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 (:obj:`ConfigDict` or dict): Specify RoI layer type and
          arguments.
      out_channels (int): Output channels of RoI layers.
      featmap_strides (List[int]): Strides of input feature maps.
      finest_scale (int): Scale threshold of mapping to level 0.
          Defaults to 56.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict. Defaults to None.
class_docstr_tok: ["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","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Specify","RoI","layer","type","and","arguments",".","out_channels","(","int",")",":","Output","channels","of","RoI","layers",".","featmap_strides","(","List","[","int","]",")",":","Strides","of","input","feature","maps",".","finest_scale","(","int",")",":","Scale","threshold","of","mapping","to","level","0",".","Defaults","to","56.","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict",".","Defaults","to","None","."]
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:
      beziers (Tensor): Input bezier control points, shape (k, 17).
      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",":","beziers","(","Tensor",")",":","Input","bezier","control","points",",","shape","(","k",",","17",")",".","num_levels","(","int",")",":","Total","level","number",".","Returns",":","Tensor",":","Level","index","(","0-based",")","of","each","RoI",",","shape","(","k",",",")"]
code: def map_roi_levels(self, beziers: Tensor, num_levels: int) -> Tensor:
      """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:
          beziers (Tensor): Input bezier control points, shape (k, 17).
          num_levels (int): Total level number.
      Returns:
          Tensor: Level index (0-based) of each RoI, shape (k, )
      """
  
      p1 = beziers[:, 1:3]
      p2 = beziers[:, 15:]
      scale = ((p1 - p2) ** 2).sum(dim=1).sqrt() * 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: mmocr/projects/ABCNet/abcnet/model/bezier_roi_extractor.py
imports: from typing import List, Tuple
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmocr.registry import MODELS
  from mmocr.utils import ConfigType, OptMultiConfig
  from .base_roi_extractor import BaseRoIExtractor
label_desc: Use image node_id 3 for calling the BezierRoIExtractor obj's underlying member method code with example usage: obj.map_roi_levels(beziers, num_levels) and returns: target_lvls