class_docstr: Base class for encoder decoder RNNT-based models with auxiliary CTC decoder/loss and subword tokenization.
class_docstr_tok: ["Base","class","for","encoder","decoder","RNNT-based","models","with","auxiliary","CTC","decoder\/loss","and","subword","tokenization","."]
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      # Convert to Hydra 1.0 compatible DictConfig
      cfg = model_utils.convert_model_config_to_dict_config(cfg)
      cfg = model_utils.maybe_update_config_version(cfg)
  
      # Tokenizer is necessary for this model
      if "tokenizer" not in cfg:
          raise ValueError(
              "`cfg` must have `tokenizer` config to create a tokenizer !"
          )
  
      if not isinstance(cfg, DictConfig):
          cfg = OmegaConf.create(cfg)
  
      # Setup the tokenizer
      self._setup_tokenizer(cfg.tokenizer)
  
      # Initialize a dummy vocabulary
      vocabulary = self.tokenizer.tokenizer.get_vocab()
  
      # Set the new vocabulary
      with open_dict(cfg):
          cfg.labels = ListConfig(list(vocabulary))
  
      with open_dict(cfg.decoder):
          cfg.decoder.vocab_size = len(vocabulary)
  
      with open_dict(cfg.joint):
          cfg.joint.num_classes = len(vocabulary)
          cfg.joint.vocabulary = ListConfig(list(vocabulary))
          cfg.joint.jointnet.encoder_hidden = (
              cfg.model_defaults.enc_hidden
          )
          cfg.joint.jointnet.pred_hidden = (
              cfg.model_defaults.pred_hidden
          )
  
      # setup auxiliary CTC decoder
      if "aux_ctc" not in cfg:
          raise ValueError(
              "The config need to have a section for the CTC decoder named as aux_ctc for Hybrid models."
          )
  
      with open_dict(cfg):
          if self.tokenizer_type == "agg":
              cfg.aux_ctc.decoder.vocabulary = ListConfig(vocabulary)
          else:
              cfg.aux_ctc.decoder.vocabulary = ListConfig(
                  list(vocabulary.keys())
              )
  
      if cfg.aux_ctc.decoder["num_classes"] < 1:
          logging.info(
              "\nReplacing placholder number of classes ({}) with actual number of classes - {}".format(
                  cfg.aux_ctc.decoder["num_classes"], len(vocabulary)
              )
          )
          cfg.aux_ctc.decoder["num_classes"] = len(vocabulary)
  
      super().__init__(cfg=cfg, trainer=trainer)
  
      # Setup decoding object
      self.decoding = RNNTBPEDecoding(
          decoding_cfg=self.cfg.decoding,
          decoder=self.decoder,
          joint=self.joint,
          tokenizer=self.tokenizer,
      )
  
      # Setup wer object
      self.wer = WER(
          decoding=self.decoding,
          batch_dim_index=0,
          use_cer=self.cfg.get("use_cer", False),
          log_prediction=self.cfg.get("log_prediction", True),
          dist_sync_on_step=True,
      )
  
      # Setup fused Joint step if flag is set
      if self.joint.fuse_loss_wer:
          self.joint.set_loss(self.loss)
          self.joint.set_wer(self.wer)
  
      # Setup CTC decoding
      ctc_decoding_cfg = self.cfg.aux_ctc.get("decoding", None)
      if ctc_decoding_cfg is None:
          ctc_decoding_cfg = OmegaConf.structured(CTCBPEDecodingConfig)
          with open_dict(self.cfg.aux_ctc):
              self.cfg.aux_ctc.decoding = ctc_decoding_cfg
      self.ctc_decoding = CTCBPEDecoding(
          self.cfg.aux_ctc.decoding, tokenizer=self.tokenizer
      )
  
      # Setup CTC WER
      self.ctc_wer = WER(
          decoding=self.ctc_decoding,
          use_cer=self.cfg.aux_ctc.get("use_cer", False),
          dist_sync_on_step=True,
          log_prediction=self.cfg.get("log_prediction", False),
      )
  
      # setting the RNNT decoder as the default one
      self.cur_decoder = "rnnt"
  
imports: import copy
  import os
  from typing import Dict, List, Optional, Union
  import torch
  from omegaconf import DictConfig, ListConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from nemo.collections.asr.data import audio_to_text_dataset
  from nemo.collections.asr.data.audio_to_text_dali import AudioToBPEDALIDataset
  from nemo.collections.asr.data.audio_to_text_lhotse import LhotseSpeechToTextBpeDataset
  from nemo.collections.asr.losses.ctc import CTCLoss
  from nemo.collections.asr.losses.rnnt import RNNTLoss
  from nemo.collections.asr.metrics.wer import WER
  from nemo.collections.asr.models.hybrid_rnnt_ctc_models import EncDecHybridRNNTCTCModel
  from nemo.collections.asr.parts.mixins import ASRBPEMixin
  from nemo.collections.asr.parts.submodules.ctc_decoding import CTCBPEDecoding, CTCBPEDecodingConfig
  from nemo.collections.asr.parts.submodules.rnnt_decoding import RNNTBPEDecoding, RNNTBPEDecodingConfig
  from nemo.collections.common.data.lhotse import get_lhotse_dataloader_from_config
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 1 to create a new EncDecHybridRNNTCTCBPEModel object from inherited base classes: EncDecHybridRNNTCTCModel, ASRBPEMixin with example: obj = EncDecHybridRNNTCTCBPEModel(cfg, trainer)