Although the recipe for forward pass needs to be defined within this function, one should call the instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
This means that in practice you should use encoder(...) because it will call encoder.forward(...), but it will also do some other things (i.e. run registered hooks if any).