Shisho_Sama:

we have gradients for our var s, yet their grad_fn attribute is None!!?
Why is that?


As I said earlier, a variable has a grad_fn only when an operation changes its value (except when the code is wrapped in with torch.no_grad():). Here no operation changes the value of var1 or var2.
Something you can try to understand is to run this code:
x = torch.ones(2).requires_grad_(True)
y = x + 2
print (y.grad_fn, x.grad_fn)

The output should be: AddBackward None
The gradients store how much the variable affects the loss. You can see it for yourself by running along with the above code:
y.sum()
y.backward()
print(x.grad)