code: def get_bboxes(
      outputs,
      proposals,
      num_proposals,
      num_classes,
      im_shape,
      im_scale,
      max_per_image=100,
      thresh=0.001,
      nms_thresh=0.4,
  ):
      """
      Returns bounding boxes for detected objects, organized by class.
  
      Transforms the proposals from the region proposal network to bounding box predictions
      using the bounding box regressions from the classification network:
      (1) Applying bounding box regressions to the region proposals.
      (2) For each class, take proposed boxes where the corresponding objectness score is greater
          then THRESH.
      (3) Apply non-maximum suppression across classes using NMS_THRESH
      (4) Limit the maximum number of detections over all classes to MAX_PER_IMAGE
  
      Arguments:
          outputs (list of tensors): Faster-RCNN model outputs
          proposals (Tensor): Proposed boxes from the model's proposalLayer
          num_proposals (int): Number of proposals
          num_classes (int): Number of classes
          im_shape (tuple): Shape of image
          im_scale (float): Scaling factor of image
          max_per_image (int): Maximum number of allowed detections per image. Default is 100.
                               None indicates no enforced maximum.
          thresh (float): Threshold for objectness score. Default is 0.001.
          nms_thresh (float): Threshold for non-maximum suppression. Default is 0.4.
  
      Returns:
          detections (array): Array of bounding box detections in a N x 6 array. Each bounding box
                              has the following attributes:[xmin, ymin, xmas, ymax, score, class]
  
      """
  
      proposals = proposals.get()[
          :num_proposals, :
      ]  # remove padded proposals
      boxes = (
          proposals[:, 1:5] / im_scale
      )  # scale back to real image space
  
      # obtain bounding box corrections from the frcn layers
      scores = outputs[2][0].get()[:, :num_proposals].T
      bbox_deltas = outputs[2][1].get()[:, :num_proposals].T
  
      # apply bounding box corrections to the region proposals
      pred_boxes = util.bbox_transform_inv(boxes, bbox_deltas)
      pred_boxes = util.clip_boxes(pred_boxes, im_shape)
  
      detections = []
      # Skip the background class, start processing from class 1
      for j in range(1, num_classes):
          inds = np.where(scores[:, j] > thresh)[0]
  
          # obtain class-specific boxes and scores
          cls_labels = j * np.ones((len(inds), 1))
          cls_scores = scores[inds, j]
          cls_boxes = pred_boxes[inds, j * 4 : (j + 1) * 4]
          cls_dets = np.hstack(
              (cls_boxes, cls_scores[:, np.newaxis], cls_labels)
          ).astype(np.float32, copy=False)
  
          # apply non-max suppression
          keep = util.nms(cls_dets, nms_thresh)
          cls_dets = cls_dets[keep, :]
  
          # store results
          if cls_dets.size != 0:
              detections.append(cls_dets)  # detections[j] = cls_dets
  
      # guard against no detections
      if len(detections) != 0:
          detections = np.vstack(detections)
  
      # Limit to max_per_image detections *over all classes*
      if max_per_image is not None:
          if len(detections) > max_per_image:
              # compute threshold needed to keep the top max_per_image
              image_thresh = np.sort(detections[:, -2])[-max_per_image]
  
              keep = np.where(detections[:, -2] >= image_thresh)[0]
              detections = detections[keep, :]
  
      # For each bounding box:
      # [xmin, ymin, xmax, ymax, score, class]
  
      return detections
  
file_path: neon/examples/faster-rcnn/faster_rcnn.py
imports: from neon.initializers import Constant, Gaussian
  from neon.transforms import Rectlin, Identity, Softmax, PixelwiseSoftmax
  from neon.layers import Conv, Affine, BranchNode, Tree, Dropout, RoiPooling
  from neon.models import Model
  from neon.data.dataloader_transformers import BGRMeanSubtract, TypeCast
  from neon.data.aeon_shim import AeonDataLoader
  from proposal_layer import ProposalLayer
  from objectlocalization import ObjectLocalization
  import util
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: get_bboxes(outputs, proposals, num_proposals, num_classes, im_shape, im_scale, max_per_image, thresh, nms_thresh) and returns: detections