code: def auto_contrast(data, _):
      # assumes FHWC or HWC layout
      lo = fn.reductions.min(data, axis_names="HW", keep_dims=True)
      hi = fn.reductions.max(data, axis_names="HW", keep_dims=True)
      diff = hi - lo
      mask_scale = diff > 0
      mask_id = mask_scale ^ True
      # choose div so that scale ends up being 255 / diff if diff > 0 and 1 otherwise
      div_by = (
          diff * mask_scale
          + types.Constant(255, dtype=types.UINT8) * mask_id
      )
      scale = 255 / div_by
      scaled = (data - lo * mask_scale) * scale
      return fn.cast_like(scaled, 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 24 for calling a global function with example usage: auto_contrast(data, _) and returns: fn