code: def libra_sample_bbox(
      matches,
      match_labels,
      matched_vals,
      gt_classes,
      batch_size_per_im,
      num_classes,
      fg_fraction,
      fg_thresh,
      bg_thresh,
      num_bins,
      use_random=True,
      is_cascade_rcnn=False,
  ):
      rois_per_image = int(batch_size_per_im)
      fg_rois_per_im = int(np.round(fg_fraction * rois_per_image))
      bg_rois_per_im = rois_per_image - fg_rois_per_im
  
      if is_cascade_rcnn:
          fg_inds = paddle.nonzero(matched_vals >= fg_thresh)
          bg_inds = paddle.nonzero(matched_vals < bg_thresh)
      else:
          matched_vals_np = matched_vals.numpy()
          match_labels_np = match_labels.numpy()
  
          # sample fg
          fg_inds = paddle.nonzero(matched_vals >= fg_thresh).flatten()
          fg_nums = int(np.minimum(fg_rois_per_im, fg_inds.shape[0]))
          if (fg_inds.shape[0] > fg_nums) and use_random:
              fg_inds = libra_sample_pos(
                  matched_vals_np,
                  match_labels_np,
                  fg_inds.numpy(),
                  fg_rois_per_im,
              )
          fg_inds = fg_inds[:fg_nums]
  
          # sample bg
          bg_inds = paddle.nonzero(matched_vals < bg_thresh).flatten()
          bg_nums = int(
              np.minimum(rois_per_image - fg_nums, bg_inds.shape[0])
          )
          if (bg_inds.shape[0] > bg_nums) and use_random:
              bg_inds = libra_sample_neg(
                  matched_vals_np,
                  match_labels_np,
                  bg_inds.numpy(),
                  bg_rois_per_im,
                  num_bins=num_bins,
                  bg_thresh=bg_thresh,
              )
          bg_inds = bg_inds[:bg_nums]
  
          sampled_inds = paddle.concat([fg_inds, bg_inds])
  
          gt_classes = paddle.gather(gt_classes, matches)
          gt_classes = paddle.where(
              match_labels == 0,
              paddle.ones_like(gt_classes) * num_classes,
              gt_classes,
          )
          gt_classes = paddle.where(
              match_labels == -1,
              paddle.ones_like(gt_classes) * -1,
              gt_classes,
          )
          sampled_gt_classes = paddle.gather(gt_classes, sampled_inds)
  
          return sampled_inds, sampled_gt_classes
  
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 13 for calling a global function with example usage: libra_sample_bbox(matches, match_labels, matched_vals, gt_classes, batch_size_per_im, num_classes, fg_fraction, fg_thresh, bg_thresh, num_bins, use_random, is_cascade_rcnn) and returns: sampled_inds,  sampled_gt_classes