code: def solarize(img, threshold=128):
      """Invert all pixel values above a threshold.
  
      Args:
          img (numpy.ndarray): The image to solarize.
          threshold (int): All pixels above this greyscale level are inverted.
  
      Returns:
          numpy.ndarray: Solarized image.
  
      """
      dtype = img.dtype
      max_val = MAX_VALUES_BY_DTYPE[dtype]
  
      if dtype == np.dtype("uint8"):
          lut = [
              (i if i < threshold else max_val - i)
              for i in range(max_val + 1)
          ]
  
          prev_shape = img.shape
          img = cv2.LUT(img, np.array(lut, dtype=dtype))
  
          if len(prev_shape) != len(img.shape):
              img = np.expand_dims(img, -1)
          return img
  
      result_img = img.copy()
      cond = img >= threshold
      result_img[cond] = max_val - result_img[cond]
      return result_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 7 for calling a global function with example usage: solarize(img, threshold) and returns: result_img, img