code: def label_box(
      anchors,
      gt_boxes,
      positive_overlap,
      negative_overlap,
      allow_low_quality,
      ignore_thresh,
      is_crowd=None,
      assign_on_cpu=False,
  ):
      if assign_on_cpu:
          device = paddle.device.get_device()
          paddle.set_device("cpu")
          iou = bbox_overlaps(gt_boxes, anchors)
          paddle.set_device(device)
  
      else:
          iou = bbox_overlaps(gt_boxes, anchors)
      n_gt = gt_boxes.shape[0]
      if n_gt == 0 or is_crowd is None:
          n_gt_crowd = 0
      else:
          n_gt_crowd = paddle.nonzero(is_crowd).shape[0]
      if iou.shape[0] == 0 or n_gt_crowd == n_gt:
          # No truth, assign everything to background
          default_matches = paddle.full(
              (iou.shape[1],), 0, dtype="int64"
          )
          default_match_labels = paddle.full(
              (iou.shape[1],), 0, dtype="int32"
          )
          return default_matches, default_match_labels
      # if ignore_thresh > 0, remove anchor if it is closed to
      # one of the crowded ground-truth
      if n_gt_crowd > 0:
          N_a = anchors.shape[0]
          ones = paddle.ones([N_a])
          mask = is_crowd * ones
  
          if ignore_thresh > 0:
              crowd_iou = iou * mask
              valid = (
                  paddle.sum(
                      (crowd_iou > ignore_thresh).cast("int32"), axis=0
                  )
                  > 0
              ).cast("float32")
              iou = iou * (1 - valid) - valid
  
          # ignore the iou between anchor and crowded ground-truth
          iou = iou * (1 - mask) - mask
  
      matched_vals, matches = paddle.topk(iou, k=1, axis=0)
      match_labels = paddle.full(matches.shape, -1, dtype="int32")
      # set ignored anchor with iou = -1
      neg_cond = paddle.logical_and(
          matched_vals > -1, matched_vals < negative_overlap
      )
      match_labels = paddle.where(
          neg_cond, paddle.zeros_like(match_labels), match_labels
      )
      match_labels = paddle.where(
          matched_vals >= positive_overlap,
          paddle.ones_like(match_labels),
          match_labels,
      )
      if allow_low_quality:
          highest_quality_foreach_gt = iou.max(axis=1, keepdim=True)
          pred_inds_with_highest_quality = (
              paddle.logical_and(
                  iou > 0, iou == highest_quality_foreach_gt
              )
              .cast("int32")
              .sum(0, keepdim=True)
          )
          match_labels = paddle.where(
              pred_inds_with_highest_quality > 0,
              paddle.ones_like(match_labels),
              match_labels,
          )
  
      matches = matches.flatten()
      match_labels = match_labels.flatten()
  
      return matches, match_labels
  
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 2 for calling a global function with example usage: label_box(anchors, gt_boxes, positive_overlap, negative_overlap, allow_low_quality, ignore_thresh, is_crowd, assign_on_cpu) and returns: matches,  match_labels, default_matches,  default_match_labels