code: def dataio_prepare(hparams):
      "Creates the datasets and their data processing pipelines."
      # Load lexicon
      lexicon = hparams["lexicon"]
      input_encoder = hparams.get("input_encoder")
  
      # add a dummy symbol for idx 0 - used for padding.
      lexicon = ["@@"] + lexicon
      input_encoder.update_from_iterable(lexicon, sequence_input=False)
      input_encoder.add_unk()
  
      # load audio, text and durations on the fly; encode audio and text.
      @sb.utils.data_pipeline.takes("wav", "phonemes", "pitch")
      @sb.utils.data_pipeline.provides("mel_text_pair")
      def audio_pipeline(wav, phonemes, pitch):
          phoneme_seq = input_encoder.encode_sequence_torch(
              phonemes
          ).int()
  
          audio, fs = torchaudio.load(wav)
          audio = audio.squeeze()
          mel, energy = hparams["mel_spectogram"](audio=audio)
  
          pitch = np.load(pitch)
          pitch = torch.from_numpy(pitch)
          pitch = pitch[: mel.shape[-1]]
          return (
              phoneme_seq,
              mel,
              pitch,
              energy,
              len(phoneme_seq),
              len(mel),
          )
  
      # define splits and load it as sb dataset
      datasets = {}
  
      for dataset in hparams["splits"]:
          datasets[
              dataset
          ] = sb.dataio.dataset.DynamicItemDataset.from_json(
              json_path=hparams[f"{dataset}_json"],
              replacements={"data_root": hparams["data_folder"]},
              dynamic_items=[audio_pipeline],
              output_keys=["mel_text_pair", "wav", "label", "pitch"],
          )
      return datasets
  
imports: import os
  import sys
  import torch
  import logging
  import torchaudio
  import numpy
  import speechbrain
  from speechbrain.inference.vocoders import HIFIGAN
  from pathlib import Path
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.data_utils import scalarize
label_desc: Use image node_id 1 for calling a global function with example usage: dataio_prepare(hparams) and returns: datasets, phoneme_seq,  mel,  pitch,  energy,  len,  len