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: Extractor ROI feats.
  
  Args:
      feats (Tuple[Tensor]): Multi-scale features.
      proposal_instances(List[InstanceData]): Proposal instances.
  
  Returns:
      Tensor: RoI feature.
docstr_tok: ["Extractor","ROI","feats",".","Args",":","feats","(","Tuple","[","Tensor","]",")",":","Multi-scale","features",".","proposal_instances","(","List","[","InstanceData","]",")",":","Proposal","instances",".","Returns",":","Tensor",":","RoI","feature","."]
code: def forward(
      self, feats: Tuple[Tensor], proposal_instances: List[InstanceData]
  ) -> Tensor:
      """Extractor ROI feats.
  
      Args:
          feats (Tuple[Tensor]): Multi-scale features.
          proposal_instances(List[InstanceData]): Proposal instances.
  
      Returns:
          Tensor: RoI feature.
      """
      beziers = [p_i.beziers for p_i in proposal_instances]
      rois = self.to_roi(beziers)
      # convert fp32 to fp16 when amp is on
      rois = rois.type_as(feats[0])
      out_size = self.roi_layers[0].output_size
      feats = feats[:3]
      num_levels = len(feats)
      roi_feats = feats[0].new_zeros(
          rois.size(0), self.out_channels, *out_size
      )
  
      if num_levels == 1:
          if len(rois) == 0:
              return roi_feats
          return self.roi_layers[0](feats[0], rois)
  
      target_lvls = self.map_roi_levels(rois, num_levels)
  
      for i in range(num_levels):
          mask = target_lvls == i
          inds = mask.nonzero(as_tuple=False).squeeze(1)
          if inds.numel() > 0:
              rois_ = rois[inds]
              roi_feats_t = self.roi_layers[i](feats[i], rois_)
              roi_feats[inds] = roi_feats_t
          else:
              # Sometimes some pyramid levels will not be used for RoI
              # feature extraction and this will cause an incomplete
              # computation graph in one GPU, which is different from those
              # in other GPUs and will cause a hanging error.
              # Therefore, we add it to ensure each feature pyramid is
              # included in the computation graph to avoid runtime bugs.
              roi_feats += (
                  sum(x.view(-1)[0] for x in self.parameters()) * 0.0
                  + feats[i].sum() * 0.0
              )
      return roi_feats
  
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 4 for calling the BezierRoIExtractor obj's underlying member method code with example usage: obj.forward(feats, proposal_instances) and returns: roi_feats, self, roi_feats