def get_world_size(group: Optional[ProcessGroup] = None) -> int:
    """Return the number of the given process group.

    Note:
        Calling ``get_world_size`` in non-distributed environment will return
        1.

    Args:
        group (ProcessGroup, optional): The process group to work on. If None,
            the default process group will be used. Defaults to None.

    Returns:
        int: Return the number of processes of the given process group if in
        distributed environment, otherwise 1.
    """
    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()
        return torch_dist.get_world_size(group)
    else:
        return 1
Return the number of the given process group.

Note:
Calling ``get_world_size`` in non-distributed environment will return
1.

Args:
group (ProcessGroup, optional): The process group to work on. If None,
the default process group will be used. Defaults to None.

Returns:
int: Return the number of processes of the given process group if in
distributed environment, otherwise 1.
projects/llava_sam2/evaluation/utils/dist.py