class_docstr: (RNN-)Transducer decoder module.
  
  Args:
      vocab_size: Output dimension.
      layers_type: (RNN-)Decoder layers type.
      num_layers: Number of decoder layers.
      hidden_size: Number of decoder units per layer.
      dropout: Dropout rate for decoder layers.
      dropout_embed: Dropout rate for embedding layer.
      embed_pad: Embed/Blank symbol ID.
docstr: One-step forward hypotheses.
  
  Args:
      hyps: Hypotheses.
      states: Decoder hidden states. ((N, B, D_dec), (N, B, D_dec))
      cache: Pairs of (dec_out, dec_states) for each label sequences. (keys)
      use_lm: Whether to compute label ID sequences for LM.
  
  Returns:
      dec_out: Decoder output sequences. (B, D_dec)
      dec_states: Decoder hidden states. ((N, B, D_dec), (N, B, D_dec))
      lm_labels: Label ID sequences for LM. (B,)
docstr_tok: ["One-step","forward","hypotheses",".","Args",":","hyps",":","Hypotheses",".","states",":","Decoder","hidden","states",".","(","(","N",",","B",",","D_dec",")",",","(","N",",","B",",","D_dec",")",")","cache",":","Pairs","of","(","dec_out",",","dec_states",")","for","each","label","sequences",".","(","keys",")","use_lm",":","Whether","to","compute","label","ID","sequences","for","LM",".","Returns",":","dec_out",":","Decoder","output","sequences",".","(","B",",","D_dec",")","dec_states",":","Decoder","hidden","states",".","(","(","N",",","B",",","D_dec",")",",","(","N",",","B",",","D_dec",")",")","lm_labels",":","Label","ID","sequences","for","LM",".","(","B",",",")"]
code: def batch_score(
      self,
      hyps: Union[List[Hypothesis], List[ExtendedHypothesis]],
      dec_states: Tuple[torch.Tensor, Optional[torch.Tensor]],
      cache: Dict[str, Any],
      use_lm: bool,
  ) -> Tuple[
      torch.Tensor, Tuple[torch.Tensor, torch.Tensor], torch.Tensor
  ]:
      """One-step forward hypotheses.
  
      Args:
          hyps: Hypotheses.
          states: Decoder hidden states. ((N, B, D_dec), (N, B, D_dec))
          cache: Pairs of (dec_out, dec_states) for each label sequences. (keys)
          use_lm: Whether to compute label ID sequences for LM.
  
      Returns:
          dec_out: Decoder output sequences. (B, D_dec)
          dec_states: Decoder hidden states. ((N, B, D_dec), (N, B, D_dec))
          lm_labels: Label ID sequences for LM. (B,)
  
      """
      final_batch = len(hyps)
  
      process = []
      done = [None] * final_batch
  
      for i, hyp in enumerate(hyps):
          str_labels = "_".join(list(map(str, hyp.yseq)))
  
          if str_labels in cache:
              done[i] = cache[str_labels]
          else:
              process.append((str_labels, hyp.yseq[-1], hyp.dec_state))
  
      if process:
          labels = torch.LongTensor(
              [[p[1]] for p in process], device=self.device
          )
          p_dec_states = self.create_batch_states(
              self.init_state(labels.size(0)), [p[2] for p in process]
          )
  
          dec_emb = self.embed(labels)
          dec_out, new_states = self.rnn_forward(dec_emb, p_dec_states)
  
      j = 0
      for i in range(final_batch):
          if done[i] is None:
              state = self.select_state(new_states, j)
  
              done[i] = (dec_out[j], state)
              cache[process[j][0]] = (dec_out[j], state)
  
              j += 1
  
      dec_out = torch.cat([d[0] for d in done], dim=0)
      dec_states = self.create_batch_states(
          dec_states, [d[1] for d in done]
      )
  
      if use_lm:
          lm_labels = torch.LongTensor(
              [h.yseq[-1] for h in hyps], device=self.device
          ).view(final_batch, 1)
  
          return dec_out, dec_states, lm_labels
  
      return dec_out, dec_states, None
  
file_path: espnet/espnet2/asr/decoder/transducer_decoder.py
imports: from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.asr.transducer.beam_search_transducer import ExtendedHypothesis, Hypothesis
label_desc: Use image node_id 7 for calling the TransducerDecoder obj's underlying member method code with example usage: obj.batch_score(hyps, dec_states, cache, use_lm) and returns: dec_out,  dec_states,  None, dec_out,  dec_states,  lm_labels