code: def check_cmn_per_sample_norm_args(
      cmn_fn, device, rand_mean, rand_stdev, scale, shift
  ):
      @pipeline_def(num_threads=3, device_id=0)
      def pipe():
          image_like = fn.random.uniform(
              device=device, range=(0, 255), shape=(80, 120, 3)
          )
          image_like = fn.reshape(image_like, layout="HWC")
          mean = [0.485 * 255, 0.456 * 255, 0.406 * 255]
          std = [0.229 * 255, 0.224 * 255, 0.225 * 255]
          if rand_mean:
              mean = fn.random.uniform(range=(100, 125), shape=(3,))
          if rand_stdev:
              std = fn.random.uniform(range=(55, 60), shape=(3,))
          out = cmn_fn(
              image_like,
              dtype=types.FLOAT,
              output_layout="HWC",
              mean=mean,
              std=std,
              scale=scale,
              shift=shift,
              pad_output=False,
          )
          return out, image_like, mean, std
  
      batch_size = 10
      p = pipe(batch_size=batch_size)
      p.build()
      for _ in range(3):
          outs = p.run()
          for s in range(batch_size):
              out, image_like, mean, std = [
                  np.array(o[s].as_cpu())
                  if isinstance(o, dali.backend_impl.TensorListGPU)
                  else np.array(o[s])
                  for o in outs
              ]
          ref_scale = scale or 1.0
          ref_shift = shift or 0.0
          ref_out = ref_scale * (image_like - mean) / std + ref_shift
          np.testing.assert_allclose(
              out, ref_out, atol=ref_scale * 1e-6
          )
  
imports: import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.ops
  import nvidia.dali.types
  import os
  from functools import partial
  from nvidia.dali import pipeline_def
  from nvidia.dali.pipeline import Pipeline
  from nose2.tools import params
  from nose_utils import assert_raises
  from nose_utils import raises
  from test_slice import check_slice_output, abs_slice_start_and_end
  from test_utils import RandomDataIterator
  from test_utils import as_array
  from test_utils import compare_pipelines, dali_type_to_np
  from test_utils import get_dali_extra_path
  import itertools
label_desc: Use image node_id 15 for calling a global function with example usage: check_cmn_per_sample_norm_args(cmn_fn, device, rand_mean, rand_stdev, scale, shift) and returns: out,  image_like,  mean,  std