class_docstr: E2E module for Transducer models.
  
  Args:
      idim: Dimension of inputs.
      odim: Dimension of outputs.
      args: Namespace containing model options.
      ignore_id: Padding symbol ID.
      blank_id: Blank symbol ID.
      training: Whether the model is initialized in training or inference mode.
class_docstr_tok: ["E2E","module","for","Transducer","models",".","Args",":","idim",":","Dimension","of","inputs",".","odim",":","Dimension","of","outputs",".","args",":","Namespace","containing","model","options",".","ignore_id",":","Padding","symbol","ID",".","blank_id",":","Blank","symbol","ID",".","training",":","Whether","the","model","is","initialized","in","training","or","inference","mode","."]
docstr: Construct an E2E object for Transducer model.
docstr_tok: ["Construct","an","E2E","object","for","Transducer","model","."]
code: def __init__(
      self,
      idim: int,
      odim: int,
      args: Namespace,
      ignore_id: int = -1,
      blank_id: int = 0,
      training: bool = True,
  ):
      """Construct an E2E object for Transducer model."""
      torch.nn.Module.__init__(self)
  
      args = fill_missing_args(args, self.add_arguments)
  
      self.is_transducer = True
  
      self.use_auxiliary_enc_outputs = (
          True if (training and args.use_aux_transducer_loss) else False
      )
  
      self.subsample = get_subsample(
          args,
          mode="asr",
          arch="transformer" if args.etype == "custom" else "rnn-t",
      )
  
      if self.use_auxiliary_enc_outputs:
          n_layers = (
              ((len(args.enc_block_arch) * args.enc_block_repeat) - 1)
              if args.enc_block_arch is not None
              else (args.elayers - 1)
          )
  
          aux_enc_output_layers = valid_aux_encoder_output_layers(
              args.aux_transducer_loss_enc_output_layers,
              n_layers,
              args.use_symm_kl_div_loss,
              self.subsample,
          )
      else:
          aux_enc_output_layers = []
  
      if args.etype == "custom":
          if args.enc_block_arch is None:
              raise ValueError(
                  "When specifying custom encoder type, --enc-block-arch"
                  "should be set in training config."
              )
  
          self.encoder = CustomEncoder(
              idim,
              args.enc_block_arch,
              args.custom_enc_input_layer,
              repeat_block=args.enc_block_repeat,
              self_attn_type=args.custom_enc_self_attn_type,
              positional_encoding_type=args.custom_enc_positional_encoding_type,
              positionwise_activation_type=args.custom_enc_pw_activation_type,
              conv_mod_activation_type=args.custom_enc_conv_mod_activation_type,
              aux_enc_output_layers=aux_enc_output_layers,
              input_layer_dropout_rate=args.custom_enc_input_dropout_rate,
              input_layer_pos_enc_dropout_rate=(
                  args.custom_enc_input_pos_enc_dropout_rate
              ),
          )
          encoder_out = self.encoder.enc_out
      else:
          self.enc = encoder_for(
              args,
              idim,
              self.subsample,
              aux_enc_output_layers=aux_enc_output_layers,
          )
          encoder_out = args.eprojs
  
      if args.dtype == "custom":
          if args.dec_block_arch is None:
              raise ValueError(
                  "When specifying custom decoder type, --dec-block-arch"
                  "should be set in training config."
              )
  
          self.decoder = CustomDecoder(
              odim,
              args.dec_block_arch,
              args.custom_dec_input_layer,
              repeat_block=args.dec_block_repeat,
              positionwise_activation_type=args.custom_dec_pw_activation_type,
              input_layer_dropout_rate=args.dropout_rate_embed_decoder,
              blank_id=blank_id,
          )
          decoder_out = self.decoder.dunits
      else:
          self.dec = RNNDecoder(
              odim,
              args.dtype,
              args.dlayers,
              args.dunits,
              args.dec_embed_dim,
              dropout_rate=args.dropout_rate_decoder,
              dropout_rate_embed=args.dropout_rate_embed_decoder,
              blank_id=blank_id,
          )
          decoder_out = args.dunits
  
      self.transducer_tasks = TransducerTasks(
          encoder_out,
          decoder_out,
          args.joint_dim,
          odim,
          joint_activation_type=args.joint_activation_type,
          transducer_loss_weight=args.transducer_weight,
          ctc_loss=args.use_ctc_loss,
          ctc_loss_weight=args.ctc_loss_weight,
          ctc_loss_dropout_rate=args.ctc_loss_dropout_rate,
          lm_loss=args.use_lm_loss,
          lm_loss_weight=args.lm_loss_weight,
          lm_loss_smoothing_rate=args.lm_loss_smoothing_rate,
          aux_transducer_loss=args.use_aux_transducer_loss,
          aux_transducer_loss_weight=args.aux_transducer_loss_weight,
          aux_transducer_loss_mlp_dim=args.aux_transducer_loss_mlp_dim,
          aux_trans_loss_mlp_dropout_rate=args.aux_transducer_loss_mlp_dropout_rate,
          symm_kl_div_loss=args.use_symm_kl_div_loss,
          symm_kl_div_loss_weight=args.symm_kl_div_loss_weight,
          fastemit_lambda=args.fastemit_lambda,
          blank_id=blank_id,
          ignore_id=ignore_id,
          training=training,
      )
  
      if training and (args.report_cer or args.report_wer):
          self.error_calculator = ErrorCalculator(
              self.decoder if args.dtype == "custom" else self.dec,
              self.transducer_tasks.joint_network,
              args.char_list,
              args.sym_space,
              args.sym_blank,
              args.report_cer,
              args.report_wer,
          )
      else:
          self.error_calculator = None
  
      self.etype = args.etype
      self.dtype = args.dtype
  
      self.sos = odim - 1
      self.eos = odim - 1
      self.blank_id = blank_id
      self.ignore_id = ignore_id
  
      self.space = args.sym_space
      self.blank = args.sym_blank
  
      self.odim = odim
  
      self.reporter = Reporter()
  
      self.default_parameters(args)
  
      self.loss = None
      self.rnnlm = None
  
imports: import logging
  import math
  from argparse import ArgumentParser, Namespace
  from dataclasses import asdict
  from typing import List
  import chainer
  import numpy
  import torch
  from espnet.nets.asr_interface import ASRInterface
  from espnet.nets.beam_search_transducer import BeamSearchTransducer
  from espnet.nets.pytorch_backend.nets_utils import get_subsample, make_non_pad_mask
  from espnet.nets.pytorch_backend.transducer.arguments import add_auxiliary_task_arguments, add_custom_decoder_arguments, add_custom_encoder_arguments, add_custom_training_arguments, add_decoder_general_arguments, add_encoder_general_arguments, add_rnn_decoder_arguments, add_rnn_encoder_arguments, add_transducer_arguments
  from espnet.nets.pytorch_backend.transducer.custom_decoder import CustomDecoder
  from espnet.nets.pytorch_backend.transducer.custom_encoder import CustomEncoder
  from espnet.nets.pytorch_backend.transducer.error_calculator import ErrorCalculator
  from espnet.nets.pytorch_backend.transducer.initializer import initializer
  from espnet.nets.pytorch_backend.transducer.rnn_decoder import RNNDecoder
  from espnet.nets.pytorch_backend.transducer.rnn_encoder import encoder_for
  from espnet.nets.pytorch_backend.transducer.transducer_tasks import TransducerTasks
  from espnet.nets.pytorch_backend.transducer.utils import get_decoder_input, valid_aux_encoder_output_layers
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention, RelPositionMultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.mask import target_mask
  from espnet.nets.pytorch_backend.transformer.plot import PlotAttentionReport
  from espnet.utils.fill_missing_args import fill_missing_args
label_desc: Use image node_id 13 to create a new E2E object from inherited base classes: ASRInterface, torch.nn with example: obj = E2E(idim, odim, args, ignore_id, blank_id, training)