def _stop_distributed_training(self, trainer, pl_module):
    if (trainer.use_ddp or trainer.use_ddp2):
        stop = torch.tensor(int(trainer.should_stop), device=pl_module.device)
        dist.all_reduce(stop, op=dist.reduce_op.SUM)
        dist.barrier()
        trainer.should_stop = (stop == trainer.world_size)
    if trainer.use_tpu:
        stop = torch.tensor(int(trainer.should_stop), device=pl_module.device, dtype=torch.int32)
        stop = xm.mesh_reduce('stop_signal', stop, torch.cat)
        torch_xla.core.xla_model.rendezvous('pl.EarlyStoppingCallback.stop_distributed_training_check')
        trainer.should_stop = (int(stop.item()) == trainer.world_size)
def _stop_distributed_training(self, trainer, pl_module):
    if (trainer.use_ddp or trainer.use_ddp2):
        stop = torch.tensor(int(trainer.should_stop), device=pl_module.device)
        dist.all_reduce(stop, op=dist.reduce_op.SUM)
        dist.barrier()
        trainer.should_stop = (stop == trainer.world_size)
    if trainer.use_tpu:
        stop = torch.tensor(int(trainer.should_stop), device=pl_module.device, dtype=torch.int32)
        stop = xm.mesh_reduce('stop_signal', stop, torch.cat)
        torch_xla.core.xla_model.rendezvous('pl.EarlyStoppingCallback.stop_distributed_training_check')
        trainer.should_stop = (int(stop.item()) == trainer.world_size)