class_docstr: Sequential RNNLM.
  
  See also:
      https://github.com/pytorch/examples/blob/4581968193699de14b56527296262dd76ab43557/word_language_model/model.py
code: def __init__(
      self,
      vocab_size: int,
      unit: int = 650,
      nhid: int = None,
      nlayers: int = 2,
      dropout_rate: float = 0.0,
      tie_weights: bool = False,
      rnn_type: str = "lstm",
      ignore_id: int = 0,
  ):
      assert check_argument_types()
      super().__init__()
  
      ninp = unit
      if nhid is None:
          nhid = unit
      rnn_type = rnn_type.upper()
  
      self.drop = nn.Dropout(dropout_rate)
      self.encoder = nn.Embedding(
          vocab_size, ninp, padding_idx=ignore_id
      )
      if rnn_type in ["LSTM", "GRU"]:
          rnn_class = getattr(nn, rnn_type)
          self.rnn = rnn_class(
              ninp,
              nhid,
              nlayers,
              dropout=dropout_rate,
              batch_first=True,
          )
      else:
          try:
              nonlinearity = {"RNN_TANH": "tanh", "RNN_RELU": "relu"}[
                  rnn_type
              ]
          except KeyError:
              raise ValueError(
                  """An invalid option for `--model` was supplied,
                      options are ['LSTM', 'GRU', 'RNN_TANH' or 'RNN_RELU']"""
              )
          self.rnn = nn.RNN(
              ninp,
              nhid,
              nlayers,
              nonlinearity=nonlinearity,
              dropout=dropout_rate,
              batch_first=True,
          )
      self.decoder = nn.Linear(nhid, vocab_size)
  
      # Optionally tie weights as in:
      # "Using the Output Embedding to Improve Language Models"
      # (Press & Wolf 2016) https://arxiv.org/abs/1608.05859
      # and
      # "Tying Word Vectors and Word Classifiers:
      # A Loss Framework for Language Modeling" (Inan et al. 2016)
      # https://arxiv.org/abs/1611.01462
      if tie_weights:
          if nhid != ninp:
              raise ValueError(
                  "When using the tied flag, nhid must be equal to emsize"
              )
          self.decoder.weight = self.encoder.weight
  
      self.rnn_type = rnn_type
      self.nhid = nhid
      self.nlayers = nlayers
  
file_path: espnet/espnet2/lm/seq_rnn_lm.py
imports: from typing import Tuple, Union
  import torch
  import torch.nn
  from typeguard import check_argument_types
  from espnet2.lm.abs_model import AbsLM
label_desc: Use image node_id 1 to create a new SequentialRNNLM object from inherited base classes: AbsLM with example: obj = SequentialRNNLM(vocab_size, unit, nhid, nlayers, dropout_rate, tie_weights, rnn_type, ignore_id)