I would recommend to modify the technique from @ptrblck’s excellent save_activation
example to do the appending.
Then you could add the hooks in a for n, m in model.named_modules():
-loop, so n
can be the key to the dictionary.
Best regards
Thomas