code: def _run_distributed(func, world_size, args: Dict, script=__file__):
      if torch.cuda.device_count() < world_size:
          pytest.skip("No enough GPU")
      import subprocess
      import os
  
      ps = []
      os.environ["MASTER_ADDR"] = "localhost"
      os.environ["MASTER_PORT"] = "36666"
      os.environ["OMPI_COMM_WORLD_SIZE"] = str(world_size)
  
      for i in range(world_size):
          os.environ["OMPI_COMM_WORLD_RANK"] = str(i)
          p = subprocess.Popen(
              [sys.executable, script, func, json.dumps(args)],
              stdout=subprocess.PIPE,
          )
          ps.append(p)
  
      for p in ps:
          p.wait()
          retc = p.poll()
          assert retc == 0
  
file_path: thu-pacman-faster-moe/tests/test_ddp.py
imports: import json
  import os
  import sys
  from typing import Dict
  import pytest
  import torch
  from test_numerical import test_fmoe
  from test_numerical import test_fmoe_linear
  from test_numerical import _test_fmoe_local_ddp
label_desc: Use image node_id 1 for calling a global function with example usage: _run_distributed(func, world_size, args, script) without return types