def _maybe_shuffle_and_repeat(dataset, num_epochs, shuffle,
    shuffle_buffer_size, shuffle_seed):
    """Optionally shuffle and repeat dataset, as requested."""
    if shuffle:
        dataset = dataset.shuffle(shuffle_buffer_size, shuffle_seed)
    if num_epochs != 1:
        dataset = dataset.repeat(num_epochs)
    return dataset
