Well man thank you  I was on the right track and I stopped working at the last step of the algorithm yesterday…
I used hooks to get gradinput and output of intermediate layers. Easier than his technique I think …
But anyway thanks you  I maybe didn’t do it first but at least I learned.