just beware that you can have a tensor with no elements and non-trivial size.
t = torch.zeros(size=(1,0))
t.nelement()   # returns zero, empty in this sense
len(t.size())  # returns two, not empty in this sense!!
len(t)         # returns one, not empty in this sense!!

t = torch.zeros(size=(0,1))
len(t)         # returns zero for this one!