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, vocab_size)`
          and next state list for ys.
docstr_tok: ["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",",","vocab_size",")","`","and","next","state","list","for","ys","."]
code: def batch_score(
      self, ys: torch.Tensor, states: List[Any], xs: torch.Tensor
  ) -> Tuple[torch.Tensor, List[Any]]:
      """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, vocab_size)`
              and next state list for ys.
  
      """
      # merge states
      n_batch = len(ys)
      n_layers = len(self.encoder.encoders)
      if states[0] is None:
          batch_state = None
      else:
          # transpose state of [batch, layer] into [layer, batch]
          batch_state = [
              torch.stack([states[b][i] for b in range(n_batch)])
              for i in range(n_layers)
          ]
  
      # batch decoding
      h, _, states = self.encoder.forward_one_step(
          self.embed(ys), self._target_mask(ys), cache=batch_state
      )
      h = self.decoder(h[:, -1])
      logp = h.log_softmax(dim=-1)
  
      # transpose state of [layer, batch] into [batch, layer]
      state_list = [
          [states[i][b] for i in range(n_layers)]
          for b in range(n_batch)
      ]
      return logp, state_list
  
file_path: espnet/espnet2/lm/transformer_lm.py
imports: from typing import Any, List, Tuple
  import torch
  import torch.nn
  from espnet2.lm.abs_model import AbsLM
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask
label_desc: Use image node_id 5 for calling the TransformerLM obj's underlying member method code with example usage: obj.batch_score(ys, states, xs) and returns: logp,  state_list