code: def test_checkerboard_dali_vs_onnx_ref():
      improc_data_dir = os.path.join(test_data_root, "db", "imgproc")
      ref_dir = os.path.join(improc_data_dir, "ref", "resampling")
  
      # Checker board with shape (22, 22) with 2x2 squares
      checkerboard_file = os.path.join(
          improc_data_dir, "checkerboard_22_22.npy"
      )
      checkerboard = np.load(checkerboard_file)
      assert checkerboard.shape == (22, 22)
  
      out_size = (17, 13)
      out_size_str = "_".join([str(n) for n in out_size])
      ref_resized_linear_filename = os.path.join(
          ref_dir, f"checkerboard_linear_{out_size_str}.npy"
      )
      ref_resized_linear_antialias_filename = os.path.join(
          ref_dir, f"checkerboard_linear_antialias_{out_size_str}.npy"
      )
      ref_resized_cubic_filename = os.path.join(
          ref_dir, f"checkerboard_cubic_{out_size_str}.npy"
      )
      ref_resized_cubic_antialias_filename = os.path.join(
          ref_dir, f"checkerboard_cubic_antialias_{out_size_str}.npy"
      )
  
      # Reference generated with ONNX reference code. To regenerate uncomment
      # from onnx.backend.test.case.node.resize import interpolate_nd, linear_coeffs, \
      #     linear_coeffs_antialias, cubic_coeffs, cubic_coeffs_antialias
      #
      # ref_resized_linear = interpolate_nd(checkerboard, lambda x, _: linear_coeffs(x),
      #                                     output_size=out_size)
      # np.save(ref_resized_linear_filename, ref_resized_linear)
      # ref_resized_linear_antialias = interpolate_nd(checkerboard, linear_coeffs_antialias,
      #                                               output_size=out_size)
      # np.save(ref_resized_linear_antialias_filename, ref_resized_linear_antialias)
      # ref_resized_cubic = interpolate_nd(checkerboard, lambda x, _: cubic_coeffs(x, A=-0.5),
      #                                    output_size=out_size)
      # np.save(ref_resized_cubic_filename, ref_resized_cubic)
      # ref_resized_cubic_antialias = interpolate_nd(checkerboard,
      #                                              lambda x, scale: cubic_coeffs_antialias(x, scale,
      #                                                                                      A=-0.5),
      #                                              output_size=out_size)
      # np.save(ref_resized_cubic_antialias_filename, ref_resized_cubic_antialias)
  
      ref_resized_linear = np.load(ref_resized_linear_filename)
      assert ref_resized_linear.shape == out_size
  
      ref_resized_linear_antialias = np.load(
          ref_resized_linear_antialias_filename
      )
      assert ref_resized_linear_antialias.shape == out_size
  
      ref_resized_cubic = np.load(ref_resized_cubic_filename)
      assert ref_resized_cubic.shape == out_size
  
      ref_resized_cubic_antialias = np.load(
          ref_resized_cubic_antialias_filename
      )
      assert ref_resized_cubic_antialias.shape == out_size
  
      antialias_ON = True
      antialias_OFF = False
      ref_data = {
          types.INTERP_LINEAR: {
              antialias_OFF: ref_resized_linear,
              antialias_ON: ref_resized_linear_antialias,
          },
          types.INTERP_CUBIC: {
              antialias_OFF: ref_resized_cubic,
              antialias_ON: ref_resized_cubic_antialias,
          },
      }
  
      @pipeline_def(batch_size=1, num_threads=3, device_id=0)
      def pipe(
          device,
          interp_type,
          antialias,
          test_data=checkerboard,
          out_size=out_size,
      ):
          data = types.Constant(test_data, device=device)
          data = fn.expand_dims(data, axes=[2])
          resized = fn.resize(
              data,
              dtype=types.FLOAT,
              min_filter=interp_type,
              mag_filter=interp_type,
              size=out_size,
              antialias=antialias,
          )
          resized = fn.squeeze(resized, axes=[2])
          return resized
  
      def impl(device, interp_type, antialias):
          assert interp_type in ref_data
          ref = ref_data[interp_type][antialias]
  
          p = pipe(device, interp_type, antialias)
          p.build()
          (out,) = p.run()
  
          out_dali = as_array(out[0])
          abs_diff = np.abs(ref - out_dali)
          max_error = np.max(abs_diff)
  
          if max_error > 1:
              suffix_str = (
                  "cubic"
                  if interp_type == types.INTERP_CUBIC
                  else "linear"
              )
              img1 = PIL.Image.fromarray(
                  np.clip(ref, 0, 255).astype(np.uint8)
              )
              img1.save(f"ref_resized_{suffix_str}.png")
  
              img2 = PIL.Image.fromarray(
                  np.clip(out_dali, 0, 255).astype(np.uint8)
              )
              img2.save(f"dali_resized_{suffix_str}.png")
  
              img2 = PIL.Image.fromarray(
                  np.clip(127 + abs_diff, 0, 255).astype(np.uint8)
              )
              img2.save(f"diff_resized_{suffix_str}.png")
  
          np.testing.assert_allclose(out_dali, ref, atol=1)
  
      for device in ["cpu", "gpu"]:
          for interp_type in [types.INTERP_LINEAR, types.INTERP_CUBIC]:
              for antialias in [antialias_OFF, antialias_ON]:
                  yield impl, device, interp_type, antialias
  
imports: import cv2
  import functools
  import math
  import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.types
  import os.path
  from nvidia.dali import Pipeline, pipeline_def
  from nvidia.dali.data_node import DataNode
  from test_utils import check_batch, get_dali_extra_path, as_array
  import PIL.Image
label_desc: Use image node_id 23 for calling a global function with example usage: test_checkerboard_dali_vs_onnx_ref() and returns: resized