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","`","."]
docstr: Args:
      feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
      out_enc (Tensor): Encoder output of shape
          :math:`(N, D_m, H, W)`.
      decode_sequence (Tensor): Shape :math:`(N, T)`. The tensor that
          stores history decoding result.
      current_step (int): Current decoding step.
      valid_ratios (Tensor): valid length ratio of img
  
  Returns:
      Tensor: Shape :math:`(N, C-1)`. The logit tensor of predicted
      tokens at current time step.
docstr_tok: ["Args",":","feat","(","Tensor",")",":","Tensor","of","shape",":","math",":","`","(","N",",","D_i",",","H",",","W",")","`",".","out_enc","(","Tensor",")",":","Encoder","output","of","shape",":","math",":","`","(","N",",","D_m",",","H",",","W",")","`",".","decode_sequence","(","Tensor",")",":","Shape",":","math",":","`","(","N",",","T",")","`",".","The","tensor","that","stores","history","decoding","result",".","current_step","(","int",")",":","Current","decoding","step",".","valid_ratios","(","Tensor",")",":","valid","length","ratio","of","img","Returns",":","Tensor",":","Shape",":","math",":","`","(","N",",","C-1",")","`",".","The","logit","tensor","of","predicted","tokens","at","current","time","step","."]
code: def forward_test_step(
      self, feat, out_enc, decode_sequence, current_step, valid_ratios
  ):
      """
      Args:
          feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
          out_enc (Tensor): Encoder output of shape
              :math:`(N, D_m, H, W)`.
          decode_sequence (Tensor): Shape :math:`(N, T)`. The tensor that
              stores history decoding result.
          current_step (int): Current decoding step.
          valid_ratios (Tensor): valid length ratio of img
  
      Returns:
          Tensor: Shape :math:`(N, C-1)`. The logit tensor of predicted
          tokens at current time step.
      """
  
      embed = self.embedding(decode_sequence)
  
      n, c_enc, h, w = out_enc.shape
      assert c_enc == self.dim_model
      _, c_feat, _, _ = feat.shape
      assert c_feat == self.dim_input
      _, _, c_q = embed.shape
      assert c_q == self.dim_model
  
      query, _ = self.sequence_layer(embed)
      query = paddle.transpose(query, (0, 2, 1))
      key = paddle.reshape(out_enc, [n, c_enc, h * w])
      if self.encode_value:
          value = key
      else:
          value = paddle.reshape(feat, [n, c_feat, h * w])
  
      # [n, c, l]
      attn_out = self.attention_layer(
          query, key, value, h, w, valid_ratios
      )
      out = attn_out[:, :, current_step]
  
      if self.return_feature:
          return out
  
      out = self.prediction(out)
      out = F.softmax(out, dim=-1)
  
      return out
  
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 4 for calling the SequenceAttentionDecoder obj's underlying member method code with example usage: obj.forward_test_step(feat, out_enc, decode_sequence, current_step, valid_ratios) and returns: out, out