code: def comm_nccl_opts(request):
      """Common resources for communicator tests."""
      if not request.config.getoption("--test-communicator"):
          return None
  
      import nnabla.communicators as C
      from nnabla.ext_utils import get_extension_context
  
      try:
          from nnabla_ext import cuda
      except Exception as e:
          raise ImportError(
              "Communicator test requires CUDA extension.\n{}".format(e)
          )
  
      gpus = request.config.getoption("--communicator-gpus")
      n_devices = cuda.get_device_count()
      if gpus is None:
          devices = list(map(str, range(n_devices)))
      else:
          devices = gpus.split(",")
          # Check numbers
          try:
              for d in devices:
                  gid = int(d)
                  if gid >= n_devices:
                      raise ValueError("")
          except ValueError as e:
              raise ValueError(
                  "GPU IDs must be comma separated integers of available GPUs. Given {}. Available GPUs are {}.".format(
                      gpus, n_devices
                  )
              )
  
      extension_module = "cuda"
      type_config = request.config.getoption("--type-config")
      ctx = get_extension_context(
          extension_module, type_config=type_config
      )
      try:
          comm = C.MultiProcessCommunicator(ctx)
      except Exception as e:
          raise RuntimeError(
              "Communicator could not be created. You may haven't build with distributed support.\n{}".format(
                  e
              )
          )
      try:
          comm.init()
      except Exception as e:
          raise RuntimeError(
              "Communicator initialization failed. (Maybe MPI init failure.)\n{}".format(
                  e
              )
          )
  
      assert (
          len(devices) == comm.size
      ), "Number of cuda devices used are not same as that of processes."
      n_devices = comm.size
      mpi_rank = comm.rank
      mpi_local_rank = comm.local_rank
      ctx.device_id = devices[mpi_local_rank]
  
      class CommOpts:
          pass
  
      c = CommOpts()
      c.comm = comm
      c.ctx = ctx
      c.device_id = ctx.device_id
      c.devices = devices
      c.mpi_rank = mpi_rank
      c.mpi_local_rank = mpi_local_rank
      return c
  
label_desc: Use image node_id 2 for calling a global function with example usage: comm_nccl_opts(request) and returns: c, None