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: Forward function.
docstr_tok: ["Forward","function","."]
code: def forward(self, feats, rois, roi_scale_factor=None):
      """Forward function."""
      out_size = self.roi_layers[0].output_size
      num_levels = len(feats)
      if torch.onnx.is_in_onnx_export():
          # Work around to export mask-rcnn to onnx
          roi_feats = rois[:, :1].clone().detach()
          roi_feats = roi_feats.expand(
              -1, self.out_channels * out_size[0] * out_size[1]
          )
          roi_feats = roi_feats.reshape(
              -1, self.out_channels, *out_size
          )
          roi_feats = roi_feats * 0
      else:
          roi_feats = feats[0].new_zeros(
              rois.size(0), self.out_channels, *out_size
          )
      # TODO: remove this when parrots supports
      if torch.__version__ == "parrots":
          roi_feats.requires_grad = True
  
      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)
      if roi_scale_factor is not None:
          rois = self.roi_rescale(rois, roi_scale_factor)
  
      for i in range(num_levels):
          mask = target_lvls == i
          inds = mask.nonzero(as_tuple=False).squeeze(1)
          # TODO: make it nicer when exporting to onnx
          if torch.onnx.is_in_onnx_export():
              # To keep all roi_align nodes exported to onnx
              rois_ = rois[inds]
              roi_feats_t = self.roi_layers[i](feats[i], rois_)
              roi_feats[inds] = roi_feats_t
              continue
          if inds.numel() > 0:
              rois_ = rois[inds]
              roi_feats_t = self.roi_layers[i](feats[i], rois_)
              roi_feats[inds] = roi_feats_t
          else:
              roi_feats += (
                  sum(x.view(-1)[0] for x in self.parameters()) * 0.0
                  + feats[i].sum() * 0.0
              )
      return roi_feats
  
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 3 for calling the SingleRoIExtractor obj's underlying member method code with example usage: obj.forward(feats, rois, roi_scale_factor) and returns: roi_feats, self, roi_feats