code: def fastnlp_torch_broadcast_object(
      obj, src, device=None, group=DEFAULT_TORCH_GROUP
  ):
      """
      将 src 上的 obj 对象广播到其它 rank 上。
  
      :param obj: 需要发送的对象
      :param src: 从哪里发出。
      :param device:
      :param group: 属于哪个通信 group
      :return:
      """
      if int(os.environ.get(FASTNLP_NO_SYNC, "0")) == 2:
          if src == dist.get_rank(group):
              return obj
          else:
              return None
  
      if group is None:
          group = DEFAULT_TORCH_GROUP
      cur_rank = dist.get_rank(group)
      if cur_rank == src:
          # 如果有 tensor 全部移动到 cpu 上，方便 pickle , 不然 unpickle 的时候可能会 pickle 到发送过来的卡那里
          obj = apply_to_collection(
              obj, torch.Tensor, _to_device, device=torch.device("cpu")
          )
      if _TORCH_GREATER_EQUAL_1_8:
          if cur_rank != src:
              get_obj = [None]
              dist.broadcast_object_list(get_obj, src=src, group=group)
              return get_obj[0]
          else:
              dist.broadcast_object_list([obj], src=src, group=group)
              return obj
      if device is None:
          device = torch.cuda.current_device()
  
      if cur_rank == src:
          tensor, size = _object_to_tensor(obj, device=device)
      else:
          size = torch.LongTensor([0]).to(device)
  
      dist.broadcast(size, src=src, group=group)
      if cur_rank != src:
          tensor = torch.empty(
              size.int().item(),  # type: ignore[arg-type]
              dtype=torch.uint8,
              device=device,
          )
      dist.broadcast(tensor, src=src, group=group)
  
      return _tensor_to_object(tensor, tensor_size=size.item())
  
file_path: fastNLP/fastNLP/core/drivers/torch_driver/dist_utils.py
imports: import io
  import pickle
  import os
  from typing import Any, List
  from fastNLP.envs.imports import _TORCH_GREATER_EQUAL_1_8
  from fastNLP.core.utils.torch_utils import DEFAULT_TORCH_GROUP
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.envs.env import FASTNLP_NO_SYNC
  from fastNLP.core.utils import apply_to_collection
label_desc: Use image node_id 8 for calling a global function with example usage: fastnlp_torch_broadcast_object(obj, src, device, group) and returns: _tensor_to_object, obj, None, get_obj, obj