Mean for empty tensor

How can we consider empty when we for sure know that len(an empty array)=0 ?
Actually, this happens:
torch.sum(a) / len(a), and obviously len(a)=0, so if torch.sum(a) becomes anything rather than 0, then division by zero exception will occur.
Also, torch.sum(torch.tensor([np.nan])) = tensor[nan] so [nan] / 0 = nan.

Although there might be some other reasons due to stability which I do not know about.

The main question that I have too is that why the sum of empty array is zero? Although in the case of mean, it won’t make a difference as nan/nan = nan = zero/nan .
After googling, I found that in numpy, fortran intrinsics follow this behavior:

So as torch tries to implement similar behavior to numpy, same idea is happening here.

I hope someone can explain more accurately.