code: def all_gather_object(object_list, obj, group=None):
      """
  
      Example::
          >>> # Note: Process group initialization omitted on each rank.
          >>> # Assumes world_size of 3.
          >>> gather_objects = ["foo", 12, {1: 2}] # any picklable object
          >>> output = [None for _ in gather_objects]
          >>> all_gather_object(output, gather_objects[dist.get_rank()])
          >>> output
          ['foo', 12, {1: 2}]
  
      :param object_list:
      :param obj:
      :param group:
      :return:
      """
      if int(os.environ.get(FASTNLP_NO_SYNC, "0")) == 2:
          return [obj]
  
      if group is not None and not group.is_member():
          return
  
      current_device = paddle.device.get_device()
  
      input_tensor, local_size = _object_to_tensor(
          obj, device=current_device
      )
  
      # 聚合 tensor 的 size，找到最大的
      object_size_list = []
      # Allgather tensor sizes
      dist.all_gather(object_size_list, local_size, group=group)
      max_object_size = int(max(object_size_list).item())  # type: ignore[type-var]
      # 将张量进行 pad
      pad_dims = []
      pad_by = (max_object_size - local_size).detach().cpu()
      for val in reversed(pad_by):
          pad_dims.append(0)
          pad_dims.append(val.item())
      tensor_padded = paddle.nn.functional.pad(input_tensor, pad_dims)
  
      # Output tensors are nonoverlapping views of coalesced_output_tensor
      output_tensors = []
      dist.all_gather(output_tensors, tensor_padded, group=group)
      dist.barrier()
      # Deserialize outputs back to object.
      for i, tensor in enumerate(output_tensors):
          tensor = tensor.astype(paddle.uint8)
          if not tensor.place.is_cpu_place():
              tensor = tensor.cpu()
          tensor_size = object_size_list[i]
          object_list[i] = _tensor_to_object(tensor, tensor_size)
      return object_list
  
file_path: fastNLP/fastNLP/core/drivers/paddle_driver/dist_utils.py
imports: import io
  import pickle
  import os
  from typing import Any, List
  import numpy
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
  from fastNLP.envs.env import FASTNLP_NO_SYNC
  from fastNLP.core.utils import paddle_move_data_to_device
label_desc: Use image node_id 10 for calling a global function with example usage: all_gather_object(object_list, obj, group) and returns: object_list, list