# tensorplay.nn.modules.module.register_module_forward_pre_hook

Source: https://www.tensorplay.cn/docs/generated/tensorplay.nn.modules.module.register_module_forward_pre_hook.html

# tensorplay.nn.modules.module.register_module_forward_pre_hook

tensorplay.nn.modules.module.register_module_forward_pre_hook(hook: [Callable](https://docs.python.org/3/library/typing.html#typing.Callable)[[...], [None](https://docs.python.org/3/library/constants.html#None)]) &#x2192; RemovableHandle[[source]](../_modules/tensorplay/nn/modules/module.html#register_module_forward_pre_hook)

Register a forward pre-hook common to all modules.

Warning

This adds global state to the nn.module module
and it is only intended for debugging/profiling purposes.

The hook will be called every time before forward() is invoked.
It should have the following signature:

```
hook(module, input) -> None or modified input
```

The input contains only the positional arguments given to the module.
Keyword arguments won’t be passed to the hooks and only to the forward.
The hook can modify the input. User can either return a tuple or a
single modified value in the hook. We will wrap the value into a tuple
if a single value is returned(unless that value is already a tuple).

This hook has precedence over the specific module hooks registered with
register_forward_pre_hook.

Returns:

a handle that can be used to remove the added hook by calling
handle.remove()

Return type:

tensorplay.utils.hooks.RemovableHandle
