code: def __init__(
      self,
      vocab_size: int,
      encoder_output_size: int,
      rnn_type: str = "lstm",
      num_layers: int = 1,
      hidden_size: int = 320,
      sampling_probability: float = 0.0,
      dropout: float = 0.0,
      context_residual: bool = False,
      replace_sos: bool = False,
      num_encs: int = 1,
      att_conf: dict = get_default_kwargs(build_attention_list),
  ):
      # FIXME(kamo): The parts of num_spk should be refactored more more more
      assert check_argument_types()
      if rnn_type not in {"lstm", "gru"}:
          raise ValueError(f"Not supported: rnn_type={rnn_type}")
  
      super().__init__()
      eprojs = encoder_output_size
      self.dtype = rnn_type
      self.dunits = hidden_size
      self.dlayers = num_layers
      self.context_residual = context_residual
      self.sos = vocab_size - 1
      self.eos = vocab_size - 1
      self.odim = vocab_size
      self.sampling_probability = sampling_probability
      self.dropout = dropout
      self.num_encs = num_encs
  
      # for multilingual translation
      self.replace_sos = replace_sos
  
      self.embed = torch.nn.Embedding(vocab_size, hidden_size)
      self.dropout_emb = torch.nn.Dropout(p=dropout)
  
      self.decoder = torch.nn.ModuleList()
      self.dropout_dec = torch.nn.ModuleList()
      self.decoder += [
          torch.nn.LSTMCell(hidden_size + eprojs, hidden_size)
          if self.dtype == "lstm"
          else torch.nn.GRUCell(hidden_size + eprojs, hidden_size)
      ]
      self.dropout_dec += [torch.nn.Dropout(p=dropout)]
      for _ in range(1, self.dlayers):
          self.decoder += [
              torch.nn.LSTMCell(hidden_size, hidden_size)
              if self.dtype == "lstm"
              else torch.nn.GRUCell(hidden_size, hidden_size)
          ]
          self.dropout_dec += [torch.nn.Dropout(p=dropout)]
          # NOTE: dropout is applied only for the vertical connections
          # see https://arxiv.org/pdf/1409.2329.pdf
  
      if context_residual:
          self.output = torch.nn.Linear(
              hidden_size + eprojs, vocab_size
          )
      else:
          self.output = torch.nn.Linear(hidden_size, vocab_size)
  
      self.att_list = build_attention_list(
          eprojs=eprojs, dunits=hidden_size, **att_conf
      )
  
file_path: espnet/espnet2/asr/decoder/rnn_decoder.py
imports: import random
  import numpy
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.utils.get_default_kwargs import get_default_kwargs
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask, to_device
  from espnet.nets.pytorch_backend.rnn.attentions import initial_att
label_desc: Use image node_id 1 to create a new RNNDecoder object from inherited base classes: AbsDecoder with example: obj = RNNDecoder(vocab_size, encoder_output_size, rnn_type, num_layers, hidden_size, sampling_probability, dropout, context_residual, replace_sos, num_encs, att_conf)