code: def _get_num_physical_gpus():
      if RAY_ON_SPARK_WORKER_GPU_NUM in os.environ:
          # In some cases, spark standalone cluster might configure part of physical
          # GPUs for spark worker,
          # but we cannot easily get related configuration,
          # as a workaround, we provide an environmental variable config
          # `RAY_ON_SPARK_WORKER_CPU_CORES` for user.
          return int(os.environ[RAY_ON_SPARK_WORKER_GPU_NUM])
  
      try:
          completed_proc = subprocess.run(
              "nvidia-smi --query-gpu=name --format=csv,noheader",
              shell=True,
              check=True,
              text=True,
              capture_output=True,
          )
      except Exception as e:
          raise RuntimeError(
              "Running command `nvidia-smi` for inferring GPU devices list failed."
          ) from e
      return len(completed_proc.stdout.strip().split("\n"))
  
imports: import subprocess
  import os
  import sys
  import random
  import threading
  import collections
  import logging
  import time
label_desc: Use image node_id 16 for calling a global function with example usage: _get_num_physical_gpus() and returns: len, int