class_docstr: A pytorch RNNLM.
class_docstr_tok: ["A","pytorch","RNNLM","."]
docstr: Forward neural networks.
docstr_tok: ["Forward","neural","networks","."]
code: def forward(self, state, x):
      """Forward neural networks."""
      if state is None:
          h = [
              to_device(x, self.zero_state(x.size(0)))
              for n in range(self.n_layers)
          ]
          state = {"h": h}
          if self.typ == "lstm":
              c = [
                  to_device(x, self.zero_state(x.size(0)))
                  for n in range(self.n_layers)
              ]
              state = {"c": c, "h": h}
  
      h = [None] * self.n_layers
      if self.embed_drop is not None:
          emb = self.embed_drop(self.embed(x))
      else:
          emb = self.embed(x)
      if self.typ == "lstm":
          c = [None] * self.n_layers
          h[0], c[0] = self.rnn[0](
              self.dropout[0](emb), (state["h"][0], state["c"][0])
          )
          for n in range(1, self.n_layers):
              h[n], c[n] = self.rnn[n](
                  self.dropout[n](h[n - 1]),
                  (state["h"][n], state["c"][n]),
              )
          state = {"c": c, "h": h}
      else:
          h[0] = self.rnn[0](self.dropout[0](emb), state["h"][0])
          for n in range(1, self.n_layers):
              h[n] = self.rnn[n](
                  self.dropout[n](h[n - 1]), state["h"][n]
              )
          state = {"h": h}
      y = self.lo(self.dropout[-1](h[-1]))
      return state, y
  
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 3 for calling the RNNLM obj's underlying member method code with example usage: obj.forward(state, x) and returns: state,  y