class_docstr: ESPnet2ASRTransducerModel module definition.
  
  Args:
      vocab_size: Size of complete vocabulary (w/ SOS/EOS and blank included).
      token_list: List of tokens in vocabulary (minus reserved tokens).
      frontend: Frontend module.
      specaug: SpecAugment module.
      normalize: Normalization module.
      encoder: Encoder module.
      decoder: Decoder module.
      joint_network: Joint Network module.
      transducer_weight: Weight of the Transducer loss.
      use_k2_pruned_loss: Whether to use k2 pruned Transducer loss.
      k2_pruned_loss_args: Arguments of the k2 loss pruned Transducer loss.
      warmup_steps: Number of steps in warmup, used for pruned loss scaling.
      validation_nstep: Maximum number of symbol expansions at each time step
                        when reporting CER or/and WER using mAES.
      fastemit_lambda: FastEmit lambda value.
      auxiliary_ctc_weight: Weight of auxiliary CTC loss.
      auxiliary_ctc_dropout_rate: Dropout rate for auxiliary CTC loss inputs.
      auxiliary_lm_loss_weight: Weight of auxiliary LM loss.
      auxiliary_lm_loss_smoothing: Smoothing rate for LM loss' label smoothing.
      ignore_id: Initial padding ID.
      sym_space: Space symbol.
      sym_blank: Blank Symbol.
      report_cer: Whether to report Character Error Rate during validation.
      report_wer: Whether to report Word Error Rate during validation.
      extract_feats_in_collect_stats: Whether to use extract_feats stats collection.
class_docstr_tok: ["ESPnet2ASRTransducerModel","module","definition",".","Args",":","vocab_size",":","Size","of","complete","vocabulary","(","w\/","SOS\/EOS","and","blank","included",")",".","token_list",":","List","of","tokens","in","vocabulary","(","minus","reserved","tokens",")",".","frontend",":","Frontend","module",".","specaug",":","SpecAugment","module",".","normalize",":","Normalization","module",".","encoder",":","Encoder","module",".","decoder",":","Decoder","module",".","joint_network",":","Joint","Network","module",".","transducer_weight",":","Weight","of","the","Transducer","loss",".","use_k2_pruned_loss",":","Whether","to","use","k2","pruned","Transducer","loss",".","k2_pruned_loss_args",":","Arguments","of","the","k2","loss","pruned","Transducer","loss",".","warmup_steps",":","Number","of","steps","in","warmup",",","used","for","pruned","loss","scaling",".","validation_nstep",":","Maximum","number","of","symbol","expansions","at","each","time","step","when","reporting","CER","or\/and","WER","using","mAES",".","fastemit_lambda",":","FastEmit","lambda","value",".","auxiliary_ctc_weight",":","Weight","of","auxiliary","CTC","loss",".","auxiliary_ctc_dropout_rate",":","Dropout","rate","for","auxiliary","CTC","loss","inputs",".","auxiliary_lm_loss_weight",":","Weight","of","auxiliary","LM","loss",".","auxiliary_lm_loss_smoothing",":","Smoothing","rate","for","LM","loss","'","label","smoothing",".","ignore_id",":","Initial","padding","ID",".","sym_space",":","Space","symbol",".","sym_blank",":","Blank","Symbol",".","report_cer",":","Whether","to","report","Character","Error","Rate","during","validation",".","report_wer",":","Whether","to","report","Word","Error","Rate","during","validation",".","extract_feats_in_collect_stats",":","Whether","to","use","extract_feats","stats","collection","."]
docstr: Forward architecture and compute loss(es).
  
  Args:
      speech: Speech sequences. (B, S)
      speech_lengths: Speech sequences lengths. (B,)
      text: Label ID sequences. (B, L)
      text_lengths: Label ID sequences lengths. (B,)
      kwargs: Contains "utts_id".
  
  Return:
      loss: Main loss value.
      stats: Task statistics.
      weight: Task weights.
docstr_tok: ["Forward","architecture","and","compute","loss","(","es",")",".","Args",":","speech",":","Speech","sequences",".","(","B",",","S",")","speech_lengths",":","Speech","sequences","lengths",".","(","B",",",")","text",":","Label","ID","sequences",".","(","B",",","L",")","text_lengths",":","Label","ID","sequences","lengths",".","(","B",",",")","kwargs",":","Contains","``","utts_id","''",".","Return",":","loss",":","Main","loss","value",".","stats",":","Task","statistics",".","weight",":","Task","weights","."]
code: def forward(
      self,
      speech: torch.Tensor,
      speech_lengths: torch.Tensor,
      text: torch.Tensor,
      text_lengths: torch.Tensor,
      **kwargs,
  ) -> Tuple[torch.Tensor, Dict[str, torch.Tensor], torch.Tensor]:
      """Forward architecture and compute loss(es).
  
      Args:
          speech: Speech sequences. (B, S)
          speech_lengths: Speech sequences lengths. (B,)
          text: Label ID sequences. (B, L)
          text_lengths: Label ID sequences lengths. (B,)
          kwargs: Contains "utts_id".
  
      Return:
          loss: Main loss value.
          stats: Task statistics.
          weight: Task weights.
  
      """
      assert text_lengths.dim() == 1, text_lengths.shape
      assert (
          speech.shape[0]
          == speech_lengths.shape[0]
          == text.shape[0]
          == text_lengths.shape[0]
      ), (
          speech.shape,
          speech_lengths.shape,
          text.shape,
          text_lengths.shape,
      )
  
      batch_size = speech.shape[0]
      text = text[:, : text_lengths.max()]
  
      # 1. Encoder
      encoder_out, encoder_out_lens = self.encode(
          speech, speech_lengths
      )
  
      # 2. Transducer-related I/O preparation
      decoder_in, target, t_len, u_len = get_transducer_task_io(
          text,
          encoder_out_lens,
          ignore_id=self.ignore_id,
      )
  
      # 3. Decoder
      self.decoder.set_device(encoder_out.device)
      decoder_out = self.decoder(decoder_in)
  
      # 4. Joint Network and RNNT loss computation
      if self.use_k2_pruned_loss:
          loss_trans = self._calc_k2_transducer_pruned_loss(
              encoder_out,
              decoder_out,
              text,
              t_len,
              u_len,
              **self.k2_pruned_loss_args,
          )
      else:
          joint_out = self.joint_network(
              encoder_out.unsqueeze(2), decoder_out.unsqueeze(1)
          )
  
          loss_trans = self._calc_transducer_loss(
              encoder_out,
              joint_out,
              target,
              t_len,
              u_len,
          )
  
      # 5. Auxiliary losses
      loss_ctc, loss_lm = 0.0, 0.0
  
      if self.use_auxiliary_ctc:
          loss_ctc = self._calc_ctc_loss(
              encoder_out,
              target,
              t_len,
              u_len,
          )
  
      if self.use_auxiliary_lm_loss:
          loss_lm = self._calc_lm_loss(decoder_out, target)
  
      loss = (
          self.transducer_weight * loss_trans
          + self.auxiliary_ctc_weight * loss_ctc
          + self.auxiliary_lm_loss_weight * loss_lm
      )
  
      # 6. CER/WER computation.
      if not self.training and (self.report_cer or self.report_wer):
          if self.error_calculator is None:
              from espnet2.asr_transducer.error_calculator import (
                  ErrorCalculator,
              )
  
              if (
                  self.use_k2_pruned_loss
                  and self.k2_loss_type == "modified"
              ):
                  self.validation_nstep = 1
  
              self.error_calculator = ErrorCalculator(
                  self.decoder,
                  self.joint_network,
                  self.token_list,
                  self.sym_space,
                  self.sym_blank,
                  nstep=self.validation_nstep,
                  report_cer=self.report_cer,
                  report_wer=self.report_wer,
              )
  
          cer_transducer, wer_transducer = self.error_calculator(
              encoder_out, target, t_len
          )
      else:
          cer_transducer, wer_transducer = None, None
  
      stats = dict(
          loss=loss.detach(),
          loss_transducer=loss_trans.detach(),
          loss_aux_ctc=loss_ctc.detach() if loss_ctc > 0.0 else None,
          loss_aux_lm=loss_lm.detach() if loss_lm > 0.0 else None,
          cer_transducer=cer_transducer,
          wer_transducer=wer_transducer,
      )
  
      # force_gatherable: to-device and to-tensor if scalar for DataParallel
      loss, stats, weight = force_gatherable(
          (loss, stats, batch_size), loss.device
      )
  
      return loss, stats, weight
  
imports: import logging
  from contextlib import contextmanager
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.encoder.encoder import Encoder
  from espnet2.asr_transducer.joint_network import JointNetwork
  from espnet2.asr_transducer.utils import get_transducer_task_io
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 2 for calling the ESPnetASRTransducerModel obj's underlying member method code with example usage: obj.forward(speech, speech_lengths, text, text_lengths) and returns: loss,  stats,  weight