code: def test_roipooling_bprop_random(backend_default, fargs):
      (
          rois_per_image,
          img_fm_c,
          img_fm_h,
          img_fm_w,
          roi_size,
          bsz,
      ) = fargs
      rois_per_batch = rois_per_image * bsz
      # generate a random feature map and some random ROIs
      feature_map_size = img_fm_c * img_fm_h * img_fm_w * bsz
  
      feature_maps = np.array(list(range(feature_map_size))).reshape(
          (img_fm_c, img_fm_h, img_fm_w, bsz)
      )
      input_errors = np.zeros(
          (img_fm_c, roi_size, roi_size, rois_per_batch)
      )
  
      range_num = roi_size * roi_size
      input_errors[0, :, :, rois_per_batch - 1] = np.array(
          list(range(range_num))
      ).reshape(input_errors[0, :, :, rois_per_batch - 1].shape)
  
      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
      )
  
      # use full frame as ROI
      rois = np.zeros((rois_per_batch, 4))
      rois[:, 0] = np.ones((rois_per_batch,))
      rois[:, 1] = np.ones((rois_per_batch,))
      rois[:, 2] = np.ones((rois_per_batch,)) * img_fm_w / spatial_scale
      rois[:, 3] = np.ones((rois_per_batch,)) * img_fm_w / spatial_scale
  
      rois = np.hstack((rois_idx, rois))
  
      # run the numpy roi fprop (function inside this test script)
      outputs_np = bprop_roipooling_ref(
          feature_maps,
          rois,
          input_errors,
          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, dtype=np.float32)
      # make sure the type being int
      argmax_dev = be.zeros(output_shape, dtype=np.int32)
      input_error_dev = be.array(input_errors)
      output_error_dev = be.zeros(feature_maps.shape)
  
      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,
      )
      start_time = timeit()
      be.roipooling_bprop(
          input_error_dev,
          rois_dev,
          output_error_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 bprop (sec): {}".format(
              timeit() - start_time
          )
      )
  
      assert (
          output_error_dev.get()
          .reshape(img_fm_c, img_fm_h, img_fm_w, bsz)[:, :, :, 0]
          .sum()
          == 0
      )
      assert (
          output_error_dev.get()
          .reshape(img_fm_c, img_fm_h, img_fm_w, bsz)[:, :, :, -1]
          .sum()
          != 0
      )
  
      assert output_error_dev.get().sum() == input_errors.sum()
  
      outputs_be = output_error_dev.get()
      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 7 for calling a global function with example usage: test_roipooling_bprop_random(backend_default, fargs) without return types