class_docstr: S4 decoder module.
  
  Args:
      vocab_size: output dim
      encoder_output_size: dimension of hidden vector
      input_layer: input layer type
      dropinp: input dropout
      dropout: dropout parameter applied on every residual and every layer
      prenorm: pre-norm vs. post-norm
      n_layers: number of layers
      transposed: transpose inputs so each layer receives (batch, dim, length)
      tie_dropout: tie dropout mask across sequence like nn.Dropout1d/nn.Dropout2d
      n_repeat: each layer is repeated n times per stage before applying pooling
      layer: layer config, must be specified
      residual: residual config
      norm: normalization config (e.g. layer vs batch)
      pool: config for pooling layer per stage
      track_norms: log norms of each layer output
      drop_path: drop rate for stochastic depth
class_docstr_tok: ["S4","decoder","module",".","Args",":","vocab_size",":","output","dim","encoder_output_size",":","dimension","of","hidden","vector","input_layer",":","input","layer","type","dropinp",":","input","dropout","dropout",":","dropout","parameter","applied","on","every","residual","and","every","layer","prenorm",":","pre-norm","vs.","post-norm","n_layers",":","number","of","layers","transposed",":","transpose","inputs","so","each","layer","receives","(","batch",",","dim",",","length",")","tie_dropout",":","tie","dropout","mask","across","sequence","like","nn.Dropout1d\/nn.Dropout2d","n_repeat",":","each","layer","is","repeated","n","times","per","stage","before","applying","pooling","layer",":","layer","config",",","must","be","specified","residual",":","residual","config","norm",":","normalization","config","(","e.g",".","layer","vs","batch",")","pool",":","config","for","pooling","layer","per","stage","track_norms",":","log","norms","of","each","layer","output","drop_path",":","drop","rate","for","stochastic","depth"]
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
  ) -> 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)
      ys = self.embed(ys[:, -1:])
  
      # workaround for remaining beam width of 1
      if type(states[0]) is list:
          states = states[0]
  
      assert ys.size(1) == 1, ys.shape
      ys = ys.squeeze(1)
  
      ys, states = self.decoder.step(ys, state=states, memory=xs)
      logp = self.output(ys).log_softmax(dim=-1)
  
      states_list = [
          [
              state[b].unsqueeze(0) if state is not None else None
              for state in states
          ]
          for b in range(n_batch)
      ]
  
      return logp, states_list
  
file_path: espnet/espnet2/asr/decoder/s4_decoder.py
imports: from typing import Any, List, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.asr.state_spaces.model import SequenceModel
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
  from espnet.nets.scorer_interface import BatchScorerInterface
label_desc: Use image node_id 5 for calling the S4Decoder obj's underlying member method code with example usage: obj.batch_score(ys, states, xs) and returns: logp,  states_list