code: def _test_kernels(device, num_dims, smoothing, normalize):
      batch_size = (max_window_size + 2 - min_window_size) // 2
  
      def get_inputs():
          ones = []
          window_sizes = []
          smoothing_sizes = []
          scales = []
          padding = 2
          for win_size in range(
              min_window_size, max_window_size + 2, 2
          ):
              a_size = win_size + padding
              a = np.zeros((a_size,) * num_dims, dtype=np.float32)
              a[(a_size // 2,) * num_dims] = 1
              ones.append(a)
              window_sizes.append(np.array(win_size, dtype=np.int32))
              if smoothing:
                  smoothing_sizes.append(
                      np.array(win_size, dtype=np.int32)
                  )
                  exponent = num_dims * win_size - 2 - num_dims
              else:
                  smoothing_sizes.append(np.array(1, dtype=np.int32))
                  exponent = win_size - 3
              scales.append(
                  np.array(2.0 ** (-exponent), dtype=np.float32)
              )
          return ones, window_sizes, smoothing_sizes, scales
  
      @pipeline_def
      def pipeline():
          (
              ones,
              window_sizes,
              smoothing_sizes,
              scales,
          ) = fn.external_source(get_inputs, num_outputs=4)
          if device == "gpu":
              ones = ones.gpu()
          kernels = fn.laplacian(
              ones,
              window_size=window_sizes,
              smoothing_size=smoothing_sizes,
              dtype=types.FLOAT,
              normalized_kernel=normalize,
              device=device,
          )
          return kernels, scales
  
      def outer(*vs):
          acc = np.array([1.0])
          for v in vs:
              acc = np.outer(acc, v)
          return acc.reshape(tuple(len(v) for v in vs))
  
      def get_cv2_kernel(win_size, smoothing):
          d, s = cv2.getDerivKernels(2, 0, win_size)
          if not smoothing:
              s = np.zeros(win_size)
              s[win_size // 2] = 1.0
          windows = [
              [d if i == j else s for j in range(num_dims)]
              for i in range(num_dims)
          ]
          return sum(outer(*ws) for ws in windows)
  
      pipe = pipeline(num_threads=4, batch_size=batch_size, device_id=0)
      pipe.build()
      (kernels, scales) = pipe.run()
      if device == "gpu":
          kernels = kernels.as_cpu()
      kernels = [
          np.array(ker)[(slice(1, -1),) * num_dims] for ker in kernels
      ]
      scales = [np.array(sf).item() for sf in scales]
      win_sizes = range(min_window_size, max_window_size + 2, 2)
      assert len(kernels) == len(win_sizes) == len(scales)
      baseline_kernels = [
          get_cv2_kernel(win_size, smoothing) * scale
          for win_size, scale in zip(win_sizes, scales)
      ]
      if not normalize:  # output was not normalized by the op
          kernels = [
              kernel * scale for kernel, scale in zip(kernels, scales)
          ]
      check_batch(
          kernels,
          baseline_kernels,
          batch_size,
          max_allowed_error=1e-5,
          expected_layout="HWC",
      )
  
imports: from nvidia.dali.pipeline import pipeline_def
  import nvidia.dali.types
  import nvidia.dali.fn
  import numpy
  import cv2
  from scipy.ndimage import convolve1d, filters
  import os
  from nose_utils import assert_raises
  from nose.plugins.attrib import attr
  from sequences_test_utils import video_suite_helper, ArgCb
  from test_utils import get_dali_extra_path, check_batch, RandomlyShapedDataIterator
label_desc: Use image node_id 2 for calling a global function with example usage: _test_kernels(device, num_dims, smoothing, normalize) and returns: ones,  window_sizes,  smoothing_sizes,  scales, kernels,  scales, acc, sum