code: def libra_generate_proposal_target(
      rpn_rois,
      gt_classes,
      gt_boxes,
      batch_size_per_im,
      fg_fraction,
      fg_thresh,
      bg_thresh,
      num_classes,
      use_random=True,
      is_cascade_rcnn=False,
      max_overlaps=None,
      num_bins=3,
  ):
      rois_with_gt = []
      tgt_labels = []
      tgt_bboxes = []
      sampled_max_overlaps = []
      tgt_gt_inds = []
      new_rois_num = []
  
      for i, rpn_roi in enumerate(rpn_rois):
          max_overlap = max_overlaps[i] if is_cascade_rcnn else None
          gt_bbox = gt_boxes[i]
          gt_class = paddle.squeeze(gt_classes[i], axis=-1)
          if is_cascade_rcnn:
              rpn_roi = filter_roi(rpn_roi, max_overlap)
          bbox = paddle.concat([rpn_roi, gt_bbox])
  
          # Step1: label bbox
          matches, match_labels, matched_vals = libra_label_box(
              bbox, gt_bbox, gt_class, fg_thresh, bg_thresh, num_classes
          )
  
          # Step2: sample bbox
          sampled_inds, sampled_gt_classes = libra_sample_bbox(
              matches,
              match_labels,
              matched_vals,
              gt_class,
              batch_size_per_im,
              num_classes,
              fg_fraction,
              fg_thresh,
              bg_thresh,
              num_bins,
              use_random,
              is_cascade_rcnn,
          )
  
          # Step3: make output
          rois_per_image = paddle.gather(bbox, sampled_inds)
          sampled_gt_ind = paddle.gather(matches, sampled_inds)
          sampled_bbox = paddle.gather(gt_bbox, sampled_gt_ind)
          sampled_overlap = paddle.gather(matched_vals, sampled_inds)
  
          rois_per_image.stop_gradient = True
          sampled_gt_ind.stop_gradient = True
          sampled_bbox.stop_gradient = True
          sampled_overlap.stop_gradient = True
  
          tgt_labels.append(sampled_gt_classes)
          tgt_bboxes.append(sampled_bbox)
          rois_with_gt.append(rois_per_image)
          sampled_max_overlaps.append(sampled_overlap)
          tgt_gt_inds.append(sampled_gt_ind)
          new_rois_num.append(paddle.shape(sampled_inds)[0:1])
      new_rois_num = paddle.concat(new_rois_num)
      # rois_with_gt, tgt_labels, tgt_bboxes, tgt_gt_inds, new_rois_num
      return (
          rois_with_gt,
          tgt_labels,
          tgt_bboxes,
          tgt_gt_inds,
          new_rois_num,
      )
  
file_path: PaddleDetection/ppdet/modeling/proposal_generator/target.py
imports: import numpy
  import paddle
  from ..bbox_utils import bbox2delta, bbox_overlaps
label_desc: Use image node_id 14 for calling a global function with example usage: libra_generate_proposal_target(rpn_rois, gt_classes, gt_boxes, batch_size_per_im, fg_fraction, fg_thresh, bg_thresh, num_classes, use_random, is_cascade_rcnn, max_overlaps, num_bins) and returns: rois_with_gt,  tgt_labels,  tgt_bboxes,  tgt_gt_inds,  new_rois_num