code: def test_roi_pool(executor_kind):
      def verify_roi_pool(
          data_shape, rois_shape, pooled_size, spatial_scale
      ):
          data = relay.var(
              "data", relay.ty.TensorType(data_shape, "float32")
          )
          rois = relay.var(
              "rois", relay.ty.TensorType(rois_shape, "float32")
          )
          z = relay.vision.roi_pool(
              data,
              rois,
              pooled_size=(pooled_size, pooled_size),
              spatial_scale=spatial_scale,
              layout="NCHW",
          )
          zz = run_infer_type(z)
          batch, channel, in_size, _ = data_shape
          num_roi = rois_shape[0]
          assert zz.checked_type == relay.ty.TensorType(
              (num_roi, channel, pooled_size, pooled_size), "float32"
          )
  
          func = relay.Function([data, rois], z)
          func = run_infer_type(func)
          np_data = np.random.uniform(size=data_shape).astype("float32")
          np_rois = (
              np.random.uniform(size=rois_shape).astype("float32")
              * in_size
          )
          np_rois[:, 0] = np.random.randint(
              low=0, high=batch, size=num_roi
          ).astype("float32")
          ref_res = tvm.topi.testing.roi_pool_nchw_python(
              np_data,
              np_rois,
              pooled_size=pooled_size,
              spatial_scale=spatial_scale,
          )
          for target, dev in tvm.testing.enabled_targets():
              op_res = relay.create_executor(
                  executor_kind, device=dev, target=target
              ).evaluate(func)(np_data, np_rois)
              tvm.testing.assert_allclose(
                  op_res.numpy(), ref_res, rtol=1e-4
              )
  
      verify_roi_pool(
          (1, 4, 16, 16), (32, 5), pooled_size=7, spatial_scale=1.0
      )
      verify_roi_pool(
          (4, 4, 16, 16), (32, 5), pooled_size=7, spatial_scale=0.5
      )
  
imports: import math
  import platform
  import sys
  import numpy
  import pytest
  import tvm
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay, te
  from tvm.relay.testing import run_infer_type
label_desc: Use image node_id 9 for calling a global function with example usage: test_roi_pool(executor_kind) without return types