All Tensors that have  requires_grad  38 which is  False  will be leaf Tensors by convention.


For Tensors that have  requires_grad  38 which is  True , they will be leaf Tensors if they were created by the user. This means that they are not the result of an operation and so  grad_fn  is None.


Only leaf Tensors will have their  grad  6 populated during a call to  backward()  2. To get  grad  6 populated for non-leaf Tensors, you can use  retain_grad()  85.

Hi I just started learning about autograd and I have some confusion about the PyTorch docs above, it says that if requires_grad is False then it is a leaf tensor and only leaf tensor will have their grad populated during the call to backward, but why a tensor’s grad is populated when it does not require gradient? What is the purpose of the is_leaf attribute?