You can get better intuition of what’s happening by using torchviz:

image624×1416 38.5 KB

The node dup_x.grad_fn.next_functions[0][0] is the AccumulateGrad that you see in the first figure, which corresponds exactly to the  AccumulateGrad node you see in the second figure.
You can verify this with:
assert(id(dup_x.grad_fn.next_functions[0][0]) = id(l.grad_fn.next_functions[0][0]))