class_docstr: Hybrid ASR-TTS model: a transparent wrapper for ASR model
  with frozen text-to-spectrogram pretrained model, which allows to use text-only data for training/finetuning
  Text-only data can be mixed with audio-text pairs
class_docstr_tok: ["Hybrid","ASR-TTS","model",":","a","transparent","wrapper","for","ASR","model","with","frozen","text-to-spectrogram","pretrained","model",",","which","allows","to","use","text-only","data","for","training\/finetuning","Text-only","data","can","be","mixed","with","audio-text","pairs"]
code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      self._full_init_guard = False
  
      self._check_config(cfg)  # check all required keys are in config
  
      # setup datasets and optimizer after model is fully initialized
      # since it's done automatically, remove options from config
      cfg = copy.deepcopy(
          cfg
      )  # copy to avoid modifying original config
      with open_dict(cfg):
          train_ds_cfg = cfg.pop("train_ds", None)
          validation_ds_cfg = cfg.pop("validation_ds", None)
          test_ds_cfg = cfg.pop("test_ds", None)
          optim_cfg = cfg.pop("optim", None)
  
      super().__init__(cfg, trainer=trainer)
  
      # tts model
      if cfg.tts_model is not None:
          self.register_nemo_submodule(
              "tts_model",
              config_field="tts_model",
              model=FastPitchModel(cfg.tts_model),
          )
      else:
          if cfg.tts_model_path is None:
              raise NeMoBaseException(
                  "Either tts_model or tts_model_path should be provided"
              )
          self.register_nemo_submodule(
              "tts_model",
              config_field="tts_model",
              model=FastPitchModel.restore_from(
                  f"{cfg.tts_model_path}",
                  map_location=torch.device("cpu"),
              ),
          )
      self.tts_model.freeze()  # tts model should be always frozen
  
      if cfg.asr_model is not None:
          self.asr_model_type = self.ASRModelTypes(
              cfg.asr_model_type
          )  # convert to enum
          self.register_nemo_submodule(
              "asr_model",
              config_field="asr_model",
              model=self.asr_model_type.get_asr_cls()(cfg.asr_model),
          )
      else:
          if cfg.asr_model_path is None:
              raise NeMoBaseException(
                  "Either asr_model or asr_model_path should be provided"
              )
          self.register_nemo_submodule(
              "asr_model",
              config_field="asr_model",
              model=ASRModel.restore_from(
                  f"{cfg.asr_model_path}",
                  map_location=torch.device("cpu"),
              ),
          )
          self.asr_model_type = self.ASRModelTypes.from_asr_model(
              self.asr_model
          )
          self.cfg.asr_model_type = (
              f"{self.asr_model_type}"  # save to config
          )
  
          # replace BatchNorm with FusedBatchNorm
      if cfg.asr_model_fuse_bn:
          _fuse_bn_in_conformer(self.asr_model)
          self.cfg.asr_model_fuse_bn = False  # no need to fuse anymore
  
      if cfg.enhancer_model is not None:
          self.register_nemo_submodule(
              "enhancer_model",
              config_field="enhancer_model",
              model=SpectrogramEnhancerModel(cfg.enhancer_model),
          )
      elif cfg.enhancer_model_path is not None:
          self.register_nemo_submodule(
              "enhancer_model",
              config_field="enhancer_model",
              model=SpectrogramEnhancerModel.restore_from(
                  cfg.enhancer_model_path,
                  map_location=torch.device("cpu"),
              ),
          )
      else:
          self.enhancer_model = None
  
      self._full_init_guard = True
  
      # initialize optimizer and datasets, asr/tts models are initialized here
      if optim_cfg:
          with open_dict(self.cfg):
              self.cfg.optim = optim_cfg
          self.setup_optimization(optim_config=optim_cfg)
      if train_ds_cfg:
          with open_dict(self.cfg):
              self.cfg.train_ds = train_ds_cfg
          self.setup_training_data(train_data_config=train_ds_cfg)
      if validation_ds_cfg:
          with open_dict(self.cfg):
              self.cfg.validation_ds = validation_ds_cfg
          self.setup_multiple_validation_data(
              val_data_config=validation_ds_cfg
          )
      if test_ds_cfg:
          with open_dict(self.cfg):
              self.cfg.test_ds = test_ds_cfg
          self.setup_test_data(test_data_config=test_ds_cfg)
  
imports: import copy
  import itertools
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple, Union, cast
  import torch
  from omegaconf import MISSING, DictConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from torch.nn.utils.rnn import pad_sequence
  from nemo.collections.asr.data.audio_to_text_dali import DALIOutputs
  from nemo.collections.asr.data.audio_to_text_dataset import get_audio_to_text_bpe_dataset_from_config
  from nemo.collections.asr.data.text_to_text import TextOrAudioToTextBatch, TextToTextBatch, TextToTextDataset, TextToTextIterableDataset
  from nemo.collections.asr.models.asr_model import ASRModel
  from nemo.collections.asr.models.ctc_bpe_models import EncDecCTCModelBPE
  from nemo.collections.asr.models.hybrid_rnnt_ctc_bpe_models import EncDecHybridRNNTCTCBPEModel
  from nemo.collections.asr.models.rnnt_bpe_models import EncDecRNNTBPEModel
  from nemo.collections.asr.modules.conformer_encoder import ConformerEncoder
  from nemo.collections.asr.parts.preprocessing.features import clean_spectrogram_batch, normalize_batch
  from nemo.collections.asr.parts.submodules.batchnorm import replace_bn_with_fused_bn_all
  from nemo.collections.common.data import ConcatDataset, ConcatMapDataset
  from nemo.collections.tts.models import FastPitchModel, SpectrogramEnhancerModel
  from nemo.core.classes import Dataset, typecheck
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
  from nemo.utils.enum import PrettyStrEnum
  from nemo.utils.exceptions import NeMoBaseException
label_desc: Use image node_id 3 to create a new ASRWithTTSModel object from inherited base classes: ASRModel with example: obj = ASRWithTTSModel(cfg, trainer)