Hi, the following code outputs 10, but I do not understand how the code arrives at this result.  Would anyone be able to explain what the logic is for this result?
import torch
from torch.autograd import Variable

val = torch.FloatTensor([1])
x = Variable(val,requires_grad=True)
y = x * 2
z = y ** 2

torch.autograd.backward([z],[val],retain_variables=True)
torch.autograd.backward([y],[val],retain_variables=True)

g = x.grad
print(g)#> Outputs : 10