(tensors, dim=0)
return torch.cat(tensors, dim)
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
Efficient version of torch . cat that avoids a copy if there is only a single element in a list
def cat(tensors, dim=0):
    """
    Efficient version of torch.cat that avoids a copy if there is only a single element in a list
    """
    assert isinstance(tensors, (list, tuple))
    if len(tensors) == 1:
        return tensors[0]
    return torch.cat(tensors, dim)
def cat ( tensors , dim = 0 ) : assert isinstance ( tensors , ( list , tuple ) ) if len ( tensors ) == 1 : return tensors [ 0 ] return torch . cat ( tensors , dim )