code: def test_cmn_optimized_vs_cpu(
      batch_size, shape, dtype, pad, mirror, crops, layout
  ):
      @pipeline_def(batch_size=batch_size, device_id=0, num_threads=4)
      def pipe(device):
          def get_data():
              out = [
                  np.arange(np.prod(shape), dtype=np.uint8).reshape(
                      shape
                  )
                  for _ in range(batch_size)
              ]
              return out
  
          data = fn.external_source(source=get_data)
          crop_h, crop_w = crops
          crop_h_int = int(crop_h * shape[0]) if crop_h else None
          crop_w_int = int(crop_w * shape[1]) if crop_w else None
          data = data.gpu() if device == "gpu" else data
          return fn.crop_mirror_normalize(
              data,
              device=device,
              dtype=dtype,
              pad_output=pad,
              mirror=mirror,
              crop_h=crop_h_int,
              crop_w=crop_w_int,
              mean=[0.1, 0.2, 0.3],
              fill_values=[0.0, 0.0, 0.0, 42.0] if pad else None,
              output_layout=layout,
          )
  
      pipe_baseline = pipe("cpu")
      pipe_opt = pipe("gpu")
      compare_pipelines(pipe_baseline, pipe_opt, batch_size, 3)
  
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 21 for calling a global function with example usage: test_cmn_optimized_vs_cpu(batch_size, shape, dtype, pad, mirror, crops, layout) and returns: fn, out