code: def pre_process():
      global pool
      pool = Pool(processes=NUM_PROCESSES)
      master_port = find_free_network_port()
      pool.starmap(
          setup_ddp,
          [
              (rank, NUM_PROCESSES, master_port)
              for rank in range(NUM_PROCESSES)
          ],
      )
      yield
      pool.close()
      pool.join()
  
file_path: fastNLP/tests/core/metrics/test_accuracy_torch.py
imports: import os
  import sys
  from typing import Dict, List, Any, Callable, Type, Union
  from functools import partial
  import copy
  import socket
  import pytest
  import numpy
  from fastNLP.core.dataset import DataSet
  from fastNLP.core.metrics.accuracy import Accuracy
  from fastNLP.core.metrics.metric import Metric
  from .utils import find_free_network_port, setup_ddp, _assert_allclose
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
label_desc: Use image node_id 2 for calling a global function with example usage: pre_process() without return types