class_docstr: Base class of Transfomer decoder module.
  
  Args:
      vocab_size: output dim
      encoder_output_size: dimension of attention
      attention_heads: the number of heads of multi head attention
      linear_units: the number of units of position-wise feed forward
      num_blocks: the number of decoder blocks
      dropout_rate: dropout rate
      self_attention_dropout_rate: dropout rate for attention
      input_layer: input layer type
      use_output_layer: whether to use output layer
      pos_enc_class: PositionalEncoding or ScaledPositionalEncoding
      normalize_before: whether to use layer_norm before the first block
      concat_after: whether to concat attention layer's input and output
          if True, additional linear will be applied.
          i.e. x -> x + linear(concat(x, att(x)))
          if False, no additional linear will be applied.
          i.e. x -> x + att(x)
class_docstr_tok: ["Base","class","of","Transfomer","decoder","module",".","Args",":","vocab_size",":","output","dim","encoder_output_size",":","dimension","of","attention","attention_heads",":","the","number","of","heads","of","multi","head","attention","linear_units",":","the","number","of","units","of","position-wise","feed","forward","num_blocks",":","the","number","of","decoder","blocks","dropout_rate",":","dropout","rate","self_attention_dropout_rate",":","dropout","rate","for","attention","input_layer",":","input","layer","type","use_output_layer",":","whether","to","use","output","layer","pos_enc_class",":","PositionalEncoding","or","ScaledPositionalEncoding","normalize_before",":","whether","to","use","layer_norm","before","the","first","block","concat_after",":","whether","to","concat","attention","layer","'s","input","and","output","if","True",",","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","linear","(","concat","(","x",",","att","(","x",")",")",")","if","False",",","no","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","att","(","x",")"]
code: def __init__(
      self,
      vocab_size: int,
      encoder_output_size: int,
      dropout_rate: float = 0.1,
      positional_dropout_rate: float = 0.1,
      input_layer: str = "embed",
      use_output_layer: bool = True,
      pos_enc_class=PositionalEncoding,
      normalize_before: bool = True,
  ):
      assert check_argument_types()
      super().__init__()
      attention_dim = encoder_output_size
  
      if input_layer == "embed":
          self.embed = torch.nn.Sequential(
              torch.nn.Embedding(vocab_size, attention_dim),
              pos_enc_class(attention_dim, positional_dropout_rate),
          )
      elif input_layer == "linear":
          self.embed = torch.nn.Sequential(
              torch.nn.Linear(vocab_size, attention_dim),
              torch.nn.LayerNorm(attention_dim),
              torch.nn.Dropout(dropout_rate),
              torch.nn.ReLU(),
              pos_enc_class(attention_dim, positional_dropout_rate),
          )
      else:
          raise ValueError(
              f"only 'embed' or 'linear' is supported: {input_layer}"
          )
  
      self.normalize_before = normalize_before
      if self.normalize_before:
          self.after_norm = LayerNorm(attention_dim)
      if use_output_layer:
          self.output_layer = torch.nn.Linear(attention_dim, vocab_size)
      else:
          self.output_layer = None
  
      self._output_size_bf_softmax = attention_dim
      # Must set by the inheritance
      self.decoders = None
  
imports: from typing import Any, List, Sequence, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.decoder_layer import DecoderLayer
  from espnet.nets.pytorch_backend.transformer.dynamic_conv import DynamicConvolution
  from espnet.nets.pytorch_backend.transformer.dynamic_conv2d import DynamicConvolution2D
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.pytorch_backend.transformer.lightconv import LightweightConvolution
  from espnet.nets.pytorch_backend.transformer.lightconv2d import LightweightConvolution2D
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
  from espnet.nets.scorer_interface import BatchScorerInterface
label_desc: Use image node_id 1 to create a new BaseTransformerDecoder object from inherited base classes: AbsDecoder, BatchScorerInterface with example: obj = BaseTransformerDecoder(vocab_size, encoder_output_size, dropout_rate, positional_dropout_rate, input_layer, use_output_layer, pos_enc_class, normalize_before)