class_docstr: Computes matching between predictions and ground truth.
  Args:
      center_radius (int | float, optional): Ground truth center size
          to judge whether a prior is in center. Default 2.5.
      candidate_topk (int, optional): The candidate top-k which used to
          get top-k ious to calculate dynamic-k. Default 10.
      iou_weight (int | float, optional): The scale factor for regression
          iou cost. Default 3.0.
      cls_weight (int | float, optional): The scale factor for classification
          cost. Default 1.0.
      num_classes (int): The num_classes of dataset.
      use_vfl (int): Whether to use varifocal_loss when calculating the cost matrix.
class_docstr_tok: ["Computes","matching","between","predictions","and","ground","truth",".","Args",":","center_radius","(","int","|","float",",","optional",")",":","Ground","truth","center","size","to","judge","whether","a","prior","is","in","center",".","Default","2.5.","candidate_topk","(","int",",","optional",")",":","The","candidate","top-k","which","used","to","get","top-k","ious","to","calculate","dynamic-k",".","Default","10.","iou_weight","(","int","|","float",",","optional",")",":","The","scale","factor","for","regression","iou","cost",".","Default","3.0.","cls_weight","(","int","|","float",",","optional",")",":","The","scale","factor","for","classification","cost",".","Default","1.0.","num_classes","(","int",")",":","The","num_classes","of","dataset",".","use_vfl","(","int",")",":","Whether","to","use","varifocal_loss","when","calculating","the","cost","matrix","."]
code: def dynamic_k_matching(self, cost_matrix, pairwise_ious, num_gt):
      match_matrix = np.zeros_like(cost_matrix.numpy())
      # select candidate topk ious for dynamic-k calculation
      topk_ious, _ = paddle.topk(
          pairwise_ious,
          min(self.candidate_topk, pairwise_ious.shape[0]),
          axis=0,
      )
      # calculate dynamic k for each gt
      dynamic_ks = paddle.clip(topk_ious.sum(0).cast("int"), min=1)
      for gt_idx in range(num_gt):
          _, pos_idx = paddle.topk(
              cost_matrix[:, gt_idx],
              k=dynamic_ks[gt_idx],
              largest=False,
          )
          match_matrix[:, gt_idx][pos_idx.numpy()] = 1.0
  
      del topk_ious, dynamic_ks, pos_idx
  
      # match points more than two gts
      extra_match_gts_mask = match_matrix.sum(1) > 1
      if extra_match_gts_mask.sum() > 0:
          cost_matrix = cost_matrix.numpy()
          cost_argmin = np.argmin(
              cost_matrix[extra_match_gts_mask, :], axis=1
          )
          match_matrix[extra_match_gts_mask, :] *= 0.0
          match_matrix[extra_match_gts_mask, cost_argmin] = 1.0
      # get foreground mask
      match_fg_mask_inmatrix = match_matrix.sum(1) > 0
      match_gt_inds_to_fg = match_matrix[
          match_fg_mask_inmatrix, :
      ].argmax(1)
  
      return match_gt_inds_to_fg, match_fg_mask_inmatrix
  
file_path: PaddleDetection/ppdet/modeling/assigners/simota_assigner.py
imports: import paddle
  import numpy
  import paddle.nn.functional
  from ppdet.modeling.losses.varifocal_loss import varifocal_loss
  from ppdet.modeling.bbox_utils import batch_bbox_overlaps
  from ppdet.core.workspace import register
label_desc: Use image node_id 3 for calling the SimOTAAssigner obj's underlying member method code with example usage: obj.dynamic_k_matching(cost_matrix, pairwise_ious, num_gt) and returns: match_gt_inds_to_fg,  match_fg_mask_inmatrix