class_docstr: Sequential RNNLM.
  
  See also:
      https://github.com/pytorch/examples/blob/4581968193699de14b56527296262dd76ab43557/word_language_model/model.py
docstr: Score new token batch.
  
  Args:
      ys (torch.Tensor): torch.int64 prefix tokens (n_batch, ylen).
      states (List[Any]): Scorer states for prefix tokens.
      xs (torch.Tensor):
          The encoder feature that generates ys (n_batch, xlen, n_feat).
  
  Returns:
      tuple[torch.Tensor, List[Any]]: Tuple of
          batchfied scores for next token with shape of `(n_batch, n_vocab)`
          and next state list for ys.
code: def batch_score(
      self, ys: torch.Tensor, states: torch.Tensor, xs: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Score new token batch.
  
      Args:
          ys (torch.Tensor): torch.int64 prefix tokens (n_batch, ylen).
          states (List[Any]): Scorer states for prefix tokens.
          xs (torch.Tensor):
              The encoder feature that generates ys (n_batch, xlen, n_feat).
  
      Returns:
          tuple[torch.Tensor, List[Any]]: Tuple of
              batchfied scores for next token with shape of `(n_batch, n_vocab)`
              and next state list for ys.
  
      """
      if states[0] is None:
          states = None
      elif isinstance(self.rnn, torch.nn.LSTM):
          # states: Batch x 2 x (Nlayers, Dim) -> 2 x (Nlayers, Batch, Dim)
          h = torch.stack([h for h, c in states], dim=1)
          c = torch.stack([c for h, c in states], dim=1)
          states = h, c
      else:
          # states: Batch x (Nlayers, Dim) -> (Nlayers, Batch, Dim)
          states = torch.stack(states, dim=1)
  
      ys, states = self(ys[:, -1:], states)
      # ys: (Batch, 1, Nvocab) -> (Batch, NVocab)
      assert ys.size(1) == 1, ys.shape
      ys = ys.squeeze(1)
      logp = ys.log_softmax(dim=-1)
  
      # state: Change to batch first
      if isinstance(self.rnn, torch.nn.LSTM):
          # h, c: (Nlayers, Batch, Dim)
          h, c = states
          # states: Batch x 2 x (Nlayers, Dim)
          states = [(h[:, i], c[:, i]) for i in range(h.size(1))]
      else:
          # states: (Nlayers, Batch, Dim) -> Batch x (Nlayers, Dim)
          states = [states[:, i] for i in range(states.size(1))]
  
      return logp, states
  
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 5 for calling the SequentialRNNLM obj's underlying member method code with example usage: obj.batch_score(ys, states, xs) and returns: logp,  states