# JoinHook Source: https://www.tensorplay.cn/docs/generated/tensorplay.distributed.algorithms.JoinHook.html ```python class tensorplay.distributed.algorithms.JoinHook ``` This defines a join hook, which provides two entry points in the join context manager. Entry points : a main hook, which is called repeatedly while there exists a non-joined process, and a post-hook, which is called once all processes have joined. To implement a join hook for the generic join context manager, define a class that inherits from [JoinHook](#tensorplay.distributed.algorithms.JoinHook) and override main_hook() and post_hook() as appropriate. ```python main_hook() → None ``` Call this hook while there exists a non-joined process to shadow collective communications in a training iteration. Training iteration i.e., in one forward pass, backward pass, and optimizer step. ```python post_hook(is_last_joiner: bool) → None ``` Call hook after all processes have joined. It is passed an additional bool argument is_last_joiner, which indicates if the rank is one of the last to join. Parameters: is_last_joiner ([bool](https://docs.python.org/3/builtins/functions.html#bool)) – True if the rank is one of the last to join; False otherwise.