code: def get_device_status(dev_index: int) -> _nvml_device_status:
      _init()
      if _init_pid is None:
          return None
  
      c_device = _nvmlDevice_t()
      c_utils = _nvmlUtilization_t()
      c_temperature = c_uint()
      c_memory_info = _nvmlBAR1Memory_t()
  
      dev_uuid = get_device_info(dev_index).uuid
  
      if not _is_wsl:
          _nvml_check_error(
              _nvml_lib.nvmlDeviceGetHandleByUUID(
                  dev_uuid, byref(c_device)
              )
          )
  
          _nvml_check_error(
              _nvml_lib.nvmlDeviceGetUtilizationRates(
                  c_device, byref(c_utils)
              )
          )
          gpu_util = c_utils.gpu
          mem_util = c_utils.memory
  
          _nvml_check_error(
              _nvml_lib.nvmlDeviceGetTemperature(
                  c_device, NVML_TEMPERATURE_GPU, byref(c_temperature)
              )
          )
          temperature = c_temperature.value
  
          _nvml_check_error(
              _nvml_lib.nvmlDeviceGetMemoryInfo(
                  c_device, byref(c_memory_info)
              )
          )
          fb_total_mem = c_memory_info.total
          fb_free_mem = c_memory_info.free
          fb_used_mem = c_memory_info.used
      else:
          import defusedxml
  
          proc = subprocess.Popen(
              [
                  "/usr/lib/wsl/lib/nvidia-smi",
                  "-q",
                  f"--id={dev_index}",
                  "-x",
              ],
              stdout=subprocess.PIPE,
          )
          proc.wait()
          xml_result = defusedxml.ElementTree.fromstring(
              proc.stdout.read()
          )
          gpu_node = xml_result.find("gpu")
  
          fb_node = gpu_node.find("fb_memory_usage")
          fb_total_mem = int(
              parse_readable_size(fb_node.find("total").text)[0]
          )
          fb_free_mem = int(
              parse_readable_size(fb_node.find("free").text)[0]
          )
          fb_used_mem = int(
              parse_readable_size(fb_node.find("used").text)[0]
          )
  
          util_node = gpu_node.find("utilization")
          if util_node.find("gpu_util").text == "N/A":
              gpu_util = 0
          else:
              gpu_util = int(util_node.find("gpu_util"))
          if util_node.find("memory_util").text == "N/A":
              mem_util = 0
          else:
              mem_util = int(util_node.find("memory_util"))
  
          temperature = int(
              gpu_node.find("temperature").find("gpu_temp").text[:-1]
          )
  
      return _nvml_device_status(
          gpu_util=gpu_util,
          mem_util=mem_util,
          temperature=temperature,
          fb_total_mem=fb_total_mem,
          fb_free_mem=fb_free_mem,
          fb_used_mem=fb_used_mem,
      )
  
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 13 for calling a global function with example usage: get_device_status(dev_index) and returns: _nvml_device_status, None