code: def compare_against_baseline(
      dali_aug,
      baseline_op,
      get_data,
      batch_size=default_batch_size,
      dev="gpu",
      eps=1e-7,
      max_allowed_error=1e-6,
      params=None,
      post_proc=None,
      use_shape=False,
      modality="image",
  ):
      @pipeline_def(
          batch_size=batch_size, num_threads=4, device_id=0, seed=42
      )
      def pipeline():
          data = get_data()
          op_data = data if dev != "gpu" else data.gpu()
          mag_bin = fn.external_source(
              lambda info: np.array(info.idx_in_batch, dtype=np.int32),
              batch=False,
          )
          extra = {}
          if use_shape:
              shape = fn.shapes(data)
              extra["shape"] = shape[int(modality == "video") :]
          output = dali_aug(
              op_data,
              num_magnitude_bins=batch_size,
              magnitude_bin=mag_bin,
              **extra,
          )
          return output, data
  
      p = pipeline()
      p.build()
      (
          output,
          data,
      ) = p.run()
      if dev == "gpu":
          output = output.as_cpu()
      output = [np.array(sample) for sample in output]
      if isinstance(data, _tensors.TensorListGPU):
          data = data.as_cpu()
      data = [np.array(sample) for sample in data]
  
      if modality == "image":
  
          def apply_to_sample(f, sample, *params):
              return f(sample, *params)
  
      else:
  
          def apply_to_sample(f, vid, *params):
              return np.stack([f(frame, *params) for frame in vid])
  
      if params is None:
          ref_output = [
              apply_to_sample(baseline_op, sample) for sample in data
          ]
      else:
          assert len(params) == len(data)
          ref_output = [
              apply_to_sample(baseline_op, sample, param)
              for sample, param in zip(data, params)
          ]
  
      if post_proc is not None:
          output = [
              apply_to_sample(post_proc, sample) for sample in output
          ]
          ref_output = [
              apply_to_sample(post_proc, sample)
              for sample in ref_output
          ]
      check_batch(
          output,
          ref_output,
          eps=eps,
          max_allowed_error=max_allowed_error,
      )
  
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 4 for calling a global function with example usage: compare_against_baseline(dali_aug, baseline_op, get_data, batch_size, dev, eps, max_allowed_error, params, post_proc, use_shape, modality) and returns: output,  data, f, np