code: def dataio_prep(hparams):
      """This function prepares the datasets to be used in the brain class.
      It also defines the data processing pipeline through user-defined
      functions. We expect `prepare_mini_librispeech` to have been called before
      this, so that the `train.json`, `valid.json`,  and `valid.json` manifest
      files are available.
      Arguments
      ---------
      hparams : dict
          This dictionary is loaded from the `train.yaml` file, and it includes
          all the hyperparameters needed for dataset construction and loading.
      Returns
      -------
      datasets : dict
          Contains two keys, "train" and "valid" that correspond
          to the appropriate DynamicItemDataset object.
      """
  
      # Define audio pipeline
      @sb.utils.data_pipeline.takes("wav")
      @sb.utils.data_pipeline.provides("sig")
      def audio_pipeline(wav):
          """Load the signal, and pass it and its length to the corruption class.
          This is done on the CPU in the `collate_fn`."""
          sig = sb.dataio.dataio.read_audio(wav)
          return sig
  
      # Initialization of the label encoder. The label encoder assignes to each
      # of the observed label a unique index (e.g, 'spk01': 0, 'spk02': 1, ..)
      label_encoder = sb.dataio.encoder.CategoricalEncoder()
  
      # Define label pipeline:
      @sb.utils.data_pipeline.takes("emo")
      @sb.utils.data_pipeline.provides("emo", "emo_encoded")
      def label_pipeline(emo):
          yield emo
          emo_encoded = label_encoder.encode_label_torch(emo)
          yield emo_encoded
  
      # Define datasets. We also connect the dataset with the data processing
      # functions defined above.
      datasets = {}
      data_info = {
          "train": hparams["train_annotation"],
          "valid": hparams["valid_annotation"],
          "test": hparams["test_annotation"],
      }
      for dataset in data_info:
          datasets[
              dataset
          ] = sb.dataio.dataset.DynamicItemDataset.from_json(
              json_path=data_info[dataset],
              replacements={"data_root": hparams["data_folder"]},
              dynamic_items=[audio_pipeline, label_pipeline],
              output_keys=["id", "sig", "emo_encoded"],
          )
      # Load or compute the label encoder (with multi-GPU DDP support)
      # Please, take a look into the lab_enc_file to see the label to index
      # mappinng.
  
      lab_enc_file = os.path.join(
          hparams["save_folder"], "label_encoder.txt"
      )
      label_encoder.load_or_create(
          path=lab_enc_file,
          from_didatasets=[datasets["train"]],
          output_key="emo",
      )
  
      return datasets
  
file_path: speechbrain/recipes/IEMOCAP/emotion_recognition/train_with_wav2vec2.py
imports: import os
  import sys
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 1 for calling a global function with example usage: dataio_prep(hparams) and returns: datasets, sig