code: def _run_distributed(
      func, world_size, args: Dict, script=__file__, env=dict()
  ):
      device_count = torch.cuda.device_count()
      if device_count < world_size:
          pytest.skip(
              "No enough GPU, only {} found".format(device_count)
          )
      import subprocess
      import os
  
      ps = []
      env["MASTER_ADDR"] = "localhost"
      global port_count
      env["MASTER_PORT"] = str(9010 + port_count)
      port_count += 1
      env["OMPI_COMM_WORLD_SIZE"] = str(world_size)
      env["LD_LIBRARY_PATH"] = os.environ.get("LD_LIBRARY_PATH")
  
      for i in range(world_size):
          env["OMPI_COMM_WORLD_RANK"] = str(i)
          p = subprocess.Popen(
              [sys.executable, script, func, json.dumps(args)],
              stdout=subprocess.PIPE,
              env=env,
          )
          ps.append(p)
  
      for p in ps:
          p.wait()
          retc = p.poll()
          assert retc == 0
  
file_path: fastmoe/tests/test_ddp.py
imports: import json
  import random
  import os
  import sys
  from typing import Dict
  import random
  import socket
  import pytest
  import torch
  import torch.distributed
  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 2 for calling a global function with example usage: _run_distributed(func, world_size, args, script, env) without return types