def get_world_size() -> int:
    """Returns the world size for distributed training."""
    if _is_xla_distributed_initialized():
        return xm.xrt_world_size()
    elif _is_torch_distributed_initialized():
        return dist.get_world_size()
    else:
        return 1
Returns the world size for distributed training.
catalyst/utils/distributed.py