code: def generate_rois(roi_counts, im_dims):
      assert len(roi_counts) == len(im_dims)
      all_rois = []
      for i, num_rois in enumerate(roi_counts):
          if num_rois == 0:
              continue
          # [batch_idx, x1, y1, x2, y2]
          rois = np.random.uniform(
              0, im_dims[i], size=(roi_counts[i], 5)
          ).astype(np.float32)
          rois[:, 0] = i  # batch_idx
          # Swap (x1, x2) if x1 > x2
          rois[:, 1], rois[:, 3] = (
              np.minimum(rois[:, 1], rois[:, 3]),
              np.maximum(rois[:, 1], rois[:, 3]),
          )
          # Swap (y1, y2) if y1 > y2
          rois[:, 2], rois[:, 4] = (
              np.minimum(rois[:, 2], rois[:, 4]),
              np.maximum(rois[:, 2], rois[:, 4]),
          )
          all_rois.append(rois)
      if len(all_rois) > 0:
          return np.vstack(all_rois)
      return np.empty((0, 5)).astype(np.float32)
  
imports: import struct
  import unittest
  import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  import numpy
  import torch
  from caffe2.python import core, workspace
  from hypothesis import given, settings
  from scipy.stats import norm
  from ._utils import assert_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: generate_rois(roi_counts, im_dims) and returns: np, np