def distributed_init(dataset_name, local_process_group, view_name=None):
        """Initializes a trainer process during distributed training.

        This function should be called at the beginning of the training script.
        It facilitates communication between processes and safely creates a
        database connection for each trainer.

        Args:
            dataset_name: the name of the dataset to load
            local_process_group: the process group with all the processes
                running the main training script
            view_name (None): the name of a saved view to load

        Returns:
            the loaded :class:`fiftyone.core.dataset.Dataset` or
            :class:`fiftyone.core.view.DatasetView`
        """
        import fiftyone as fo

        # make sure all processes have the same authkey
        local_broadcast_process_authkey(local_process_group)

        for i in range(get_local_size(local_process_group)):
            if get_local_rank(local_process_group) == i:
                dataset = fo.load_dataset(dataset_name)
                if view_name is not None:
                    dataset = dataset.load_saved_view(view_name)

            torch.distributed.barrier(local_process_group)

        return dataset
Initializes a trainer process during distributed training.

        This function should be called at the beginning of the training script.
        It facilitates communication between processes and safely creates a
        database connection for each trainer.

        Args:
            dataset_name: the name of the dataset to load
            local_process_group: the process group with all the processes
                running the main training script
            view_name (None): the name of a saved view to load

        Returns:
            the loaded :class:`fiftyone.core.dataset.Dataset` or
            :class:`fiftyone.core.view.DatasetView`
        
fiftyone/utils/torch.py