class_docstr: Importance-based Sample Reweighting (ISR_N), described in `Prime Sample
  Attention in Object Detection <https://arxiv.org/abs/1904.04821>`_.
  
  Score hierarchical local rank (HLR) differentiates with RandomSampler in
  negative part. It firstly computes Score-HLR in a two-step way,
  then linearly maps score hlr to the loss weights.
  
  Args:
      num (int): Total number of sampled RoIs.
      pos_fraction (float): Fraction of positive samples.
      context (:class:`BaseRoIHead`): RoI head that the sampler belongs to.
      neg_pos_ub (int): Upper bound of the ratio of num negative to num
          positive, -1 means no upper bound.
      add_gt_as_proposals (bool): Whether to add ground truth as proposals.
      k (float): Power of the non-linear mapping.
      bias (float): Shift of the non-linear mapping.
      score_thr (float): Minimum score that a negative sample is to be
          considered as valid bbox.
class_docstr_tok: ["Importance-based","Sample","Reweighting","(","ISR_N",")",",","described","in","`","Prime","Sample","Attention","in","Object","Detection","<","https",":","\/\/arxiv.org\/abs\/1904.04821",">","`","_",".","Score","hierarchical","local","rank","(","HLR",")","differentiates","with","RandomSampler","in","negative","part",".","It","firstly","computes","Score-HLR","in","a","two-step","way",",","then","linearly","maps","score","hlr","to","the","loss","weights",".","Args",":","num","(","int",")",":","Total","number","of","sampled","RoIs",".","pos_fraction","(","float",")",":","Fraction","of","positive","samples",".","context","(",":","class",":","`","BaseRoIHead","`",")",":","RoI","head","that","the","sampler","belongs","to",".","neg_pos_ub","(","int",")",":","Upper","bound","of","the","ratio","of","num","negative","to","num","positive",",","-1","means","no","upper","bound",".","add_gt_as_proposals","(","bool",")",":","Whether","to","add","ground","truth","as","proposals",".","k","(","float",")",":","Power","of","the","non-linear","mapping",".","bias","(","float",")",":","Shift","of","the","non-linear","mapping",".","score_thr","(","float",")",":","Minimum","score","that","a","negative","sample","is","to","be","considered","as","valid","bbox","."]
code: def __init__(
      self,
      num,
      pos_fraction,
      context,
      neg_pos_ub=-1,
      add_gt_as_proposals=True,
      k=0.5,
      bias=0,
      score_thr=0.05,
      iou_thr=0.5,
      **kwargs,
  ):
      super().__init__(
          num, pos_fraction, neg_pos_ub, add_gt_as_proposals
      )
      self.k = k
      self.bias = bias
      self.score_thr = score_thr
      self.iou_thr = iou_thr
      self.context = context
      # context of cascade detectors is a list, so distinguish them here.
      if not hasattr(context, "num_stages"):
          self.bbox_roi_extractor = context.bbox_roi_extractor
          self.bbox_head = context.bbox_head
          self.with_shared_head = context.with_shared_head
          if self.with_shared_head:
              self.shared_head = context.shared_head
      else:
          self.bbox_roi_extractor = context.bbox_roi_extractor[
              context.current_stage
          ]
          self.bbox_head = context.bbox_head[context.current_stage]
  
file_path: insightface/detection/scrfd/mmdet/core/bbox/samplers/score_hlr_sampler.py
imports: import torch
  from mmcv.ops import nms_match
  from ..builder import BBOX_SAMPLERS
  from ..transforms import bbox2roi
  from .base_sampler import BaseSampler
  from .sampling_result import SamplingResult
label_desc: Use image node_id 1 to create a new ScoreHLRSampler object from inherited base classes: BaseSampler with example: obj = ScoreHLRSampler(num, pos_fraction, context, neg_pos_ub, add_gt_as_proposals, k, bias, score_thr, iou_thr)