wow 
so cool!
thanks
the following code making it more clear for myself, maybe it helps others too
from torch import FloatTensor
from torch.autograd import Variable


# Define the leaf nodes
a = Variable(FloatTensor([4]))

weights = [Variable(FloatTensor([i]), requires_grad=True) for i in (2, 5, 9, 7)]

# unpack the weights for nicer assignment
w1, w2, w3, w4 = weights

b = w1 * a
c = w2 * a
d = w3 * b + w4 * c
L = (10 - d)

L.register_hook(lambda grad: print(grad)) 
d.register_hook(lambda grad: print(grad)) 
b.register_hook(lambda grad: print(grad)) 
c.register_hook(lambda grad: print(grad)) 
b.register_hook(lambda grad: print(grad)) 

L.backward()


for index, weight in enumerate(weights, start=1):
    gradient, *_ = weight.grad.data
    print(f"Gradient of w{index} w.r.t to L: {gradient}")


tensor([1.])
tensor([-1.])
tensor([-7.])
tensor([-9.])
tensor([-9.])
Gradient of w1 w.r.t to L: -36.0
Gradient of w2 w.r.t to L: -28.0
Gradient of w3 w.r.t to L: -8.0
Gradient of w4 w.r.t to L: -20.0