def barrier(group: Optional[ProcessGroup] = None) -> None:
    """Synchronize all processes from the given process group.

    This collective blocks processes until the whole group enters this
    function.

    Note:
        Calling ``barrier`` in non-distributed environment will do nothing.

    Args:
        group (ProcessGroup, optional): The process group to work on. If None,
            the default process group will be used. Defaults to None.
    """
    if is_distributed():
        # handle low versions of torch like 1.5.0 which does not support
        # passing in None for group argument
        if group is None:
            group = get_default_group()
        torch_dist.barrier(group)
Synchronize all processes from the given process group.

This collective blocks processes until the whole group enters this
function.

Note:
Calling ``barrier`` in non-distributed environment will do nothing.

Args:
group (ProcessGroup, optional): The process group to work on. If None,
the default process group will be used. Defaults to None.
projects/llava_sam2/evaluation/utils/dist.py