class_docstr: Class for processing and loading text to speech training examples.
  
  Args:
      dataset_meta: Dict of dataset names (string) to dataset metadata.
      sample_rate: Sample rate to load audio as. If the audio is stored at a different sample rate, then it will
          be resampled.
      text_tokenizer: Tokenizer to apply to the text field.
      weighted_sampling_steps_per_epoch: Optional int, If provided, then data will be sampled (with replacement) based on
          the sample weights provided in the dataset metadata. If None, then sample weights will be ignored.
      speaker_path: Optional, path to JSON file with speaker indices, for multi-speaker training. Can be created with
          scripts.dataset_processing.tts.create_speaker_map.py
      featurizers: Optional, list of featurizers to load feature data from. Should be the same config provided
          when running scripts.dataset_processing.tts.compute_features.py before training.
      feature_processors: Optional, list of feature processors to run on training examples.
      align_prior_hop_length: Optional int, hop length of audio features.
          If provided alignment prior will be calculated and included in batch output. Must match hop length
          of audio features used for training.
      min_duration: Optional float, if provided audio files in the training manifest shorter than 'min_duration'
          will be ignored.
      max_duration: Optional float, if provided audio files in the training manifest longer than 'max_duration'
          will be ignored.
      volume_norm: Whether to apply volume normalization to loaded audio.
class_docstr_tok: ["Class","for","processing","and","loading","text","to","speech","training","examples",".","Args",":","dataset_meta",":","Dict","of","dataset","names","(","string",")","to","dataset","metadata",".","sample_rate",":","Sample","rate","to","load","audio","as",".","If","the","audio","is","stored","at","a","different","sample","rate",",","then","it","will","be","resampled",".","text_tokenizer",":","Tokenizer","to","apply","to","the","text","field",".","weighted_sampling_steps_per_epoch",":","Optional","int",",","If","provided",",","then","data","will","be","sampled","(","with","replacement",")","based","on","the","sample","weights","provided","in","the","dataset","metadata",".","If","None",",","then","sample","weights","will","be","ignored",".","speaker_path",":","Optional",",","path","to","JSON","file","with","speaker","indices",",","for","multi-speaker","training",".","Can","be","created","with","scripts.dataset_processing.tts.create_speaker_map.py","featurizers",":","Optional",",","list","of","featurizers","to","load","feature","data","from",".","Should","be","the","same","config","provided","when","running","scripts.dataset_processing.tts.compute_features.py","before","training",".","feature_processors",":","Optional",",","list","of","feature","processors","to","run","on","training","examples",".","align_prior_hop_length",":","Optional","int",",","hop","length","of","audio","features",".","If","provided","alignment","prior","will","be","calculated","and","included","in","batch","output",".","Must","match","hop","length","of","audio","features","used","for","training",".","min_duration",":","Optional","float",",","if","provided","audio","files","in","the","training","manifest","shorter","than","'min_duration'","will","be","ignored",".","max_duration",":","Optional","float",",","if","provided","audio","files","in","the","training","manifest","longer","than","'max_duration'","will","be","ignored",".","volume_norm",":","Whether","to","apply","volume","normalization","to","loaded","audio","."]
code: def collate_fn(self, batch: List[dict]):
      dataset_name_list = []
      audio_filepath_list = []
      audio_list = []
      audio_len_list = []
      token_list = []
      token_len_list = []
      speaker_list = []
      prior_list = []
  
      for example in batch:
          dataset_name_list.append(example["dataset_name"])
          audio_filepath_list.append(example["audio_filepath"])
  
          audio_list.append(example["audio"])
          audio_len_list.append(example["audio_len"])
  
          token_list.append(example["tokens"])
          token_len_list.append(example["text_len"])
  
          if self.include_speaker:
              speaker_list.append(example["speaker_index"])
  
          if self.include_align_prior:
              prior_list.append(example["align_prior"])
  
      batch_audio_len = torch.IntTensor(audio_len_list)
      audio_max_len = int(batch_audio_len.max().item())
  
      batch_token_len = torch.IntTensor(token_len_list)
      token_max_len = int(batch_token_len.max().item())
  
      batch_audio = stack_tensors(audio_list, max_lens=[audio_max_len])
      batch_tokens = stack_tensors(
          token_list,
          max_lens=[token_max_len],
          pad_value=self.text_tokenizer.pad,
      )
  
      batch_dict = {
          "dataset_names": dataset_name_list,
          "audio_filepaths": audio_filepath_list,
          "audio": batch_audio,
          "audio_lens": batch_audio_len,
          "text": batch_tokens,
          "text_lens": batch_token_len,
      }
  
      if self.include_speaker:
          batch_dict["speaker_id"] = torch.IntTensor(speaker_list)
  
      if self.include_align_prior:
          spec_max_len = max([prior.shape[0] for prior in prior_list])
          text_max_len = max([prior.shape[1] for prior in prior_list])
          batch_dict["align_prior_matrix"] = stack_tensors(
              prior_list,
              max_lens=[text_max_len, spec_max_len],
          )
  
      for featurizer in self.featurizers:
          feature_dict = featurizer.collate_fn(batch)
          batch_dict.update(feature_dict)
  
      return batch_dict
  
imports: import json
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional
  import librosa
  import torch.utils.data
  from nemo.collections.asr.parts.utils.manifest_utils import read_manifest
  from nemo.collections.common.tokenizers.text_to_speech.tts_tokenizers import BaseTokenizer
  from nemo.collections.tts.parts.preprocessing.feature_processors import FeatureProcessor
  from nemo.collections.tts.parts.preprocessing.features import Featurizer
  from nemo.collections.tts.parts.utils.tts_dataset_utils import beta_binomial_prior_distribution, filter_dataset_by_duration, get_weighted_sampler, load_audio, stack_tensors
  from nemo.core.classes import Dataset
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 6 for calling the TextToSpeechDataset obj's underlying member method code with example usage: obj.collate_fn(batch) and returns: batch_dict