Stop =torch.Tensor()[0] from segfaulting

Move precondition checks up to prevent element access from seg-faulting.