In the second case there is only one tensor. grad_fn is stored as an attribute of a tensor. So you cannot store the grad_fn of multiple tensors in a single tensor (you can use a proxy to sum all the tensors, but your case that is not valid).