class_docstr: The implementation of the paper: Spatial Dual-Modality Graph Reasoning
  for Key Information Extraction. https://arxiv.org/abs/2103.14470.
  
  Args:
      backbone (dict, optional): Config of backbone. If None, None will be
          passed to kie_head during training and testing. Defaults to None.
      roi_extractor (dict, optional): Config of roi extractor. Only
          applicable when backbone is not None. Defaults to None.
      neck (dict, optional): Config of neck. Defaults to None.
      kie_head (dict): Config of KIE head. Defaults to None.
      dictionary (dict, optional): Config of dictionary. Defaults to None.
      data_preprocessor (dict or ConfigDict, optional): The pre-process
          config of :class:`BaseDataPreprocessor`.  it usually includes,
          ``pad_size_divisor``, ``pad_value``, ``mean`` and ``std``. It has
          to be None when working in non-visual mode. Defaults to None.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
docstr: Extract features from images if self.backbone is not None. It
  returns None otherwise.
  
  Args:
      img (torch.Tensor): The input image with shape (N, C, H, W).
      gt_bboxes (list[torch.Tensor)): A list of ground truth bounding
          boxes, each of shape :math:`(N_i, 4)`.
  
  Returns:
      torch.Tensor: The extracted features with shape (N, E).
docstr_tok: ["Extract","features","from","images","if","self.backbone","is","not","None",".","It","returns","None","otherwise",".","Args",":","img","(","torch.Tensor",")",":","The","input","image","with","shape","(","N",",","C",",","H",",","W",")",".","gt_bboxes","(","list","[","torch.Tensor",")",")",":","A","list","of","ground","truth","bounding","boxes",",","each","of","shape",":","math",":","`","(","N_i",",","4",")","`",".","Returns",":","torch.Tensor",":","The","extracted","features","with","shape","(","N",",","E",")","."]
code: def extract_feat(
      self, img: torch.Tensor, gt_bboxes: List[torch.Tensor]
  ) -> torch.Tensor:
      """Extract features from images if self.backbone is not None. It
      returns None otherwise.
  
      Args:
          img (torch.Tensor): The input image with shape (N, C, H, W).
          gt_bboxes (list[torch.Tensor)): A list of ground truth bounding
              boxes, each of shape :math:`(N_i, 4)`.
  
      Returns:
          torch.Tensor: The extracted features with shape (N, E).
      """
      if not hasattr(self, "backbone"):
          return None
      x = self.backbone(img)
      if hasattr(self, "neck"):
          x = self.neck(x)
      x = x[-1]
      feats = self.maxpool(self.extractor([x], bbox2roi(gt_bboxes)))
      return feats.view(feats.size(0), -1)
  
file_path: mmocr/mmocr/models/kie/extractors/sdmgr.py
imports: import warnings
  from typing import Dict, List, Optional, Sequence, Tuple
  import torch
  from mmdet.structures.bbox import bbox2roi
  from mmengine.model import BaseModel
  from torch import nn
  from mmocr.registry import MODELS, TASK_UTILS
  from mmocr.structures import KIEDataSample
label_desc: Use image node_id 2 for calling the SDMGR obj's underlying member method code with example usage: obj.extract_feat(img, gt_bboxes) and returns: feats, None