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"]
docstr: Load model from pretrained ASR and TTS models
  Args:
      asr_model_path: path to .nemo ASR model checkpoint
      tts_model_path: path to .nemo TTS model checkpoint
      enhancer_model_path: path to .nemo enhancer model checkpoint
      asr_model_fuse_bn: automatically fuse batchnorm layers in ASR model
      cfg: optional config for hybrid model
      trainer: Pytorch-Lightning trainer
  
  Returns:
      ASRWithTTSModel instance
docstr_tok: ["Load","model","from","pretrained","ASR","and","TTS","models","Args",":","asr_model_path",":","path","to",".nemo","ASR","model","checkpoint","tts_model_path",":","path","to",".nemo","TTS","model","checkpoint","enhancer_model_path",":","path","to",".nemo","enhancer","model","checkpoint","asr_model_fuse_bn",":","automatically","fuse","batchnorm","layers","in","ASR","model","cfg",":","optional","config","for","hybrid","model","trainer",":","Pytorch-Lightning","trainer","Returns",":","ASRWithTTSModel","instance"]
code: def from_pretrained_models(
      cls,
      asr_model_path: Union[str, Path],
      tts_model_path: Union[str, Path],
      enhancer_model_path: Optional[Union[str, Path]] = None,
      asr_model_fuse_bn: bool = False,
      cfg: Optional[DictConfig] = None,
      trainer: Optional[Trainer] = None,
  ):
      """
      Load model from pretrained ASR and TTS models
      Args:
          asr_model_path: path to .nemo ASR model checkpoint
          tts_model_path: path to .nemo TTS model checkpoint
          enhancer_model_path: path to .nemo enhancer model checkpoint
          asr_model_fuse_bn: automatically fuse batchnorm layers in ASR model
          cfg: optional config for hybrid model
          trainer: Pytorch-Lightning trainer
  
      Returns:
          ASRWithTTSModel instance
      """
      if cfg is None:
          cfg = DictConfig(
              dict(
                  asr_model_path=f"{asr_model_path}",
                  asr_model=None,
                  tts_model_path=f"{tts_model_path}",
                  tts_model=None,
                  enhancer_model_path=f"{enhancer_model_path}"
                  if enhancer_model_path is not None
                  else None,
                  enhancer_model=None,
                  asr_model_type=None,
                  asr_model_fuse_bn=asr_model_fuse_bn,
                  train_ds=None,
                  validation_ds=None,
                  test_ds=None,
                  optim=None,
              )
          )
      else:
          cfg = copy.deepcopy(
              cfg
          )  # copy to avoid modifying original config
          cfg.tts_model_path = f"{tts_model_path}"
          cfg.asr_model_path = f"{asr_model_path}"
          cfg.enhancer_model_path = (
              f"{enhancer_model_path}"
              if enhancer_model_path is not None
              else None
          )
      return ASRWithTTSModel(cfg, trainer=trainer)
  
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 5 for calling the ASRWithTTSModel obj's underlying member method code with example usage: obj.from_pretrained_models(cls, asr_model_path, tts_model_path, enhancer_model_path, asr_model_fuse_bn, cfg, trainer) and returns: ASRWithTTSModel