class_docstr: Base class for encoder decoder RNNT-based models with subword tokenization.
class_docstr_tok: ["Base","class","for","encoder","decoder","RNNT-based","models","with","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
          )
  
      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)
  
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.rnnt import RNNTLoss
  from nemo.collections.asr.metrics.wer import WER
  from nemo.collections.asr.models.rnnt_models import EncDecRNNTModel
  from nemo.collections.asr.parts.mixins import ASRBPEMixin
  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 2 to create a new EncDecRNNTBPEModel object from inherited base classes: EncDecRNNTModel, ASRBPEMixin with example: obj = EncDecRNNTBPEModel(cfg, trainer)