@contextmanager
def block_ddp_sync_behaviour(self, should_block_sync: bool=False):
    '\n        automatic_optimization = True\n        Blocks ddp sync gradients behaviour on backwards pass.\n        This is useful for skipping sync when accumulating gradients, reducing communication overhead\n\n        automatic_optimization = False\n        do not block ddp gradient sync when using manual optimization\n        as gradients are needed within the training step\n\n        Returns:\n            context manager with sync behaviour off\n\n        '
    if (isinstance(self.trainer.training_type_plugin, ParallelPlugin) and (self.trainer.lightning_module.automatic_optimization or should_block_sync)):
        with self.trainer.training_type_plugin.block_backward_sync():
            (yield None)
    else:
        (yield None)
automatic_optimization = True
Blocks ddp sync gradients behaviour on backwards pass.
This is useful for skipping sync when accumulating gradients, reducing communication overhead

automatic_optimization = False
do not block ddp gradient sync when using manual optimization
as gradients are needed within the training step

Returns:
    context manager with sync behaviour off
@contextmanager
def block_ddp_sync_behaviour(self, should_block_sync: bool=False):
    '\n        automatic_optimization = True\n        Blocks ddp sync gradients behaviour on backwards pass.\n        This is useful for skipping sync when accumulating gradients, reducing communication overhead\n\n        automatic_optimization = False\n        do not block ddp gradient sync when using manual optimization\n        as gradients are needed within the training step\n\n        Returns:\n            context manager with sync behaviour off\n\n        '
    if (isinstance(self.trainer.training_type_plugin, ParallelPlugin) and (self.trainer.lightning_module.automatic_optimization or should_block_sync)):
        with self.trainer.training_type_plugin.block_backward_sync():
            (yield None)
    else:
        (yield None)