def local_scatter(array, local_process_group):
    """Scatters the given array from the local leader to all local workers.

    The worker with rank ``i`` gets ``array[i]``.

    Args:
        array: an array with same size as the local process group
        local_process_group: the local process group

    Returns:
        the array element for the current rank
    """
    if get_local_size(local_process_group) == 1:
        return array[0]

    if get_local_rank(local_process_group) == 0:
        assert len(array) == get_local_size(local_process_group)
        all_gather(array)
    else:
        all_data = all_gather(None)
        array = all_data[get_rank() - get_local_rank(local_process_group)]

    return array[get_local_rank(local_process_group)]
Scatters the given array from the local leader to all local workers.

    The worker with rank ``i`` gets ``array[i]``.

    Args:
        array: an array with same size as the local process group
        local_process_group: the local process group

    Returns:
        the array element for the current rank
    
fiftyone/utils/torch.py