Hook on all layers of pretrained model

The documentation for hooks is very less, hence this question.

Is there any way to register a hook on all layers of a pretrained model that are used during evaluation? I’m currently registering a hook on all model.modules() but I feel that it is not an elegant solution, since all elements of model.modules() don’t run during evaluation (correct me if I’m wrong here).

Currently, I’m doing it as:
Query regarding register_backward_hook

Is there a more efficient way of doing it?