Solved by ptrblck in post #2 
              
              
                The grad_fn is used during the backward() operation for the gradient calculation. 
In the first example, at least one of the input tensors (part1 or part2 or both) are attached to a computation graph. Since the loss tensor is calculated from a mean() operation, the grad_fn will point to MeanBackward.…