code: def contrast(data, parameter):
      """
      It follows PIL implementation of Contrast enhancement which uses a channel-weighted
      mean as a contrast center.
      """
      # assumes FHWC or HWC layout
      mean = fn.reductions.mean(data, axis_names="HW", keep_dims=True)
      rgb_weights = types.Constant(
          np.array([0.299, 0.587, 0.114], dtype=np.float32)
      )
      center = fn.reductions.sum(
          mean * rgb_weights, axis_names="C", keep_dims=True
      )
      # it could be just `fn.contrast(data, contrast=parameter, contrast_center=center)`
      # but for GPU `data` the `center` is in GPU mem, and that cannot be passed
      # as named arg (i.e. `contrast_center`) to the operator
      return fn.cast_like(center + (data - center) * parameter, data)
  
imports: from nvidia.dali import fn
  from nvidia.dali import types
  from nvidia.dali.auto_aug.core import augmentation
label_desc: Use image node_id 12 for calling a global function with example usage: contrast(data, parameter) and returns: fn