torch.Tensor.retain_grad Tensor.retain_grad() → None Enables this Tensor to have their grad populated during . This is a no-op for leaf tensors.