code: def get_device_index_and_uuid(device):
      """Get both device index and UUID from 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 : CudaDeviceInfo
          Object containing information about the device.
  
      Examples
      --------
      >>> get_device_index_and_uuid(0)  # doctest: +SKIP
      {'device-index': 0, 'uuid': b'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
  
      >>> get_device_index_and_uuid('GPU-e1006a74-5836-264f-5c26-53d19d212dfe')  # doctest: +SKIP
      {'device-index': 0, 'uuid': b'GPU-e1006a74-5836-264f-5c26-53d19d212dfe'}
  
      >>> get_device_index_and_uuid('MIG-7feb6df5-eccf-5faa-ab00-9a441867e237')  # doctest: +SKIP
      {'device-index': 0, 'uuid': b'MIG-7feb6df5-eccf-5faa-ab00-9a441867e237'}
      """
      init_once()
      try:
          device_index = int(device)
          device_handle = pynvml.nvmlDeviceGetHandleByIndex(
              device_index
          )
          uuid = pynvml.nvmlDeviceGetUUID(device_handle)
      except ValueError:
          uuid = (
              device
              if isinstance(device, bytes)
              else bytes(device, "utf-8")
          )
  
          # Validate UUID, get index and UUID as seen with `nvidia-smi -L`
          uuid_handle = pynvml.nvmlDeviceGetHandleByUUID(uuid)
          device_index = pynvml.nvmlDeviceGetIndex(uuid_handle)
          uuid = pynvml.nvmlDeviceGetUUID(uuid_handle)
  
      return CudaDeviceInfo(uuid=uuid, device_index=device_index)
  
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 8 for calling a global function with example usage: get_device_index_and_uuid(device) and returns: CudaDeviceInfo