Hi, I see that you are using the unsafe hack I previously proposed.
Just want to notice you that there seems to be a new elegant way to do this.
Please take a look at NN Module functional API · Issue #49171 · pytorch/pytorch · GitHub
which shall provide an elegant solution after 1.11 release.