code: def test_nearest_onnx(
      self,
      height_scale,
      width_scale,
      height,
      width,
      num_channels,
      batch_size,
      seed,
      order,
      gc,
      dc,
  ):
      assume(order == "NCHW" or gc.device_type == caffe2_pb2.CPU)
      # NHWC currently only supported for CPU. Ignore other devices.
      if order == "NHWC":
          dc = [d for d in dc if d.device_type == caffe2_pb2.CPU]
  
      np.random.seed(seed)
      op = core.CreateOperator(
          "ResizeNearest",
          ["X", "scales"],
          ["Y"],
          order=order,
      )
  
      X = np.random.rand(
          batch_size, num_channels, height, width
      ).astype(np.float32)
      if order == "NHWC":
          X = X.transpose([0, 2, 3, 1])
  
      scales = np.array([height_scale, width_scale]).astype(np.float32)
  
      def ref(X, scales):
          output_height = np.int32(height * scales[0])
          output_width = np.int32(width * scales[1])
  
          output_h_idxs, output_w_idxs = np.meshgrid(
              np.arange(output_height),
              np.arange(output_width),
              indexing="ij",
          )
  
          input_h_idxs = np.minimum(
              output_h_idxs / scales[0], height - 1
          ).astype(np.int32)
          input_w_idxs = np.minimum(
              output_w_idxs / scales[1], width - 1
          ).astype(np.int32)
  
          if order == "NCHW":
              Y = X[:, :, input_h_idxs, input_w_idxs]
          else:
              Y = X[:, input_h_idxs, input_w_idxs, :]
  
          return (Y,)
  
      self.assertReferenceChecks(gc, op, [X, scales], ref)
      self.assertDeviceChecks(dc, op, [X, scales], [0])
      self.assertGradientChecks(
          gc, op, [X, scales], 0, [0], stepsize=0.1, threshold=1e-2
      )
  
file_path: pytorch/caffe2/python/operator_test/resize_op_test.py
imports: import numpy
  import hypothesis.strategies
  import unittest
  import caffe2.python.hypothesis_test_util
  from caffe2.python import core
  from caffe2.proto import caffe2_pb2
  from hypothesis import assume, given, settings
label_desc: Use image node_id 3 for calling the TestResize obj's underlying member method code with example usage: obj.test_nearest_onnx(height_scale, width_scale, height, width, num_channels, batch_size, seed, order, gc, dc) and returns: Y