class_docstr: Encoder decoder CTC-based models with Byte Pair Encoding.
code: def __init__(self, cfg: DictConfig, 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)
  
      if "tokenizer" not in cfg:
          raise ValueError(
              "`cfg` must have `tokenizer` config to create a tokenizer !"
          )
  
      # 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):
          # sidestepping the potential overlapping tokens issue in aggregate tokenizers
          if self.tokenizer_type == "agg":
              cfg.decoder.vocabulary = ListConfig(vocabulary)
          else:
              cfg.decoder.vocabulary = ListConfig(
                  list(vocabulary.keys())
              )
  
      # Override number of classes if placeholder provided
      num_classes = cfg.decoder["num_classes"]
  
      if num_classes < 1:
          logging.info(
              "\nReplacing placeholder number of classes ({}) with actual number of classes - {}".format(
                  num_classes, len(vocabulary)
              )
          )
          cfg.decoder["num_classes"] = len(vocabulary)
  
      super().__init__(cfg=cfg, trainer=trainer)
  
      # Setup decoding objects
      decoding_cfg = self.cfg.get("decoding", None)
  
      # In case decoding config not found, use default config
      if decoding_cfg is None:
          decoding_cfg = OmegaConf.structured(CTCBPEDecodingConfig)
          with open_dict(self.cfg):
              self.cfg.decoding = decoding_cfg
  
      self.decoding = CTCBPEDecoding(
          self.cfg.decoding, tokenizer=self.tokenizer
      )
  
      # Setup metric with decoding strategy
      self.wer = WER(
          decoding=self.decoding,
          use_cer=self._cfg.get("use_cer", False),
          dist_sync_on_step=True,
          log_prediction=self._cfg.get("log_prediction", False),
      )
  
imports: import copy
  import os
  from typing import Dict, List, Optional, Union
  import torch
  from omegaconf import DictConfig, ListConfig, OmegaConf, open_dict
  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.metrics.wer import WER
  from nemo.collections.asr.models.ctc_models import EncDecCTCModel
  from nemo.collections.asr.parts.mixins import ASRBPEMixin
  from nemo.collections.asr.parts.submodules.ctc_decoding import CTCBPEDecoding, CTCBPEDecodingConfig
  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 EncDecCTCModelBPE object from inherited base classes: EncDecCTCModel, ASRBPEMixin with example: obj = EncDecCTCModelBPE(cfg, trainer)