def METHOD_NAME(self, dataset, K):
    """Performs a K-fold split of the tasks for dataset.
    If split is uneven, spillover goes to last fold.
    Parameters
    ----------
    dataset: dc.data.Dataset
        Dataset to be split
    K: int
        Number of splits to be made
    """
    n_tasks = len(dataset.get_task_names())
    n_per_fold = int(np.round(n_tasks / float(K)))
    if K * n_per_fold != n_tasks:
        print("Assigning extra tasks to last fold due to uneven split")
    X, y, w, ids = dataset.X, dataset.y, dataset.w, dataset.ids
    fold_datasets = []
    for fold in range(K):
        if fold != K - 1:
            fold_tasks = range(fold * n_per_fold, (fold + 1) * n_per_fold)
        else:
            fold_tasks = range(fold * n_per_fold, n_tasks)
        if len(w.shape) == 1:
            w_tasks = w
        elif w.shape[1] == 1:
            w_tasks = w[:, 0]
        else:
            w_tasks = w[:, fold_tasks]
        fold_datasets.append(NumpyDataset(X, y[:, fold_tasks], w_tasks,
                                          ids))
    return fold_datasets