class_docstr: Base class of Transfomer decoder module.
  
  Args:
      vocab_size: output dim
      encoder_output_size: dimension of attention
      attention_heads: the number of heads of multi head attention
      linear_units: the number of units of position-wise feed forward
      num_blocks: the number of decoder blocks
      dropout_rate: dropout rate
      self_attention_dropout_rate: dropout rate for attention
      input_layer: input layer type
      use_output_layer: whether to use output layer
      pos_enc_class: PositionalEncoding or ScaledPositionalEncoding
      normalize_before: whether to use layer_norm before the first block
      concat_after: whether to concat attention layer's input and output
          if True, additional linear will be applied.
          i.e. x -> x + linear(concat(x, att(x)))
          if False, no additional linear will be applied.
          i.e. x -> x + att(x)
class_docstr_tok: ["Base","class","of","Transfomer","decoder","module",".","Args",":","vocab_size",":","output","dim","encoder_output_size",":","dimension","of","attention","attention_heads",":","the","number","of","heads","of","multi","head","attention","linear_units",":","the","number","of","units","of","position-wise","feed","forward","num_blocks",":","the","number","of","decoder","blocks","dropout_rate",":","dropout","rate","self_attention_dropout_rate",":","dropout","rate","for","attention","input_layer",":","input","layer","type","use_output_layer",":","whether","to","use","output","layer","pos_enc_class",":","PositionalEncoding","or","ScaledPositionalEncoding","normalize_before",":","whether","to","use","layer_norm","before","the","first","block","concat_after",":","whether","to","concat","attention","layer","'s","input","and","output","if","True",",","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","linear","(","concat","(","x",",","att","(","x",")",")",")","if","False",",","no","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","att","(","x",")"]
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.
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",",","n_vocab",")","`","and","next","state","list","for","ys","."]
code: def batch_score(
      self,
      ys: torch.Tensor,
      states: List[Any],
      xs: torch.Tensor,
      return_hs: bool = False,
  ) -> 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, n_vocab)`
              and next state list for ys.
  
      """
      # merge states
      n_batch = len(ys)
      n_layers = len(self.decoders)
      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
      ys_mask = subsequent_mask(
          ys.size(-1), device=xs.device
      ).unsqueeze(0)
      if return_hs:
          (logp, hs), states = self.forward_one_step(
              ys, ys_mask, xs, cache=batch_state, return_hs=return_hs
          )
      else:
          logp, states = self.forward_one_step(
              ys, ys_mask, xs, cache=batch_state, return_hs=return_hs
          )
  
      # 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)
      ]
      if return_hs:
          return (logp, hs), state_list
      return logp, state_list
  
imports: from typing import Any, List, Sequence, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.decoder_layer import DecoderLayer
  from espnet.nets.pytorch_backend.transformer.dynamic_conv import DynamicConvolution
  from espnet.nets.pytorch_backend.transformer.dynamic_conv2d import DynamicConvolution2D
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.pytorch_backend.transformer.lightconv import LightweightConvolution
  from espnet.nets.pytorch_backend.transformer.lightconv2d import LightweightConvolution2D
  from espnet.nets.pytorch_backend.transformer.mask import subsequent_mask
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
  from espnet.nets.scorer_interface import BatchScorerInterface
label_desc: Use image node_id 5 for calling the BaseTransformerDecoder obj's underlying member method code with example usage: obj.batch_score(ys, states, xs, return_hs) and returns: logp,  state_list, logp,  hs,  state_list