If you want to compute second-order derivatives, I think you mean to find the derivative of your grad_output wrt to another output (not grad_output), because that grad_output would not be part of this grad_output’s graph.
Have you tried registering a full backward hook on a module in which your hook function calls autograd.grad(grad_wrt_this_output, (other_output,))?