class_docstr: Args:
      out_channels (int): Output class number.
      enc_bi_rnn (bool): If True, use bidirectional RNN in encoder.
      dec_bi_rnn (bool): If True, use bidirectional RNN in decoder.
      dec_drop_rnn (float): Dropout of RNN layer in decoder.
      dec_gru (bool): If True, use GRU, else LSTM in decoder.
      d_model (int): Dim of channels from backbone.
      d_enc (int): Dim of encoder RNN layer.
      d_k (int): Dim of channels of attention module.
      pred_dropout (float): Dropout probability of prediction layer.
      max_seq_len (int): Maximum sequence length for decoding.
      mask (bool): If True, mask padding in feature map.
      start_idx (int): Index of start token.
      padding_idx (int): Index of padding token.
      pred_concat (bool): If True, concat glimpse feature from
          attention with holistic feature and hidden state.
class_docstr_tok: ["Args",":","out_channels","(","int",")",":","Output","class","number",".","enc_bi_rnn","(","bool",")",":","If","True",",","use","bidirectional","RNN","in","encoder",".","dec_bi_rnn","(","bool",")",":","If","True",",","use","bidirectional","RNN","in","decoder",".","dec_drop_rnn","(","float",")",":","Dropout","of","RNN","layer","in","decoder",".","dec_gru","(","bool",")",":","If","True",",","use","GRU",",","else","LSTM","in","decoder",".","d_model","(","int",")",":","Dim","of","channels","from","backbone",".","d_enc","(","int",")",":","Dim","of","encoder","RNN","layer",".","d_k","(","int",")",":","Dim","of","channels","of","attention","module",".","pred_dropout","(","float",")",":","Dropout","probability","of","prediction","layer",".","max_seq_len","(","int",")",":","Maximum","sequence","length","for","decoding",".","mask","(","bool",")",":","If","True",",","mask","padding","in","feature","map",".","start_idx","(","int",")",":","Index","of","start","token",".","padding_idx","(","int",")",":","Index","of","padding","token",".","pred_concat","(","bool",")",":","If","True",",","concat","glimpse","feature","from","attention","with","holistic","feature","and","hidden","state","."]
code: def __init__(
      self,
      out_channels,  # 90 + unknown + start + padding
      enc_bi_rnn=False,
      dec_bi_rnn=False,
      dec_drop_rnn=0.0,
      dec_gru=False,
      d_model=512,
      d_enc=512,
      d_k=64,
      pred_dropout=0.1,
      max_text_length=30,
      mask=True,
      pred_concat=True,
      **kwargs,
  ):
      super().__init__()
  
      self.num_classes = out_channels
      self.enc_bi_rnn = enc_bi_rnn
      self.d_k = d_k
      self.start_idx = out_channels - 2
      self.padding_idx = out_channels - 1
      self.max_seq_len = max_text_length
      self.mask = mask
      self.pred_concat = pred_concat
  
      encoder_rnn_out_size = d_enc * (int(enc_bi_rnn) + 1)
      decoder_rnn_out_size = encoder_rnn_out_size * (
          int(dec_bi_rnn) + 1
      )
  
      # 2D attention layer
      self.conv1x1_1 = nn.Linear(decoder_rnn_out_size, d_k)
      self.conv3x3_1 = nn.Conv2D(
          d_model, d_k, kernel_size=3, stride=1, padding=1
      )
      self.conv1x1_2 = nn.Linear(d_k, 1)
  
      # Decoder RNN layer
      if dec_bi_rnn:
          direction = "bidirectional"
      else:
          direction = "forward"
  
      kwargs = dict(
          input_size=encoder_rnn_out_size,
          hidden_size=encoder_rnn_out_size,
          num_layers=2,
          time_major=False,
          dropout=dec_drop_rnn,
          direction=direction,
      )
      if dec_gru:
          self.rnn_decoder = nn.GRU(**kwargs)
      else:
          self.rnn_decoder = nn.LSTM(**kwargs)
  
      # Decoder input embedding
      self.embedding = nn.Embedding(
          self.num_classes,
          encoder_rnn_out_size,
          padding_idx=self.padding_idx,
      )
  
      # Prediction layer
      self.pred_dropout = nn.Dropout(pred_dropout)
      pred_num_classes = self.num_classes - 1
      if pred_concat:
          fc_in_channel = (
              decoder_rnn_out_size + d_model + encoder_rnn_out_size
          )
      else:
          fc_in_channel = d_model
      self.prediction = nn.Linear(fc_in_channel, 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 ParallelSARDecoder object from inherited base classes: BaseDecoder with example: obj = ParallelSARDecoder(out_channels, enc_bi_rnn, dec_bi_rnn, dec_drop_rnn, dec_gru, d_model, d_enc, d_k, pred_dropout, max_text_length, mask, pred_concat)