code: def _equalize_cv(img, mask=None):
      if mask is None:
          return cv2.equalizeHist(img)
  
      histogram = cv2.calcHist(
          [img], [0], mask, [256], (0, 256)
      ).ravel()
      i = 0
      for val in histogram:
          if val > 0:
              break
          i += 1
      i = min(i, 255)
  
      total = np.sum(histogram)
      if histogram[i] == total:
          return np.full_like(img, i)
  
      scale = 255.0 / (total - histogram[i])
      _sum = 0
  
      lut = np.zeros(256, dtype=np.uint8)
      i += 1
      for i in range(i, len(histogram)):
          _sum += histogram[i]
          lut[i] = clip(round(_sum * scale), np.dtype("uint8"), 255)
  
      return cv2.LUT(img, lut)
  
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 10 for calling a global function with example usage: _equalize_cv(img, mask) and returns: cv2, cv2, np