I want to find out how many numbers which are nonzero in the tensor：
output = model(input)
output = output.reshape(-1)
result1 = sum(output != 0)
result2 = torch.sum(output != 0)

However, I found sometimes result1 and result2 are different and the result1 is zero even though there are many nonzero elements in the output. Why?