import random


def k_fold_cross_validation(k: int, num_data: int, shuffle: bool = True) -> tuple:
    """
    Splits a number of training data into k folds, which can be used for k-fold-cross-validation.
    Parameters
    ----------
    k: number of folds for cross validation.
    num_data: Total amount of data values.
    shuffle: Boolean variable, which indicates whether to shuffle the data or not.

    Returns
    -------
    split: tuple, in which lists of indices according to the splits are stored.
    """

    assert num_data >= k, "Total amount of data needs to be larger or equal to the number of folds!"

    # create indices, corresponding to the data points, and shuffle them, if required
    indices = list(range(num_data))
    if shuffle:
        random.shuffle(indices)

    # compute the sizes of the folds and the remaining number of data
    fold_size = int(num_data / k)
    remaining_data = num_data % k

    # compute the splits
    fold_list = []
    for i in range(k):
        fold_list.append(indices[i*fold_size:(i+1)*fold_size])

    # append the remaining data points to the folds
    for i in range(remaining_data):
        fold_list[i].append(indices[k*fold_size+i])
    split = tuple(fold_list)
    return split