It seems that you can’t get the gradient through derivative as of pytorch 1.5:
import torch

x = torch.Tensor([1, 2, 3])
x.requires_grad_(True)
c = x ** 2
print(c.grad_fn)  # c has gradient function
dc_dx = torch.autograd.grad(c.mean(), x)[0]
print(dc_dx)
print(dc_dx.grad_fn)  # derivative of c over x doesn't have gradient function
dc_dx.backward()  # raises RuntimeError