def all_gather(data, group=None):
    """Gathers arbitrary picklable data (not necessarily tensors).

    Args:
        data: any picklable object
        group (None): a torch process group. By default, uses a group which
            contains all ranks on gloo backend

    Returns:
        the list of data gathered from each rank
    """
    if get_world_size() == 1:
        return [data]

    if group is None:
        # use CPU group by default, to reduce GPU RAM usage
        group = _get_global_gloo_group()

    world_size = dist.get_world_size(group)
    if world_size == 1:
        return [data]

    output = [None for _ in range(world_size)]
    dist.all_gather_object(output, data, group=group)
    return output
Gathers arbitrary picklable data (not necessarily tensors).

    Args:
        data: any picklable object
        group (None): a torch process group. By default, uses a group which
            contains all ranks on gloo backend

    Returns:
        the list of data gathered from each rank
    
fiftyone/utils/torch.py