Actually, this is just almost the Pearlmutter method, only.... it's an inverse. Useful for optimization. I haven't actually seen a method for doing this in any of the literatures I'm familiar with.
I have the simpler functional examples in examples.py. But the main body is in writeup.pdf.
The basic trick is using the inverse function theorem to realize H^{-1}.