code: def get_mig_device_handle_by_index(
      device: _nvmlDevice_t, index: int
  ) -> _nvmlDevice_t:
      _init_nvml()
      if _nvml_lib is None:
          return None
  
      c_index = c_uint(index)
      mig_device = _nvmlDevice_t()
      _nvml_check_error(
          _nvml_lib.nvmlDeviceGetMigDeviceHandleByIndex(
              device, c_index, byref(mig_device)
          )
      )
      return mig_device
  
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 18 for calling a global function with example usage: get_mig_device_handle_by_index(device, index) and returns: mig_device, None