class_docstr: Implements a ViTSTR architecture as described in `"Vision Transformer for Fast and
  Efficient Scene Text Recognition" <https://arxiv.org/pdf/2105.08582.pdf>`_.
  
  Args:
  ----
      feature_extractor: the backbone serving as feature extractor
      vocab: vocabulary used for encoding
      embedding_units: number of embedding units
      max_length: maximum word length handled by the model
      dropout_prob: dropout probability for the encoder and decoder
      input_shape: input shape of the image
      exportable: onnx exportable returns only logits
      cfg: dictionary containing information about the model
class_docstr_tok: ["Implements","a","ViTSTR","architecture","as","described","in","`","``","Vision","Transformer","for","Fast","and","Efficient","Scene","Text","Recognition","''","<","https",":","\/\/arxiv.org\/pdf\/2105.08582.pdf",">","`","_",".","Args",":","--","--","feature_extractor",":","the","backbone","serving","as","feature","extractor","vocab",":","vocabulary","used","for","encoding","embedding_units",":","number","of","embedding","units","max_length",":","maximum","word","length","handled","by","the","model","dropout_prob",":","dropout","probability","for","the","encoder","and","decoder","input_shape",":","input","shape","of","the","image","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
      )  # (batch_size, patches_seqlen, d_model)
  
      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")
  
      features = features[
          :, : self.max_length
      ]  # (batch_size, max_length, d_model)
      B, N, E = features.shape
      features = tf.reshape(features, (B * N, E))
      logits = tf.reshape(
          self.head(features, **kwargs), (B, N, len(self.vocab) + 1)
      )  # (batch_size, max_length, vocab + 1)
      decoded_features = _bf16_to_float32(
          logits[:, 1:]
      )  # remove cls_token
  
      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
  
file_path: doctr/doctr/models/recognition/vitstr/tensorflow.py
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple
  import tensorflow
  from tensorflow.keras import Model, layers
  from doctr.datasets import VOCABS
  from ...classification import vit_b, vit_s
  from ...utils.tensorflow import _bf16_to_float32, load_pretrained_params
  from .base import _ViTSTR, _ViTSTRPostProcessor
label_desc: Use image node_id 3 for calling the ViTSTR obj's underlying member method code with example usage: obj.call(x, target, return_model_output, return_preds) and returns: out, out