code: def _get_rois_from_boxes(self, boxes, im_shape):
      rois = []
      for i, boxes_per_image in enumerate(boxes):
          clip_box = clip_bbox(boxes_per_image, im_shape[i])
          if self.training:
              keep = nonempty_bbox(clip_box)
              if keep.shape[0] == 0:
                  keep = paddle.zeros([1], dtype="int32")
              clip_box = paddle.gather(clip_box, keep)
          rois.append(clip_box)
      rois_num = paddle.concat([paddle.shape(r)[0:1] for r in rois])
      return rois, rois_num
  
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal
  from ppdet.core.workspace import register
  from .bbox_head import BBoxHead, TwoFCHead, XConvNormHead
  from .roi_extractor import RoIAlign
  from ..shape_spec import ShapeSpec
  from ..bbox_utils import delta2bbox, clip_bbox, nonempty_bbox
  from ..cls_utils import _get_class_default_kwargs
label_desc: Use image node_id 3 for calling the CascadeHead obj's underlying member method code with example usage: obj._get_rois_from_boxes(boxes, im_shape) and returns: rois,  rois_num