code: def get_device_count() -> int:
      global _gpu_count
  
      if _gpu_count is not None:
          return _gpu_count
  
      _init_nvml()
      if _nvml_lib is None:
          return None
  
      if "CUDA_VISIBLE_DEVICES" in os.environ:
          devices = os.environ["CUDA_VISIBLE_DEVICES"].strip()
          if not devices or devices == "-1":
              _gpu_count = 0
          else:
              _gpu_count = len(devices.split(","))
      else:
          n_gpus = c_uint()
          _cu_check_error(_nvml_lib.nvmlDeviceGetCount(byref(n_gpus)))
          _gpu_count = n_gpus.value
      return _gpu_count
  
imports: import dataclasses
  import logging
  import os
  import subprocess
  import sys
  import uuid
  from collections import namedtuple
  from ctypes import c_char, c_char_p, c_int, c_uint, c_ulonglong, byref, create_string_buffer, Structure, POINTER, CDLL
  from typing import List, Tuple, Optional, Union
  from ..utils import parse_readable_size
label_desc: Use image node_id 9 for calling a global function with example usage: get_device_count() and returns: _gpu_count, _gpu_count, None