Hi,
This is the same issue as this one: https://github.com/pytorch/pytorch/issues/1776 92
Unfortunately, this is not possible to use .backward() during another .backward() call (which is when your hook is called).