class_docstr: Implements a SAR architecture as described in `"Show, Attend and Read:A Simple and Strong Baseline for
  Irregular Text Recognition" <https://arxiv.org/pdf/1811.00751.pdf>`_.
  
  Args:
  ----
      feature_extractor: the backbone serving as feature extractor
      vocab: vocabulary used for encoding
      rnn_units: number of hidden units in both encoder and decoder LSTM
      embedding_units: number of embedding units
      attention_units: number of hidden units in attention module
      max_length: maximum word length handled by the model
      dropout_prob: dropout probability of the encoder LSTM
      exportable: onnx exportable returns only logits
      cfg: dictionary containing information about the model
class_docstr_tok: ["Implements","a","SAR","architecture","as","described","in","`","``","Show",",","Attend","and","Read",":","A","Simple","and","Strong","Baseline","for","Irregular","Text","Recognition","''","<","https",":","\/\/arxiv.org\/pdf\/1811.00751.pdf",">","`","_",".","Args",":","--","--","feature_extractor",":","the","backbone","serving","as","feature","extractor","vocab",":","vocabulary","used","for","encoding","rnn_units",":","number","of","hidden","units","in","both","encoder","and","decoder","LSTM","embedding_units",":","number","of","embedding","units","attention_units",":","number","of","hidden","units","in","attention","module","max_length",":","maximum","word","length","handled","by","the","model","dropout_prob",":","dropout","probability","of","the","encoder","LSTM","exportable",":","onnx","exportable","returns","only","logits","cfg",":","dictionary","containing","information","about","the","model"]
code: def __init__(
      self,
      feature_extractor,
      vocab: str,
      rnn_units: int = 512,
      embedding_units: int = 512,
      attention_units: int = 512,
      max_length: int = 30,
      dropout_prob: float = 0.0,
      input_shape: Tuple[int, int, int] = (3, 32, 128),
      exportable: bool = False,
      cfg: Optional[Dict[str, Any]] = None,
  ) -> None:
      super().__init__()
      self.vocab = vocab
      self.exportable = exportable
      self.cfg = cfg
  
      self.max_length = (
          max_length + 1
      )  # Add 1 timestep for EOS after the longest word
  
      self.feat_extractor = feature_extractor
  
      # Size the LSTM
      self.feat_extractor.eval()
      with torch.no_grad():
          out_shape = self.feat_extractor(
              torch.zeros((1, *input_shape))
          )["features"].shape
      # Switch back to original mode
      self.feat_extractor.train()
  
      self.encoder = SAREncoder(out_shape[1], rnn_units, dropout_prob)
      self.decoder = SARDecoder(
          rnn_units,
          self.max_length,
          len(self.vocab),
          embedding_units,
          attention_units,
          dropout_prob=dropout_prob,
      )
  
      self.postprocessor = SARPostProcessor(vocab=vocab)
  
      for n, m in self.named_modules():
          # Don't override the initialization of the backbone
          if n.startswith("feat_extractor."):
              continue
          if isinstance(m, nn.Conv2d):
              nn.init.kaiming_normal_(
                  m.weight, mode="fan_out", nonlinearity="relu"
              )
          elif isinstance(m, (nn.BatchNorm2d, nn.GroupNorm)):
              nn.init.constant_(m.weight, 1)
              nn.init.constant_(m.bias, 0)
  
imports: from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from torch.nn import functional
  from torchvision.models._utils import IntermediateLayerGetter
  from doctr.datasets import VOCABS
  from ...classification import resnet31
  from ...utils.pytorch import _bf16_to_float32, load_pretrained_params
  from ..core import RecognitionModel, RecognitionPostProcessor
label_desc: Use image node_id 1 to create a new SAR object from inherited base classes: nn, RecognitionModel with example: obj = SAR(feature_extractor, vocab, rnn_units, embedding_units, attention_units, max_length, dropout_prob, input_shape, exportable, cfg)