def duplicate(x, rep):
    """Duplicate x rep times.

    Args:
        x (torch.Tensor): Tensor to replicate
        rep (int): Number of times to replicate

    Returns:
        torch.Tensor: Replicated Tensor
    """
    return x.expand(rep, *x.shape).reshape(-1, *x.shape[1:])