Not really sure what you want to do, but you could circumvent modifying autograd itself since you can directly access to gradient informations by sometensor.grad (or maybe there would be some proper way to do this) for Tensors of leaf nodes with requires_grad==True. In my case, when I faced a wall with autograd problem, this youtube vid 15 really helped me a lot (13 min)
btw is it proper to link a youtube here? it is educational one about pytorch.