class_docstr: Transducer tasks module.
docstr: Initialize module for Transducer tasks.
  
  Args:
      encoder_dim: Encoder outputs dimension.
      decoder_dim: Decoder outputs dimension.
      joint_dim: Joint space dimension.
      output_dim: Output dimension.
      joint_activation_type: Type of activation for joint network.
      transducer_loss_weight: Weight for main transducer loss.
      ctc_loss: Compute CTC loss.
      ctc_loss_weight: Weight of CTC loss.
      ctc_loss_dropout_rate: Dropout rate for CTC loss inputs.
      lm_loss: Compute LM loss.
      lm_loss_weight: Weight of LM loss.
      lm_loss_smoothing_rate: Smoothing rate for LM loss' label smoothing.
      aux_transducer_loss: Compute auxiliary transducer loss.
      aux_transducer_loss_weight: Weight of auxiliary transducer loss.
      aux_transducer_loss_mlp_dim: Hidden dimension for aux. transducer MLP.
      aux_trans_loss_mlp_dropout_rate: Dropout rate for aux. transducer MLP.
      symm_kl_div_loss: Compute KL divergence loss.
      symm_kl_div_loss_weight: Weight of KL divergence loss.
      fastemit_lambda: Regularization parameter for FastEmit.
      blank_id: Blank symbol ID.
      ignore_id: Padding symbol ID.
      training: Whether the model was initializated in training or inference mode.
docstr_tok: ["Initialize","module","for","Transducer","tasks",".","Args",":","encoder_dim",":","Encoder","outputs","dimension",".","decoder_dim",":","Decoder","outputs","dimension",".","joint_dim",":","Joint","space","dimension",".","output_dim",":","Output","dimension",".","joint_activation_type",":","Type","of","activation","for","joint","network",".","transducer_loss_weight",":","Weight","for","main","transducer","loss",".","ctc_loss",":","Compute","CTC","loss",".","ctc_loss_weight",":","Weight","of","CTC","loss",".","ctc_loss_dropout_rate",":","Dropout","rate","for","CTC","loss","inputs",".","lm_loss",":","Compute","LM","loss",".","lm_loss_weight",":","Weight","of","LM","loss",".","lm_loss_smoothing_rate",":","Smoothing","rate","for","LM","loss","'","label","smoothing",".","aux_transducer_loss",":","Compute","auxiliary","transducer","loss",".","aux_transducer_loss_weight",":","Weight","of","auxiliary","transducer","loss",".","aux_transducer_loss_mlp_dim",":","Hidden","dimension","for","aux",".","transducer","MLP",".","aux_trans_loss_mlp_dropout_rate",":","Dropout","rate","for","aux",".","transducer","MLP",".","symm_kl_div_loss",":","Compute","KL","divergence","loss",".","symm_kl_div_loss_weight",":","Weight","of","KL","divergence","loss",".","fastemit_lambda",":","Regularization","parameter","for","FastEmit",".","blank_id",":","Blank","symbol","ID",".","ignore_id",":","Padding","symbol","ID",".","training",":","Whether","the","model","was","initializated","in","training","or","inference","mode","."]
code: def __init__(
      self,
      encoder_dim: int,
      decoder_dim: int,
      joint_dim: int,
      output_dim: int,
      joint_activation_type: str = "tanh",
      transducer_loss_weight: float = 1.0,
      ctc_loss: bool = False,
      ctc_loss_weight: float = 0.5,
      ctc_loss_dropout_rate: float = 0.0,
      lm_loss: bool = False,
      lm_loss_weight: float = 0.5,
      lm_loss_smoothing_rate: float = 0.0,
      aux_transducer_loss: bool = False,
      aux_transducer_loss_weight: float = 0.2,
      aux_transducer_loss_mlp_dim: int = 320,
      aux_trans_loss_mlp_dropout_rate: float = 0.0,
      symm_kl_div_loss: bool = False,
      symm_kl_div_loss_weight: float = 0.2,
      fastemit_lambda: float = 0.0,
      blank_id: int = 0,
      ignore_id: int = -1,
      training: bool = False,
  ):
      """Initialize module for Transducer tasks.
  
      Args:
          encoder_dim: Encoder outputs dimension.
          decoder_dim: Decoder outputs dimension.
          joint_dim: Joint space dimension.
          output_dim: Output dimension.
          joint_activation_type: Type of activation for joint network.
          transducer_loss_weight: Weight for main transducer loss.
          ctc_loss: Compute CTC loss.
          ctc_loss_weight: Weight of CTC loss.
          ctc_loss_dropout_rate: Dropout rate for CTC loss inputs.
          lm_loss: Compute LM loss.
          lm_loss_weight: Weight of LM loss.
          lm_loss_smoothing_rate: Smoothing rate for LM loss' label smoothing.
          aux_transducer_loss: Compute auxiliary transducer loss.
          aux_transducer_loss_weight: Weight of auxiliary transducer loss.
          aux_transducer_loss_mlp_dim: Hidden dimension for aux. transducer MLP.
          aux_trans_loss_mlp_dropout_rate: Dropout rate for aux. transducer MLP.
          symm_kl_div_loss: Compute KL divergence loss.
          symm_kl_div_loss_weight: Weight of KL divergence loss.
          fastemit_lambda: Regularization parameter for FastEmit.
          blank_id: Blank symbol ID.
          ignore_id: Padding symbol ID.
          training: Whether the model was initializated in training or inference mode.
  
      """
      super().__init__()
  
      if not training:
          ctc_loss, lm_loss, aux_transducer_loss, symm_kl_div_loss = (
              False,
              False,
              False,
              False,
          )
  
      self.joint_network = JointNetwork(
          output_dim,
          encoder_dim,
          decoder_dim,
          joint_dim,
          joint_activation_type,
      )
  
      if training:
          from warprnnt_pytorch import RNNTLoss
  
          self.transducer_loss = RNNTLoss(
              blank=blank_id,
              reduction="sum",
              fastemit_lambda=fastemit_lambda,
          )
  
      if ctc_loss:
          self.ctc_lin = torch.nn.Linear(encoder_dim, output_dim)
  
          self.ctc_loss = torch.nn.CTCLoss(
              blank=blank_id,
              reduction="none",
              zero_infinity=True,
          )
  
      if aux_transducer_loss:
          self.mlp = torch.nn.Sequential(
              torch.nn.Linear(encoder_dim, aux_transducer_loss_mlp_dim),
              torch.nn.LayerNorm(aux_transducer_loss_mlp_dim),
              torch.nn.Dropout(p=aux_trans_loss_mlp_dropout_rate),
              torch.nn.ReLU(),
              torch.nn.Linear(aux_transducer_loss_mlp_dim, joint_dim),
          )
  
          if symm_kl_div_loss:
              self.kl_div = torch.nn.KLDivLoss(reduction="sum")
  
      if lm_loss:
          self.lm_lin = torch.nn.Linear(decoder_dim, output_dim)
  
          self.label_smoothing_loss = LabelSmoothingLoss(
              output_dim,
              ignore_id,
              lm_loss_smoothing_rate,
              normalize_length=False,
          )
  
      self.output_dim = output_dim
  
      self.transducer_loss_weight = transducer_loss_weight
  
      self.use_ctc_loss = ctc_loss
      self.ctc_loss_weight = ctc_loss_weight
      self.ctc_dropout_rate = ctc_loss_dropout_rate
  
      self.use_lm_loss = lm_loss
      self.lm_loss_weight = lm_loss_weight
  
      self.use_aux_transducer_loss = aux_transducer_loss
      self.aux_transducer_loss_weight = aux_transducer_loss_weight
  
      self.use_symm_kl_div_loss = symm_kl_div_loss
      self.symm_kl_div_loss_weight = symm_kl_div_loss_weight
  
      self.blank_id = blank_id
      self.ignore_id = ignore_id
  
      self.target = None
  
file_path: espnet/espnet/nets/pytorch_backend/transducer/transducer_tasks.py
imports: from typing import Any, List, Optional, Tuple
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
  from espnet.nets.pytorch_backend.transducer.joint_network import JointNetwork
  from espnet.nets.pytorch_backend.transformer.label_smoothing_loss import LabelSmoothingLoss
label_desc: Use image node_id 1 to create a new TransducerTasks object from inherited base classes: torch.nn with example: obj = TransducerTasks(encoder_dim, decoder_dim, joint_dim, output_dim, joint_activation_type, transducer_loss_weight, ctc_loss, ctc_loss_weight, ctc_loss_dropout_rate, lm_loss, lm_loss_weight, lm_loss_smoothing_rate, aux_transducer_loss, aux_transducer_loss_weight, aux_transducer_loss_mlp_dim, aux_trans_loss_mlp_dropout_rate, symm_kl_div_loss, symm_kl_div_loss_weight, fastemit_lambda, blank_id, ignore_id, training)