code: def set_cuda_visibile():
      cuda_visible = os.environ.get("CUDA_VISIBLE_DEVICES", None)
      xdist_worker_id = get_xdist_worker_id()
      if xdist_worker_id is None:
          xdist_worker_id = 0
      if cuda_visible is None:
          # CUDA_VISIBLE_DEVICES is not set, discover it from nvidia-smi instead
          import subprocess
  
          is_rocm_pytorch = (
              hasattr(torch.version, "hip")
              and torch.version.hip is not None
          )
          if is_rocm_pytorch:
              rocm_smi = subprocess.check_output(
                  ["rocm-smi", "--showid"]
              )
              gpu_ids = filter(
                  lambda s: "GPU" in s,
                  rocm_smi.decode("utf-8").strip().split("\n"),
              )
              num_gpus = len(list(gpu_ids))
          else:
              nvidia_smi = subprocess.check_output(
                  ["nvidia-smi", "--list-gpus"]
              )
              num_gpus = len(
                  nvidia_smi.decode("utf-8").strip().split("\n")
              )
          cuda_visible = ",".join(map(str, range(num_gpus)))
  
      # rotate list based on xdist worker id, example below
      # wid=0 -> ['0', '1', '2', '3']
      # wid=1 -> ['1', '2', '3', '0']
      # wid=2 -> ['2', '3', '0', '1']
      # wid=3 -> ['3', '0', '1', '2']
      dev_id_list = cuda_visible.split(",")
      dev_id_list = (
          dev_id_list[xdist_worker_id:] + dev_id_list[:xdist_worker_id]
      )
      os.environ["CUDA_VISIBLE_DEVICES"] = ",".join(dev_id_list)
  
imports: import os
  import time
  import inspect
  from abc import ABC, abstractmethod
  from pathlib import Path
  import torch
  import torch.multiprocessing
  import deepspeed
  import deepspeed.comm
  from torch.multiprocessing import Process
  import pytest
  from _pytest.outcomes import Skipped
  from _pytest.fixtures import FixtureLookupError, FixtureFunctionMarker
label_desc: Use image node_id 3 for calling a global function with example usage: set_cuda_visibile() without return types