import torch


def expand_tens(tens, nb_new, device="cpu"):
    """Expands a tensor to include scores for new videos

    tens (tensor): a detached tensor
    nb_new (int): number of parameters to add
    device (str): device used (cpu/gpu)

    Returns:
        (tensor): expanded tensor requiring gradients
    """
    expanded = torch.cat([tens, torch.zeros(nb_new, device=device)])
    expanded.requires_grad = True
    return expanded