Solved by richard in post #2 
              
              
                Effectively, x.grad = 2 * x + y, y.grad = x + 2 * y. 
Because of this, the amount that x contributes to grad_sum is 4 through the 2 * x.grad term and 1 through the y_grad term. Hence x_hv = 5 * torch.ones(2, 2). 
The amount that y contributes to grad_sum is 2 through the 2 * x.grad term and 2 throug…