import copy
import random


def generate_training_sets(dataset, percentage, copies):
    """Resample from separated training sets to generate smaller training sets.

    No instance will present in one new training set more than once.
    Mechanism is to shuffle, then pick the first percentage% instances.

    Args:
        dataset (list): List of vectors (features + label)
        percentage (number that supports __mul__ and __floordiv__):
            This decides the size of new training set generated related to the
            population.
        copies (int): The number of new training sets required.

    Returns:
        list: list of new training datasets
            list of list of vectors

    """
    training_sets = []
    i = copies
    while i > 0:
        population = copy.deepcopy(dataset)
        random.shuffle(population)
        training_sets.append(population[:len(population) * percentage // 100])
        i -= 1

    return training_sets