def is_global_primary() -> bool:
    """
    Checks if the distributed process group is the global primary (rank = 0).
    If the distributed process group is not available or has not been initialized,
    this trivially returns `True`.
    """
    if not is_distributed():
        return True
    else:
        return dist.get_rank() == 0
Checks if the distributed process group is the global primary (rank = 0).
If the distributed process group is not available or has not been initialized,
this trivially returns `True`.
allennlp/common/util.py