class_docstr: Base class for encoder decoder CTC-based models.
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      # Get global rank and total number of GPU workers for IterableDataset partitioning, if applicable
      # Global_rank and local_rank is set by LightningModule in Lightning 1.2.0
      self.world_size = 1
      if trainer is not None:
          self.world_size = trainer.world_size
  
      super().__init__(cfg=cfg, trainer=trainer)
      self.preprocessor = EncDecCTCModel.from_config_dict(
          self._cfg.preprocessor
      )
      self.encoder = EncDecCTCModel.from_config_dict(self._cfg.encoder)
  
      with open_dict(self._cfg):
          if "feat_in" not in self._cfg.decoder or (
              not self._cfg.decoder.feat_in
              and hasattr(self.encoder, "_feat_out")
          ):
              self._cfg.decoder.feat_in = self.encoder._feat_out
          if (
              "feat_in" not in self._cfg.decoder
              or not self._cfg.decoder.feat_in
          ):
              raise ValueError(
                  "param feat_in of the decoder's config is not set!"
              )
  
          if (
              self.cfg.decoder.num_classes < 1
              and self.cfg.decoder.vocabulary is not None
          ):
              logging.info(
                  "\nReplacing placeholder number of classes ({}) with actual number of classes - {}".format(
                      self.cfg.decoder.num_classes,
                      len(self.cfg.decoder.vocabulary),
                  )
              )
              cfg.decoder["num_classes"] = len(
                  self.cfg.decoder.vocabulary
              )
  
      self.decoder = EncDecCTCModel.from_config_dict(self._cfg.decoder)
  
      self.loss = CTCLoss(
          num_classes=self.decoder.num_classes_with_blank - 1,
          zero_infinity=True,
          reduction=self._cfg.get("ctc_reduction", "mean_batch"),
      )
  
      if (
          hasattr(self._cfg, "spec_augment")
          and self._cfg.spec_augment is not None
      ):
          self.spec_augmentation = EncDecCTCModel.from_config_dict(
              self._cfg.spec_augment
          )
      else:
          self.spec_augmentation = None
  
      # 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(CTCDecodingConfig)
          with open_dict(self.cfg):
              self.cfg.decoding = decoding_cfg
  
      self.decoding = CTCDecoding(
          self.cfg.decoding,
          vocabulary=OmegaConf.to_container(self.decoder.vocabulary),
      )
  
      # 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),
      )
  
      # Setup optional Optimization flags
      self.setup_optimization_flags()
  
      # setting up interCTC loss (from InterCTCMixin)
      self.setup_interctc(
          decoder_name="decoder", loss_name="loss", wer_name="wer"
      )
  
      # Adapter modules setup (from ASRAdapterModelMixin)
      self.setup_adapters()
  
imports: import copy
  import json
  import os
  import tempfile
  from math import ceil
  from typing import Dict, List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from tqdm.auto import tqdm
  from nemo.collections.asr.data import audio_to_text_dataset
  from nemo.collections.asr.data.audio_to_text_dali import AudioToCharDALIDataset, DALIOutputs
  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.asr_model import ASRModel, ExportableEncDecModel
  from nemo.collections.asr.parts.mixins import ASRModuleMixin, InterCTCMixin
  from nemo.collections.asr.parts.submodules.ctc_decoding import CTCDecoding, CTCDecodingConfig
  from nemo.collections.asr.parts.utils.audio_utils import ChannelSelectorType
  from nemo.collections.common.data.lhotse import get_lhotse_dataloader_from_config
  from nemo.collections.common.parts.preprocessing.parsers import make_parser
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.classes.mixins import AccessMixin
  from nemo.core.neural_types import AudioSignal, LabelsType, LengthsType, LogprobsType, NeuralType, SpectrogramType
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new EncDecCTCModel object from inherited base classes: ASRModel, ExportableEncDecModel, ASRModuleMixin, InterCTCMixin with example: obj = EncDecCTCModel(cfg, trainer)