code: def collect_results_cpu(result_part, size, tmpdir=None):
      rank, world_size = get_dist_info()
      # create a tmp dir if it is not specified
      if tmpdir is None:
          MAX_LEN = 512
          # 32 is whitespace
          dir_tensor = torch.full(
              (MAX_LEN,), 32, dtype=torch.uint8, device="cuda"
          )
          if rank == 0:
              mmcv.mkdir_or_exist(".dist_test")
              tmpdir = tempfile.mkdtemp(dir=".dist_test")
              tmpdir = torch.tensor(
                  bytearray(tmpdir.encode()),
                  dtype=torch.uint8,
                  device="cuda",
              )
              dir_tensor[: len(tmpdir)] = tmpdir
          dist.broadcast(dir_tensor, 0)
          tmpdir = dir_tensor.cpu().numpy().tobytes().decode().rstrip()
      else:
          mmcv.mkdir_or_exist(tmpdir)
      # dump the part result to the dir
      mmcv.dump(result_part, osp.join(tmpdir, f"part_{rank}.pkl"))
      dist.barrier()
      # collect all parts
      if rank != 0:
          return None
      else:
          # load results of all parts from tmp dir
          part_list = []
          for i in range(world_size):
              part_file = osp.join(tmpdir, f"part_{i}.pkl")
              part_list.append(mmcv.load(part_file))
          # sort the results
          ordered_results = []
          for res in zip(*part_list):
              ordered_results.extend(list(res))
          # the dataloader may pad some samples
          ordered_results = ordered_results[:size]
          # remove tmp dir
          shutil.rmtree(tmpdir)
          return ordered_results
  
file_path: insightface/detection/scrfd/mmdet/apis/test.py
imports: import os.path
  import pickle
  import shutil
  import tempfile
  import time
  import mmcv
  import torch
  import torch.distributed
  from mmcv.image import tensor2imgs
  from mmcv.runner import get_dist_info
  from mmdet.core import encode_mask_results
label_desc: Use image node_id 3 for calling a global function with example usage: collect_results_cpu(result_part, size, tmpdir) and returns: None, ordered_results