code: def test_crop_and_resize():
      def verify_crop_and_resize(
          image_shape,
          np_boxes,
          np_box_indices,
          np_crop_size,
          layout="NHWC",
          method="bilinear",
          extrapolation_value=0.0,
      ):
          images = te.placeholder(
              image_shape, name="images", dtype="float32"
          )
          np_images = np.random.uniform(size=image_shape).astype(
              "float32"
          )
          boxes = te.placeholder(
              np_boxes.shape, name="boxes", dtype="float32"
          )
          box_ind = te.placeholder(
              np_box_indices.shape, name="box_ind", dtype="int32"
          )
  
          batch = len(np_box_indices)
          target_height, target_width = np_crop_size[0], np_crop_size[1]
          if layout == "NHWC":
              channel = image_shape[3]
              out_shape = (batch, target_height, target_width, channel)
          elif layout == "NCHW":
              channel = image_shape[1]
              out_shape = (batch, channel, target_height, target_width)
          else:
              raise NotImplementedError(
                  "Layout {} is not supported.".format(layout)
              )
  
          out = topi.image.crop_and_resize(
              images,
              boxes,
              box_ind,
              np_crop_size,
              layout=layout,
              method=method,
              extrapolation_value=extrapolation_value,
          )
  
          baseline_np = tvm.topi.testing.crop_and_resize_python(
              np_images,
              np_boxes,
              np_box_indices,
              np_crop_size,
              layout,
              method,
              extrapolation_value,
          )
  
          def check_target(target, dev):
              print("Running on target: %s" % target)
              with tvm.target.Target(target):
                  s = tvm.topi.testing.get_injective_schedule(target)(
                      out
                  )
              tvm_images = tvm.nd.array(np_images, dev)
              tvm_boxes = tvm.nd.array(np_boxes, dev)
              tvm_indices = tvm.nd.array(np_box_indices, dev)
              tvm_out = tvm.nd.array(
                  np.zeros(out_shape, dtype="float32"), dev
              )
              f = tvm.build(
                  s,
                  [images, boxes, box_ind, out],
                  target,
                  name="crop_and_resize",
              )
              f(tvm_images, tvm_boxes, tvm_indices, tvm_out)
  
              tvm.testing.assert_allclose(
                  tvm_out.numpy(), baseline_np, rtol=1e-3, atol=1e-3
              )
  
          for target, dev in tvm.testing.enabled_targets():
              check_target(target, dev)
  
      boxes_1 = np.array([[0.2, 0.3, 0.7, 0.9]], dtype="float32")
      boxes_2 = np.array(
          [[0.2, 0.3, 0.7, 0.9], [0, 0.1, 0.8, 1]], dtype="float32"
      )
      indices_1 = np.array([0], dtype="int32")
      indices_2 = np.array([1, 0], dtype="int32")
      size_1 = (7, 11)
      size_2 = (90, 60)
  
      verify_crop_and_resize(
          (1, 255, 255, 3), boxes_1, indices_1, size_1, layout="NHWC"
      )
      verify_crop_and_resize(
          (10, 224, 224, 5),
          boxes_2,
          indices_2,
          size_2,
          extrapolation_value=0.3,
          layout="NHWC",
      )
      verify_crop_and_resize(
          (1, 100, 100, 3),
          boxes_1,
          indices_1,
          size_1,
          method="nearest_neighbor",
      )
      verify_crop_and_resize(
          (1, 3, 224, 224), boxes_1, indices_1, size_1, layout="NCHW"
      )
  
file_path: tvm/tests/python/topi/test_topi_image.py
imports: import numpy
  import tvm
  from tvm import te
  from tvm import topi
  import tvm.testing
  import tvm.topi.testing
  from tvm.contrib.pickle_memoize import memoize
label_desc: Use image node_id 5 for calling a global function with example usage: test_crop_and_resize() without return types