class_docstr: Sequence attention decoder for RobustScanner.
  
  RobustScanner: `RobustScanner: Dynamically Enhancing Positional Clues for
  Robust Text Recognition <https://arxiv.org/abs/2007.07542>`_
  
  Args:
      num_classes (int): Number of output classes :math:`C`.
      rnn_layers (int): Number of RNN layers.
      dim_input (int): Dimension :math:`D_i` of input vector ``feat``.
      dim_model (int): Dimension :math:`D_m` of the model. Should also be the
          same as encoder output vector ``out_enc``.
      max_seq_len (int): Maximum output sequence length :math:`T`.
      start_idx (int): The index of `<SOS>`.
      mask (bool): Whether to mask input features according to
          ``img_meta['valid_ratio']``.
      padding_idx (int): The index of `<PAD>`.
      dropout (float): Dropout rate.
      return_feature (bool): Return feature or logits as the result.
      encode_value (bool): Whether to use the output of encoder ``out_enc``
          as `value` of attention layer. If False, the original feature
          ``feat`` will be used.
  
  Warning:
      This decoder will not predict the final class which is assumed to be
      `<PAD>`. Therefore, its output size is always :math:`C - 1`. `<PAD>`
      is also ignored by loss as specified in
      :obj:`mmocr.models.textrecog.recognizer.EncodeDecodeRecognizer`.
class_docstr_tok: ["Sequence","attention","decoder","for","RobustScanner",".","RobustScanner",":","`","RobustScanner",":","Dynamically","Enhancing","Positional","Clues","for","Robust","Text","Recognition","<","https",":","\/\/arxiv.org\/abs\/2007.07542",">","`","_","Args",":","num_classes","(","int",")",":","Number","of","output","classes",":","math",":","`","C","`",".","rnn_layers","(","int",")",":","Number","of","RNN","layers",".","dim_input","(","int",")",":","Dimension",":","math",":","`","D_i","`","of","input","vector","``","feat","``",".","dim_model","(","int",")",":","Dimension",":","math",":","`","D_m","`","of","the","model",".","Should","also","be","the","same","as","encoder","output","vector","``","out_enc","``",".","max_seq_len","(","int",")",":","Maximum","output","sequence","length",":","math",":","`","T","`",".","start_idx","(","int",")",":","The","index","of","`","<","SOS",">","`",".","mask","(","bool",")",":","Whether","to","mask","input","features","according","to","``","img_meta","[","'valid_ratio","'","]","``",".","padding_idx","(","int",")",":","The","index","of","`","<","PAD",">","`",".","dropout","(","float",")",":","Dropout","rate",".","return_feature","(","bool",")",":","Return","feature","or","logits","as","the","result",".","encode_value","(","bool",")",":","Whether","to","use","the","output","of","encoder","``","out_enc","``","as","`","value","`","of","attention","layer",".","If","False",",","the","original","feature","``","feat","``","will","be","used",".","Warning",":","This","decoder","will","not","predict","the","final","class","which","is","assumed","to","be","`","<","PAD",">","`",".","Therefore",",","its","output","size","is","always",":","math",":","`","C","-","1","`",".","`","<","PAD",">","`","is","also","ignored","by","loss","as","specified","in",":","obj",":","`","mmocr.models.textrecog.recognizer.EncodeDecodeRecognizer","`","."]
code: def __init__(
      self,
      num_classes=None,
      rnn_layers=2,
      dim_input=512,
      dim_model=128,
      max_seq_len=40,
      start_idx=0,
      mask=True,
      padding_idx=None,
      dropout=0,
      return_feature=False,
      encode_value=False,
  ):
      super().__init__()
  
      self.num_classes = num_classes
      self.dim_input = dim_input
      self.dim_model = dim_model
      self.return_feature = return_feature
      self.encode_value = encode_value
      self.max_seq_len = max_seq_len
      self.start_idx = start_idx
      self.mask = mask
  
      self.embedding = nn.Embedding(
          self.num_classes, self.dim_model, padding_idx=padding_idx
      )
  
      self.sequence_layer = nn.LSTM(
          input_size=dim_model,
          hidden_size=dim_model,
          num_layers=rnn_layers,
          time_major=False,
          dropout=dropout,
      )
  
      self.attention_layer = DotProductAttentionLayer()
  
      self.prediction = None
      if not self.return_feature:
          pred_num_classes = num_classes - 1
          self.prediction = nn.Linear(
              dim_model if encode_value else dim_input, pred_num_classes
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
label_desc: Use image node_id 1 to create a new SequenceAttentionDecoder object from inherited base classes: BaseDecoder with example: obj = SequenceAttentionDecoder(num_classes, rnn_layers, dim_input, dim_model, max_seq_len, start_idx, mask, padding_idx, dropout, return_feature, encode_value)