class_docstr: Computes matching between predictions and ground truth with dynamic soft
  label assignment.
  
  Args:
      soft_center_radius (float): Radius of the soft center prior.
          Defaults to 3.0.
      topk (int): Select top-k predictions to calculate dynamic k
          best matches for each gt. Defaults to 13.
      iou_weight (float): The scale factor of iou cost. Defaults to 3.0.
      iou_calculator (ConfigType): Config of overlaps Calculator.
          Defaults to dict(type='BboxOverlaps2D').
docstr: Use IoU and matching cost to calculate the dynamic top-k positive
  targets. Same as SimOTA.
  
  Args:
      cost (Tensor): Cost matrix.
      pairwise_ious (Tensor): Pairwise iou matrix.
      num_gt (int): Number of gt.
      valid_mask (Tensor): Mask for valid bboxes.
  
  Returns:
      tuple: matched ious and gt indexes.
docstr_tok: ["Use","IoU","and","matching","cost","to","calculate","the","dynamic","top-k","positive","targets",".","Same","as","SimOTA",".","Args",":","cost","(","Tensor",")",":","Cost","matrix",".","pairwise_ious","(","Tensor",")",":","Pairwise","iou","matrix",".","num_gt","(","int",")",":","Number","of","gt",".","valid_mask","(","Tensor",")",":","Mask","for","valid","bboxes",".","Returns",":","tuple",":","matched","ious","and","gt","indexes","."]
code: def dynamic_k_matching(
      self,
      cost: Tensor,
      pairwise_ious: Tensor,
      num_gt: int,
      valid_mask: Tensor,
  ) -> Tuple[Tensor, Tensor]:
      """Use IoU and matching cost to calculate the dynamic top-k positive
      targets. Same as SimOTA.
  
      Args:
          cost (Tensor): Cost matrix.
          pairwise_ious (Tensor): Pairwise iou matrix.
          num_gt (int): Number of gt.
          valid_mask (Tensor): Mask for valid bboxes.
  
      Returns:
          tuple: matched ious and gt indexes.
      """
      matching_matrix = torch.zeros_like(cost, dtype=torch.uint8)
      # select candidate topk ious for dynamic-k calculation
      candidate_topk = min(self.topk, pairwise_ious.size(0))
      topk_ious, _ = torch.topk(pairwise_ious, candidate_topk, dim=0)
      # calculate dynamic k for each gt
      dynamic_ks = torch.clamp(topk_ious.sum(0).int(), min=1)
      for gt_idx in range(num_gt):
          _, pos_idx = torch.topk(
              cost[:, gt_idx], k=dynamic_ks[gt_idx], largest=False
          )
          matching_matrix[:, gt_idx][pos_idx] = 1
  
      del topk_ious, dynamic_ks, pos_idx
  
      prior_match_gt_mask = matching_matrix.sum(1) > 1
      if prior_match_gt_mask.sum() > 0:
          cost_min, cost_argmin = torch.min(
              cost[prior_match_gt_mask, :], dim=1
          )
          matching_matrix[prior_match_gt_mask, :] *= 0
          matching_matrix[prior_match_gt_mask, cost_argmin] = 1
      # get foreground mask inside box and center prior
      fg_mask_inboxes = matching_matrix.sum(1) > 0
      valid_mask[valid_mask.clone()] = fg_mask_inboxes
  
      matched_gt_inds = matching_matrix[fg_mask_inboxes, :].argmax(1)
      matched_pred_ious = (matching_matrix * pairwise_ious).sum(1)[
          fg_mask_inboxes
      ]
      return matched_pred_ious, matched_gt_inds
  
file_path: mmdetection/mmdet/models/task_modules/assigners/dynamic_soft_label_assigner.py
imports: from typing import Optional, Tuple
  import torch
  import torch.nn.functional
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import TASK_UTILS
  from mmdet.structures.bbox import BaseBoxes
  from mmdet.utils import ConfigType
  from .assign_result import AssignResult
  from .base_assigner import BaseAssigner
label_desc: Use image node_id 3 for calling the DynamicSoftLabelAssigner obj's underlying member method code with example usage: obj.dynamic_k_matching(cost, pairwise_ious, num_gt, valid_mask) and returns: matched_pred_ious,  matched_gt_inds