def distributed_device() -> torch.device:
    """
    Get the correct `torch.device` of the current process to use for distributed point-to-point communication.
    """
    if not is_distributed():
        raise RuntimeError(
            "'distributed_device()' can only be called within a distributed process group"
        )
    return int_to_device(-1 if dist.get_backend() != "nccl" else torch.cuda.current_device())
Get the correct `torch.device` of the current process to use for distributed point-to-point communication.
allennlp/nn/util.py