def shuffle_datasets(dataset_dict, dataset_names, idx1, idx2):
    """ Shuffles two elements, indicated by `idx1` and `idx2`, between
    two datasets in `dataset_dict`.
    """
    for name in dataset_names:
        dataset_dict[name][idx1], dataset_dict[name][idx2] = \
            dataset_dict[name][idx2], dataset_dict[name][idx1]

    return dataset_dict