class_docstr: Transfomer decoder module.
  
  Args:
      odim (int): Output diminsion.
      self_attention_layer_type (str): Self-attention layer type.
      attention_dim (int): Dimension of attention.
      attention_heads (int): The number of heads of multi head attention.
      conv_wshare (int): The number of kernel of convolution. Only used in
          self_attention_layer_type == "lightconv*" or "dynamiconv*".
      conv_kernel_length (Union[int, str]): Kernel size str of convolution
          (e.g. 71_71_71_71_71_71). Only used in self_attention_layer_type
          == "lightconv*" or "dynamiconv*".
      conv_usebias (bool): Whether to use bias in convolution. Only used in
          self_attention_layer_type == "lightconv*" or "dynamiconv*".
      linear_units (int): The number of units of position-wise feed forward.
      num_blocks (int): The number of decoder blocks.
      dropout_rate (float): Dropout rate.
      positional_dropout_rate (float): Dropout rate after adding positional encoding.
      self_attention_dropout_rate (float): Dropout rate in self-attention.
      src_attention_dropout_rate (float): Dropout rate in source-attention.
      input_layer (Union[str, torch.nn.Module]): Input layer type.
      use_output_layer (bool): Whether to use output layer.
      pos_enc_class (torch.nn.Module): Positional encoding module class.
          `PositionalEncoding `or `ScaledPositionalEncoding`
      normalize_before (bool): Whether to use layer_norm before the first block.
      concat_after (bool): 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)
docstr: Construct an Decoder object.
docstr_tok: ["Construct","an","Decoder","object","."]
code: def __init__(
      self,
      odim,
      selfattention_layer_type="selfattn",
      attention_dim=256,
      attention_heads=4,
      conv_wshare=4,
      conv_kernel_length=11,
      conv_usebias=False,
      linear_units=2048,
      num_blocks=6,
      dropout_rate=0.1,
      positional_dropout_rate=0.1,
      self_attention_dropout_rate=0.0,
      src_attention_dropout_rate=0.0,
      input_layer="embed",
      use_output_layer=True,
      pos_enc_class=PositionalEncoding,
      normalize_before=True,
      concat_after=False,
  ):
      """Construct an Decoder object."""
      torch.nn.Module.__init__(self)
      self._register_load_state_dict_pre_hook(_pre_hook)
      if input_layer == "embed":
          self.embed = torch.nn.Sequential(
              torch.nn.Embedding(odim, attention_dim),
              pos_enc_class(attention_dim, positional_dropout_rate),
          )
      elif input_layer == "linear":
          self.embed = torch.nn.Sequential(
              torch.nn.Linear(odim, attention_dim),
              torch.nn.LayerNorm(attention_dim),
              torch.nn.Dropout(dropout_rate),
              torch.nn.ReLU(),
              pos_enc_class(attention_dim, positional_dropout_rate),
          )
      elif isinstance(input_layer, torch.nn.Module):
          self.embed = torch.nn.Sequential(
              input_layer,
              pos_enc_class(attention_dim, positional_dropout_rate),
          )
      else:
          raise NotImplementedError(
              "only `embed` or torch.nn.Module is supported."
          )
      self.normalize_before = normalize_before
  
      # self-attention module definition
      if selfattention_layer_type == "selfattn":
          logging.info(
              "decoder self-attention layer type = self-attention"
          )
          decoder_selfattn_layer = MultiHeadedAttention
          decoder_selfattn_layer_args = [
              (
                  attention_heads,
                  attention_dim,
                  self_attention_dropout_rate,
              )
          ] * num_blocks
      elif selfattention_layer_type == "lightconv":
          logging.info(
              "decoder self-attention layer type = lightweight convolution"
          )
          decoder_selfattn_layer = LightweightConvolution
          decoder_selfattn_layer_args = [
              (
                  conv_wshare,
                  attention_dim,
                  self_attention_dropout_rate,
                  int(conv_kernel_length.split("_")[lnum]),
                  True,
                  conv_usebias,
              )
              for lnum in range(num_blocks)
          ]
      elif selfattention_layer_type == "lightconv2d":
          logging.info(
              "decoder self-attention layer "
              "type = lightweight convolution 2-dimensional"
          )
          decoder_selfattn_layer = LightweightConvolution2D
          decoder_selfattn_layer_args = [
              (
                  conv_wshare,
                  attention_dim,
                  self_attention_dropout_rate,
                  int(conv_kernel_length.split("_")[lnum]),
                  True,
                  conv_usebias,
              )
              for lnum in range(num_blocks)
          ]
      elif selfattention_layer_type == "dynamicconv":
          logging.info(
              "decoder self-attention layer type = dynamic convolution"
          )
          decoder_selfattn_layer = DynamicConvolution
          decoder_selfattn_layer_args = [
              (
                  conv_wshare,
                  attention_dim,
                  self_attention_dropout_rate,
                  int(conv_kernel_length.split("_")[lnum]),
                  True,
                  conv_usebias,
              )
              for lnum in range(num_blocks)
          ]
      elif selfattention_layer_type == "dynamicconv2d":
          logging.info(
              "decoder self-attention layer type = dynamic convolution 2-dimensional"
          )
          decoder_selfattn_layer = DynamicConvolution2D
          decoder_selfattn_layer_args = [
              (
                  conv_wshare,
                  attention_dim,
                  self_attention_dropout_rate,
                  int(conv_kernel_length.split("_")[lnum]),
                  True,
                  conv_usebias,
              )
              for lnum in range(num_blocks)
          ]
  
      self.decoders = repeat(
          num_blocks,
          lambda lnum: DecoderLayer(
              attention_dim,
              decoder_selfattn_layer(
                  *decoder_selfattn_layer_args[lnum]
              ),
              MultiHeadedAttention(
                  attention_heads,
                  attention_dim,
                  src_attention_dropout_rate,
              ),
              PositionwiseFeedForward(
                  attention_dim, linear_units, dropout_rate
              ),
              dropout_rate,
              normalize_before,
              concat_after,
          ),
      )
      self.selfattention_layer_type = selfattention_layer_type
      if self.normalize_before:
          self.after_norm = LayerNorm(attention_dim)
      if use_output_layer:
          self.output_layer = torch.nn.Linear(attention_dim, odim)
      else:
          self.output_layer = None
  
imports: import logging
  from typing import Any, List, Tuple
  import torch
  from espnet.nets.pytorch_backend.nets_utils import rename_state_dict
  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 Decoder object from inherited base classes: BatchScorerInterface, torch.nn with example: obj = Decoder(odim, attention_layer_type, attention_dim, attention_heads, conv_wshare, conv_kernel_length, conv_usebias, linear_units, num_blocks, dropout_rate, positional_dropout_rate, _attention_dropout_rate, src_attention_dropout_rate, input_layer, use_output_layer, pos_enc_class, normalize_before, concat_after)