Thanks!
But if we define the behavior of the neural model in our own function instead of defining forward and call __call__, do we need to take care of the hooks in our own function? Since __call__ will take care of all the hooks. Specifically, if we define a function called func, and then call model.func to do the computation, we will need to take care of hooks inside func by ourselves right?
Actually, I don’t quite get the necessity for the hooks. What are they essentially for? I suppose the hooks do not really affect the forward pass and back propagation. They are only used to do some auxiliary work such as visualizing the neural nets, e.t.c. In another words, our neural models can still work properly even we don’t register the hooks, e.g., we define the computation using our own entry point instead of forward.