class_docstr: Extract RoI features from a single level feature map.
  
  If there are multiple input feature levels, each RoI is mapped to a level
  according to its scale. The mapping rule is proposed in
  `FPN <https://arxiv.org/abs/1612.03144>`_.
  
  Args:
      roi_layer (dict): Specify RoI layer type and arguments.
      out_channels (int): Output channels of RoI layers.
      featmap_strides (int): Strides of input feature maps.
      finest_scale (int): Scale threshold of mapping to level 0. Default: 56.
docstr: Map rois to corresponding feature levels by scales.
  
  - scale < finest_scale * 2: level 0
  - finest_scale * 2 <= scale < finest_scale * 4: level 1
  - finest_scale * 4 <= scale < finest_scale * 8: level 2
  - scale >= finest_scale * 8: level 3
  
  Args:
      rois (Tensor): Input RoIs, shape (k, 5).
      num_levels (int): Total level number.
  
  Returns:
      Tensor: Level index (0-based) of each RoI, shape (k, )
docstr_tok: ["Map","rois","to","corresponding","feature","levels","by","scales",".","-","scale","<","finest_scale","*","2",":","level","0","-","finest_scale","*","2","<","=","scale","<","finest_scale","*","4",":","level","1","-","finest_scale","*","4","<","=","scale","<","finest_scale","*","8",":","level","2","-","scale",">","=","finest_scale","*","8",":","level","3","Args",":","rois","(","Tensor",")",":","Input","RoIs",",","shape","(","k",",","5",")",".","num_levels","(","int",")",":","Total","level","number",".","Returns",":","Tensor",":","Level","index","(","0-based",")","of","each","RoI",",","shape","(","k",",",")"]
code: def map_roi_levels(self, rois, num_levels):
      """Map rois to corresponding feature levels by scales.
  
      - scale < finest_scale * 2: level 0
      - finest_scale * 2 <= scale < finest_scale * 4: level 1
      - finest_scale * 4 <= scale < finest_scale * 8: level 2
      - scale >= finest_scale * 8: level 3
  
      Args:
          rois (Tensor): Input RoIs, shape (k, 5).
          num_levels (int): Total level number.
  
      Returns:
          Tensor: Level index (0-based) of each RoI, shape (k, )
      """
      scale = torch.sqrt(
          (rois[:, 3] - rois[:, 1]) * (rois[:, 4] - rois[:, 2])
      )
      target_lvls = torch.floor(
          torch.log2(scale / self.finest_scale + 1e-6)
      )
      target_lvls = target_lvls.clamp(min=0, max=num_levels - 1).long()
      return target_lvls
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/roi_extractors/single_level_roi_extractor.py
imports: import torch
  from mmcv.runner import force_fp32
  from mmdet.models.builder import ROI_EXTRACTORS
  from .base_roi_extractor import BaseRoIExtractor
label_desc: Use image node_id 2 for calling the SingleRoIExtractor obj's underlying member method code with example usage: obj.map_roi_levels(rois, num_levels) and returns: target_lvls