code: def get_index_and_uuid(
      device: Union[int, bytes, str]
  ) -> CudaDeviceInfo:
      _init_nvml()
      if _nvml_lib is None:
          return None
  
      try:
          device_index = int(device)
          device_handle = get_handle_by_index(device_index)
          uuid = get_uuid(device_handle)
      except ValueError:
          uuid = (
              device if isinstance(device, bytes) else device.encode()
          )
          uuid_handle = get_handle_by_uuid(uuid)
          device_index = get_index(uuid_handle)
          uuid = get_uuid(uuid_handle)
  
      return CudaDeviceInfo(uuid=uuid, device_index=device_index)
  
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 21 for calling a global function with example usage: get_index_and_uuid(device) and returns: CudaDeviceInfo, None