code: def test_fastnlp_paddle_all_gather(self):
      obj = {
          "tensor": paddle.full(
              shape=(2,), fill_value=self.local_rank
          ).cuda(),
          "numpy": np.full(shape=(2,), fill_value=self.local_rank),
          "bool": self.local_rank % 2 == 0,
          "float": self.local_rank + 0.1,
          "int": self.local_rank,
          "dict": {"rank": self.local_rank},
          "list": [self.local_rank] * 2,
          "str": f"{self.local_rank}",
          "tensors": [
              paddle.full(
                  shape=(2,), fill_value=self.local_rank
              ).cuda(),
              paddle.full(
                  shape=(2,), fill_value=self.local_rank
              ).cuda(),
          ],
      }
      data = fastnlp_paddle_all_gather(obj)
      world_size = int(os.environ["PADDLE_TRAINERS_NUM"])
      assert len(data) == world_size
      for i in range(world_size):
          assert (data[i]["tensor"] == i).sum() == 2
          assert (data[i]["numpy"] == i).sum() == 2
          assert data[i]["bool"] == (i % 2 == 0)
          assert np.allclose(data[i]["float"], i + 0.1)
          assert data[i]["int"] == i
          assert data[i]["dict"]["rank"] == i
          assert data[i]["list"][0] == i
          assert data[i]["str"] == f"{i}"
          assert data[i]["tensors"][0][0] == i
  
      for obj in [1, True, "xxx"]:
          data = fastnlp_paddle_all_gather(obj)
          assert len(data) == world_size
          assert data[0] == data[1]
  
      dist.barrier()
  
file_path: fastNLP/tests/core/drivers/paddle_driver/test_dist_utils.py
imports: import os
  import sys
  import signal
  import pytest
  import traceback
  import numpy
  from fastNLP.core.drivers.paddle_driver.dist_utils import _tensor_to_object, _object_to_tensor, fastnlp_paddle_all_gather, fastnlp_paddle_broadcast_object
  from fastNLP.core.drivers.paddle_driver.fleet_launcher import FleetLauncher
  from tests.helpers.utils import magic_argv_env_context
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
label_desc: Use image node_id 3 for calling the TestAllGatherAndBroadCast obj's underlying member method code with example usage: obj.test_fastnlp_paddle_all_gather() without return types