code: def get_device_mig_mode(device):
      """Get MIG mode for a device index or UUID
  
      Parameters
      ----------
      device: int, bytes or str
          An ``int`` with the index of a GPU, or ``bytes`` or ``str`` with the UUID
          of a CUDA (either GPU or MIG) device.
  
      Returns
      -------
      out : list
          A ``list`` with two integers ``[current_mode, pending_mode]``.
      """
      init_once()
      try:
          device_index = int(device)
          handle = pynvml.nvmlDeviceGetHandleByIndex(device_index)
      except ValueError:
          uuid = (
              device
              if isinstance(device, bytes)
              else bytes(device, "utf-8")
          )
          handle = pynvml.nvmlDeviceGetHandleByUUID(uuid)
      try:
          return pynvml.nvmlDeviceGetMigMode(handle)
      except pynvml.NVMLError_NotSupported:
          return [0, 0]
  
imports: from __future__ import annotations
  import os
  from enum import IntEnum, auto
  from platform import uname
  from typing import NamedTuple
  from packaging.version import parse
  import dask
label_desc: Use image node_id 9 for calling a global function with example usage: get_device_mig_mode(device) and returns: pynvml, list