code: def clahe(img, clip_limit=2.0, tile_grid_size=(8, 8)):
      if img.dtype != np.uint8:
          raise TypeError("clahe supports only uint8 inputs")
  
      clahe_mat = cv2.createCLAHE(
          clipLimit=clip_limit, tileGridSize=tile_grid_size
      )
  
      if len(img.shape) == 2 or img.shape[2] == 1:
          img = clahe_mat.apply(img)
      else:
          img = cv2.cvtColor(img, cv2.COLOR_RGB2LAB)
          img[:, :, 0] = clahe_mat.apply(img[:, :, 0])
          img = cv2.cvtColor(img, cv2.COLOR_LAB2RGB)
  
      return img
  
imports: from __future__ import division
  from typing import Optional, Sequence, Union
  from warnings import warn
  import cv2
  import numpy
  import skimage
  from albumentations import random_utils
  from albumentations.augmentations.utils import MAX_VALUES_BY_DTYPE, _maybe_process_in_chunks, clip, clipped, ensure_contiguous, is_grayscale_image, is_rgb_image, non_rgb_warning, preserve_channel_dim, preserve_shape
label_desc: Use image node_id 18 for calling a global function with example usage: clahe(img, clip_limit, tile_grid_size) and returns: img