Solved by tom in post #2 
              
              
                The backward of .sum() is “.expand()”. 
The first variant (btw. I tend to write it u_t, = torch.autograd.grad(...), i.e. use tuple unpacking instead of indexing) is implicitly furnishing a scalar 1 as the grad_outputs. 
Thus the difference is that 1. has a first step does an expand of the 1 as the b…