Stop from =torch.Tensor()[0] form set-faulting

Move function preconditions up to stop set-faulting.