class_docstr: A pytorch RNNLM.
class_docstr_tok: ["A","pytorch","RNNLM","."]
docstr: Initialize class.
  
  :param int n_vocab: The size of the vocabulary
  :param int n_layers: The number of layers to create
  :param int n_units: The number of units per layer
  :param str typ: The RNN type
docstr_tok: ["Initialize","class",".",":","param","int","n_vocab",":","The","size","of","the","vocabulary",":","param","int","n_layers",":","The","number","of","layers","to","create",":","param","int","n_units",":","The","number","of","units","per","layer",":","param","str","typ",":","The","RNN","type"]
code: def __init__(
      self,
      n_vocab,
      n_layers,
      n_units,
      n_embed=None,
      typ="lstm",
      dropout_rate=0.5,
      emb_dropout_rate=0.0,
      tie_weights=False,
  ):
      """Initialize class.
  
      :param int n_vocab: The size of the vocabulary
      :param int n_layers: The number of layers to create
      :param int n_units: The number of units per layer
      :param str typ: The RNN type
      """
      super(RNNLM, self).__init__()
      if n_embed is None:
          n_embed = n_units
  
      self.embed = nn.Embedding(n_vocab, n_embed)
  
      if emb_dropout_rate == 0.0:
          self.embed_drop = None
      else:
          self.embed_drop = nn.Dropout(emb_dropout_rate)
  
      if typ == "lstm":
          self.rnn = nn.ModuleList(
              [nn.LSTMCell(n_embed, n_units)]
              + [
                  nn.LSTMCell(n_units, n_units)
                  for _ in range(n_layers - 1)
              ]
          )
      else:
          self.rnn = nn.ModuleList(
              [nn.GRUCell(n_embed, n_units)]
              + [
                  nn.GRUCell(n_units, n_units)
                  for _ in range(n_layers - 1)
              ]
          )
  
      self.dropout = nn.ModuleList(
          [nn.Dropout(dropout_rate) for _ in range(n_layers + 1)]
      )
      self.lo = nn.Linear(n_units, n_vocab)
      self.n_layers = n_layers
      self.n_units = n_units
      self.typ = typ
  
      logging.info("Tie weights set to {}".format(tie_weights))
      logging.info("Dropout set to {}".format(dropout_rate))
      logging.info("Emb Dropout set to {}".format(emb_dropout_rate))
  
      if tie_weights:
          assert (
              n_embed == n_units
          ), "Tie Weights: True need embedding and final dimensions to match"
          self.lo.weight = self.embed.weight
  
      # initialize parameters from uniform distribution
      for param in self.parameters():
          param.data.uniform_(-0.1, 0.1)
  
imports: import logging
  from typing import Any, List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from espnet.nets.lm_interface import LMInterface
  from espnet.nets.pytorch_backend.e2e_asr import to_device
  from espnet.nets.scorer_interface import BatchScorerInterface
  from espnet.utils.cli_utils import strtobool
label_desc: Use image node_id 1 to create a new RNNLM object from inherited base classes: nn with example: obj = RNNLM(n_vocab, n_layers, n_units, n_embed, typ, dropout_rate, emb_dropout_rate, tie_weights)