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","."]
docstr: Randomly sample some positive samples.
docstr_tok: ["Randomly","sample","some","positive","samples","."]
code: def _sample_pos(self, assign_result, num_expected, **kwargs):
      """Randomly sample some positive samples."""
      pos_inds = torch.nonzero(assign_result.gt_inds > 0).flatten()
      if pos_inds.numel() <= num_expected:
          return pos_inds
      else:
          return self.random_choice(pos_inds, num_expected)
  
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 3 for calling the ScoreHLRSampler obj's underlying member method code with example usage: obj._sample_pos(assign_result, num_expected) and returns: pos_inds, self