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
      num_decoder_cells: number of LSTMCell layers to stack
      dropout_prob: dropout probability for the encoder and decoder
      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","num_decoder_cells",":","number","of","LSTMCell","layers","to","stack","dropout_prob",":","dropout","probability","for","the","encoder","and","decoder","exportable",":","onnx","exportable","returns","only","logits","cfg",":","dictionary","containing","information","about","the","model"]
code: def call(
      self,
      x: tf.Tensor,
      target: Optional[List[str]] = None,
      return_model_output: bool = False,
      return_preds: bool = False,
      **kwargs: Any,
  ) -> Dict[str, Any]:
      features = self.feat_extractor(x, **kwargs)
      # vertical max pooling --> (N, C, W)
      pooled_features = tf.reduce_max(features, axis=1)
      # holistic (N, C)
      encoded = self.encoder(pooled_features, **kwargs)
  
      if target is not None:
          gt, seq_len = self.build_target(target)
          seq_len = tf.cast(seq_len, tf.int32)
  
      if kwargs.get("training", False) and target is None:
          raise ValueError(
              "Need to provide labels during training for teacher forcing"
          )
  
      decoded_features = _bf16_to_float32(
          self.decoder(
              features,
              encoded,
              gt=None if target is None else gt,
              **kwargs,
          )
      )
  
      out: Dict[str, tf.Tensor] = {}
      if self.exportable:
          out["logits"] = decoded_features
          return out
  
      if return_model_output:
          out["out_map"] = decoded_features
  
      if target is None or return_preds:
          # Post-process boxes
          out["preds"] = self.postprocessor(decoded_features)
  
      if target is not None:
          out["loss"] = self.compute_loss(decoded_features, gt, seq_len)
  
      return out
  
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple
  import tensorflow
  from tensorflow.keras import Model, Sequential, layers
  from doctr.datasets import VOCABS
  from doctr.utils.repr import NestedObject
  from ...classification import resnet31
  from ...utils.tensorflow import _bf16_to_float32, load_pretrained_params
  from ..core import RecognitionModel, RecognitionPostProcessor
label_desc: Use image node_id 3 for calling the SAR obj's underlying member method code with example usage: obj.call(x, target, return_model_output, return_preds) and returns: out, out