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: Setup training data from config: text-only, audio-text or mixed data.
docstr_tok: ["Setup","training","data","from","config",":","text-only",",","audio-text","or","mixed","data","."]
code: def setup_training_data(
      self, train_data_config: Optional[Union[DictConfig, Dict]]
  ):
      """
      Setup training data from config: text-only, audio-text or mixed data.
      """
      if train_data_config is None:
          logging.warning("No training data")
          return
  
      self._update_dataset_config(
          dataset_name="train", config=train_data_config
      )
      asr_dataset = get_audio_to_text_bpe_dataset_from_config(
          train_data_config,
          local_rank=self.local_rank,
          global_rank=self.global_rank,
          world_size=self.world_size,
          tokenizer=self.asr_model.tokenizer,
          preprocessor_cfg=self.asr_model.cfg.get("preprocessor", None),
      )
  
      dataset_iterable = True
      if asr_dataset is not None and isinstance(asr_dataset, Dataset):
          # asr_dataset is map-style, for mixing datasets use map-style text-to-text dataset
          dataset_iterable = False
      if train_data_config.get("text_data") is not None:
          tts_dataset = self._setup_text_dataset_from_config(
              train_data_config, iterable=dataset_iterable
          )
      else:
          tts_dataset = None
  
      if tts_dataset and asr_dataset:
          text_data_config: TextDataConfig = cast(
              TextDataConfig,
              OmegaConf.merge(
                  OmegaConf.structured(TextDataConfig),
                  train_data_config.text_data,
              ),
          )
          concat_kwargs = dict()
          if text_data_config.asr_tts_sampling_technique is not None:
              concat_kwargs[
                  "sampling_technique"
              ] = text_data_config.asr_tts_sampling_technique
          if text_data_config.asr_tts_sampling_temperature is not None:
              concat_kwargs[
                  "sampling_temperature"
              ] = text_data_config.asr_tts_sampling_temperature
          if text_data_config.asr_tts_sampling_probabilities:
              concat_kwargs[
                  "sampling_probabilities"
              ] = text_data_config.asr_tts_sampling_probabilities
  
          if dataset_iterable:
              dataset = ConcatDataset(
                  datasets=[asr_dataset, tts_dataset], **concat_kwargs
              )
          else:
              dataset = ConcatMapDataset(
                  datasets=[asr_dataset, tts_dataset], **concat_kwargs
              )
      else:
          dataset = tts_dataset or asr_dataset
  
      if dataset is None:
          return
  
      if tts_dataset:
          collate_fn = tts_dataset.collate_fn
      else:
          if hasattr(asr_dataset, "collate_fn"):
              collate_fn = asr_dataset.collate_fn
          elif hasattr(asr_dataset.datasets[0], "collate_fn"):
              # support datasets that are lists of entries
              collate_fn = asr_dataset.datasets[0].collate_fn
          else:
              # support datasets that are lists of lists
              collate_fn = (
                  asr_dataset.datasets[0].datasets[0].collate_fn
              )
  
      shuffle = (
          train_data_config.get("shuffle", True)
          and not dataset_iterable
      )
      self._train_dl = torch.utils.data.DataLoader(
          dataset=dataset,
          batch_size=train_data_config["batch_size"],
          collate_fn=collate_fn,
          drop_last=train_data_config.get("drop_last", False),
          shuffle=shuffle,
          num_workers=train_data_config.get("num_workers", 0),
          pin_memory=train_data_config.get("pin_memory", False),
      )
  
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 25 for calling the ASRWithTTSModel obj's underlying member method code with example usage: obj.setup_training_data(train_data_config) without return types