code: def test_solarize_add(modality, dev):
      # adapted the implementation from DeepLearningExamples:
      # https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/
      # Classification/ConvNets/image_classification/autoaugment.py
      def solarize_add_ref(image, magnitude):
          threshold = 128
          lut = []
          for i in range(256):
              if i < threshold:
                  res = i + magnitude if i + magnitude <= 255 else 255
                  res = res if res >= 0 else 0
                  lut.append(res)
              else:
                  lut.append(i)
          return ImageOps._lut(image, lut)
  
      data_source = get_images if modality == "image" else get_videos()
      solarize_add = a.solarize_add.augmentation(param_device=dev)
      magnitudes = solarize_add._get_magnitudes(default_batch_size)
      params = solarize_add._map_mags_to_params(magnitudes)
      compare_against_baseline(
          solarize_add,
          pil_baseline(solarize_add_ref),
          data_source,
          max_allowed_error=1,
          dev=dev,
          params=params,
          modality=modality,
      )
  
imports: import itertools
  import os
  import numpy
  from PIL import Image, ImageEnhance, ImageOps
  from nose2.tools import params, cartesian_params
  import nvidia.dali.tensors
  from nvidia.dali import fn, pipeline_def
  from nvidia.dali.auto_aug import augmentations
  from nvidia.dali.auto_aug.core._utils import get_translations
  from test_utils import get_dali_extra_path, check_batch
label_desc: Use image node_id 20 for calling a global function with example usage: test_solarize_add(modality, dev) and returns: ImageOps