code: def sample_bbox(
      matches,
      match_labels,
      gt_classes,
      batch_size_per_im,
      fg_fraction,
      num_classes,
      use_random=True,
      is_cascade=False,
  ):
      n_gt = gt_classes.shape[0]
      if n_gt == 0:
          # No truth, assign everything to background
          gt_classes = (
              paddle.ones(matches.shape, dtype="int32") * num_classes
          )
          # return matches, match_labels + num_classes
      else:
          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,
          )
      if is_cascade:
          index = paddle.arange(matches.shape[0])
          return index, gt_classes
      rois_per_image = int(batch_size_per_im)
  
      fg_inds, bg_inds = subsample_labels(
          gt_classes,
          rois_per_image,
          fg_fraction,
          num_classes,
          use_random,
      )
      if fg_inds.shape[0] == 0 and bg_inds.shape[0] == 0:
          # fake output labeled with -1 when all boxes are neither
          # foreground nor background
          sampled_inds = paddle.zeros([1], dtype="int32")
      else:
          sampled_inds = paddle.concat([fg_inds, bg_inds])
      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 5 for calling a global function with example usage: sample_bbox(matches, match_labels, gt_classes, batch_size_per_im, fg_fraction, num_classes, use_random, is_cascade) and returns: sampled_inds,  sampled_gt_classes, index,  gt_classes