class_docstr: Assign pixels at the center region of a bbox as positive.
  
  Each proposals will be assigned with `-1`, `0`, or a positive integer
  indicating the ground truth index.
  - -1: negative samples
  - semi-positive numbers: positive sample, index (0-based) of assigned gt
  
  Args:
      pos_scale (float): Threshold within which pixels are
        labelled as positive.
      neg_scale (float): Threshold above which pixels are
        labelled as positive.
      min_pos_iof (float): Minimum iof of a pixel with a gt to be
        labelled as positive. Default: 1e-2
      ignore_gt_scale (float): Threshold within which the pixels
        are ignored when the gt is labelled as shadowed. Default: 0.5
      foreground_dominate (bool): If True, the bbox will be assigned as
        positive when a gt's kernel region overlaps with another's shadowed
        (ignored) region, otherwise it is set as ignored. Default to False.
docstr: Assign only one gt index to each prior box.
  
  Gts with large gt_priority are more likely to be assigned.
  
  Args:
      is_bbox_in_gt_core (Tensor): Bool tensor indicating the bbox center
        is in the core area of a gt (e.g. 0-0.2).
        Shape: (num_prior, num_gt).
      is_bbox_in_gt_shadow (Tensor): Bool tensor indicating the bbox
        center is in the shadowed area of a gt (e.g. 0.2-0.5).
        Shape: (num_prior, num_gt).
      gt_priority (Tensor): Priorities of gts. The gt with a higher
        priority is more likely to be assigned to the bbox when the bbox
        match with multiple gts. Shape: (num_gt, ).
  
  Returns:
      tuple: Returns (assigned_gt_inds, shadowed_gt_inds).
  
          - assigned_gt_inds: The assigned gt index of each prior bbox                     (i.e. index from 1 to num_gts). Shape: (num_prior, ).
          - shadowed_gt_inds: shadowed gt indices. It is a tensor of                     shape (num_ignore, 2) with first column being the                     shadowed prior bbox indices and the second column the                     shadowed gt indices (1-based).
docstr_tok: ["Assign","only","one","gt","index","to","each","prior","box",".","Gts","with","large","gt_priority","are","more","likely","to","be","assigned",".","Args",":","is_bbox_in_gt_core","(","Tensor",")",":","Bool","tensor","indicating","the","bbox","center","is","in","the","core","area","of","a","gt","(","e.g",".","0-0.2",")",".","Shape",":","(","num_prior",",","num_gt",")",".","is_bbox_in_gt_shadow","(","Tensor",")",":","Bool","tensor","indicating","the","bbox","center","is","in","the","shadowed","area","of","a","gt","(","e.g",".","0.2-0.5",")",".","Shape",":","(","num_prior",",","num_gt",")",".","gt_priority","(","Tensor",")",":","Priorities","of","gts",".","The","gt","with","a","higher","priority","is","more","likely","to","be","assigned","to","the","bbox","when","the","bbox","match","with","multiple","gts",".","Shape",":","(","num_gt",",",")",".","Returns",":","tuple",":","Returns","(","assigned_gt_inds",",","shadowed_gt_inds",")",".","-","assigned_gt_inds",":","The","assigned","gt","index","of","each","prior","bbox","(","i.e",".","index","from","1","to","num_gts",")",".","Shape",":","(","num_prior",",",")",".","-","shadowed_gt_inds",":","shadowed","gt","indices",".","It","is","a","tensor","of","shape","(","num_ignore",",","2",")","with","first","column","being","the","shadowed","prior","bbox","indices","and","the","second","column","the","shadowed","gt","indices","(","1-based",")","."]
code: def assign_one_hot_gt_indices(
      self, is_bbox_in_gt_core, is_bbox_in_gt_shadow, gt_priority=None
  ):
      """Assign only one gt index to each prior box.
  
          Gts with large gt_priority are more likely to be assigned.
  
          Args:
              is_bbox_in_gt_core (Tensor): Bool tensor indicating the bbox center
                is in the core area of a gt (e.g. 0-0.2).
                Shape: (num_prior, num_gt).
              is_bbox_in_gt_shadow (Tensor): Bool tensor indicating the bbox
                center is in the shadowed area of a gt (e.g. 0.2-0.5).
                Shape: (num_prior, num_gt).
              gt_priority (Tensor): Priorities of gts. The gt with a higher
                priority is more likely to be assigned to the bbox when the bbox
                match with multiple gts. Shape: (num_gt, ).
  
          Returns:
              tuple: Returns (assigned_gt_inds, shadowed_gt_inds).
  
                  - assigned_gt_inds: The assigned gt index of each prior bbox \
                      (i.e. index from 1 to num_gts). Shape: (num_prior, ).
                  - shadowed_gt_inds: shadowed gt indices. It is a tensor of \
                      shape (num_ignore, 2) with first column being the \
                      shadowed prior bbox indices and the second column the \
                      shadowed gt indices (1-based).
          """
      num_bboxes, num_gts = is_bbox_in_gt_core.shape
  
      if gt_priority is None:
          gt_priority = torch.arange(
              num_gts, device=is_bbox_in_gt_core.device
          )
      assert gt_priority.size(0) == num_gts
      # The bigger gt_priority, the more preferable to be assigned
      # The assigned inds are by default 0 (background)
      assigned_gt_inds = is_bbox_in_gt_core.new_zeros(
          (num_bboxes,), dtype=torch.long
      )
      # Shadowed bboxes are assigned to be background. But the corresponding
      #   label is ignored during loss calculation, which is done through
      #   shadowed_gt_inds
      shadowed_gt_inds = torch.nonzero(
          is_bbox_in_gt_shadow, as_tuple=False
      )
      if is_bbox_in_gt_core.sum() == 0:  # No gt match
          shadowed_gt_inds[:, 1] += 1  # 1-based. For consistency issue
          return assigned_gt_inds, shadowed_gt_inds
  
      # The priority of each prior box and gt pair. If one prior box is
      #  matched bo multiple gts. Only the pair with the highest priority
      #  is saved
      pair_priority = is_bbox_in_gt_core.new_full(
          (num_bboxes, num_gts), -1, dtype=torch.long
      )
  
      # Each bbox could match with multiple gts.
      # The following codes deal with this situation
      # Matched  bboxes (to any gt). Shape: (num_pos_anchor, )
      inds_of_match = torch.any(is_bbox_in_gt_core, dim=1)
      # The matched gt index of each positive bbox. Length >= num_pos_anchor
      #   , since one bbox could match multiple gts
      matched_bbox_gt_inds = torch.nonzero(
          is_bbox_in_gt_core, as_tuple=False
      )[:, 1]
      # Assign priority to each bbox-gt pair.
      pair_priority[is_bbox_in_gt_core] = gt_priority[
          matched_bbox_gt_inds
      ]
      _, argmax_priority = pair_priority[inds_of_match].max(dim=1)
      assigned_gt_inds[inds_of_match] = argmax_priority + 1  # 1-based
      # Zero-out the assigned anchor box to filter the shadowed gt indices
      is_bbox_in_gt_core[inds_of_match, argmax_priority] = 0
      # Concat the shadowed indices due to overlapping with that out side of
      #   effective scale. shape: (total_num_ignore, 2)
      shadowed_gt_inds = torch.cat(
          (
              shadowed_gt_inds,
              torch.nonzero(is_bbox_in_gt_core, as_tuple=False),
          ),
          dim=0,
      )
      # `is_bbox_in_gt_core` should be changed back to keep arguments intact.
      is_bbox_in_gt_core[inds_of_match, argmax_priority] = 1
      # 1-based shadowed gt indices, to be consistent with `assigned_gt_inds`
      if shadowed_gt_inds.numel() > 0:
          shadowed_gt_inds[:, 1] += 1
      return assigned_gt_inds, shadowed_gt_inds
  
file_path: insightface/detection/scrfd/mmdet/core/bbox/assigners/center_region_assigner.py
imports: import torch
  from ..builder import BBOX_ASSIGNERS
  from ..iou_calculators import build_iou_calculator
  from .assign_result import AssignResult
  from .base_assigner import BaseAssigner
label_desc: Use image node_id 4 for calling the CenterRegionAssigner obj's underlying member method code with example usage: obj.assign_one_hot_gt_indices(is_bbox_in_gt_core, is_bbox_in_gt_shadow, gt_priority) and returns: assigned_gt_inds,  shadowed_gt_inds, assigned_gt_inds,  shadowed_gt_inds