okay_All_Right:

torchviz doesn’t show the math behind the derivatives


But hopefully the math for these simple function should be easy to derive.
At least it gives you the structure of the calculations.

so how the backward work if(eval_net) has multiple outputs ?

What do you mean? In your code example above, it returns a single Tensor that you call gather on right?
PS: You can put your code examples in between triple ticks ``` to make them look better (check how I edited your last message).