import torch


def split_train_validation(train_input, train_target, train_classes, validation_proportion = 0.2):
    """
    Splits the train tensors passed as argument into new train and validations tensors with 'validation_proportion' of the data
    """
    index_permutation = torch.randperm(train_input.size(0))
    split = int(0.2 * train_input.size(0))

    validation_index = index_permutation[:split]
    training_index = index_permutation[split:]

    validation_input = train_input[validation_index]
    validation_target = train_target[validation_index]
    validation_classes = train_classes[validation_index]

    train_input = train_input[training_index]
    train_target = train_target[training_index]
    train_classes = train_classes[training_index]
    
    return train_input, train_target, train_classes, validation_input, validation_target, validation_classes