code: def test_roipooling_fprop_random(backend_default, fargs):
      (
          rois_per_image,
          img_fm_c,
          img_fm_h,
          img_fm_w,
          roi_size,
          bsz,
      ) = fargs
  
      # generate a random feature map and some random ROIs
      feature_maps = np.random.random(
          (img_fm_c, img_fm_h, img_fm_w, bsz)
      ).reshape(-1, bsz)
      rois_per_batch = rois_per_image * bsz
  
      rois_idx = np.vstack(
          [i * np.ones((rois_per_image, 1)) for i in range(bsz)]
      )
      rois = np.random.random((rois_per_batch, 4)) * min(
          img_fm_h, img_fm_w
      )
  
      rois = np.zeros((rois_per_batch, 4))
      rois[:, 0] = (
          np.random.random((rois_per_batch,)) * 10 / spatial_scale
      )
      rois[:, 1] = (
          np.random.random((rois_per_batch,)) * 25 / spatial_scale
      )
      rois[:, 2] = (
          np.random.random((rois_per_batch,)) * 27 + (img_fm_w - 27)
      ) / spatial_scale
      rois[:, 3] = (
          np.random.random((rois_per_batch,)) * 12 + (img_fm_h - 12)
      ) / spatial_scale
  
      rois = np.hstack((rois_idx, rois))
  
      # run the numpy roi fprop (function inside this test script)
      outputs_np = fprop_roipooling_ref(
          feature_maps,
          rois,
          img_fm_c,
          img_fm_h,
          img_fm_w,
          bsz,
          rois_per_image,
          roi_size,
          roi_size,
      )
  
      # call backend roipooling kernel
      NervanaObject.be.bsz = bsz
      be = NervanaObject.be
      input_dev = be.array(feature_maps)
      rois_dev = be.array(rois)
      output_shape = (img_fm_c, roi_size, roi_size, rois_per_batch)
      outputs_dev = be.zeros(output_shape)
      # make sure the type being int
      argmax_dev = be.zeros(output_shape, np.int32)
  
      start_time = timeit()
      be.roipooling_fprop(
          input_dev,
          rois_dev,
          outputs_dev,
          argmax_dev,
          rois_per_batch,
          img_fm_c,
          img_fm_h,
          img_fm_w,
          roi_size,
          roi_size,
          spatial_scale,
      )
      neon_logger.display(
          "Nervana backend roipooling fprop (sec): {}".format(
              timeit() - start_time
          )
      )
  
      outputs_be = outputs_dev.get().reshape(-1, rois_per_batch)
      assert allclose_with_out(
          outputs_np, outputs_be, atol=1e-6, rtol=0
      )
  
file_path: neon/tests/test_roipooling_layer.py
imports: from builtins import round
  import itertools
  import numpy
  from timeit import default_timer
  from neon import NervanaObject, logger
  from neon.backends import gen_backend
  from utils import allclose_with_out
label_desc: Use image node_id 5 for calling a global function with example usage: test_roipooling_fprop_random(backend_default, fargs) without return types