code: def dataio_prepare(hparams):
      """This function prepares the datasets to be used in the brain class.
      It also defines the data processing pipeline through user-defined functions.
      """
  
      data_folder = hparams["data_folder"]
  
      train_data = sb.dataio.dataset.DynamicItemDataset.from_csv(
          csv_path=hparams["csv_train"],
          replacements={"data_root": data_folder},
      )
  
      if hparams["sorting"] == "ascending":
          # we sort training data to speed up training and get better results.
          train_data = train_data.filtered_sorted(sort_key="duration")
          # when sorting do not shuffle in dataloader ! otherwise is pointless
          hparams["dataloader_opts"]["shuffle"] = False
  
      elif hparams["sorting"] == "descending":
          train_data = train_data.filtered_sorted(
              sort_key="duration", reverse=True
          )
          # when sorting do not shuffle in dataloader ! otherwise is pointless
          hparams["dataloader_opts"]["shuffle"] = False
  
      elif hparams["sorting"] == "random":
          pass
  
      else:
          raise NotImplementedError(
              "sorting must be random, ascending or descending"
          )
  
      valid_data = sb.dataio.dataset.DynamicItemDataset.from_csv(
          csv_path=hparams["csv_valid"],
          replacements={"data_root": data_folder},
      )
      valid_data = valid_data.filtered_sorted(sort_key="duration")
  
      test_data = sb.dataio.dataset.DynamicItemDataset.from_csv(
          csv_path=hparams["csv_test"],
          replacements={"data_root": data_folder},
      )
      test_data = test_data.filtered_sorted(sort_key="duration")
  
      datasets = [train_data, valid_data, test_data]
  
      tokenizer = hparams["tokenizer"]
  
      # 2. Define audio pipeline:
      @sb.utils.data_pipeline.takes("wav")
      @sb.utils.data_pipeline.provides("sig")
      def audio_pipeline(wav):
          sig = sb.dataio.dataio.read_audio(wav)
          return sig
  
      sb.dataio.dataset.add_dynamic_item(datasets, audio_pipeline)
  
      # 3. Define text pipeline:
      @sb.utils.data_pipeline.takes("semantics")
      @sb.utils.data_pipeline.provides(
          "semantics",
          "token_list",
          "tokens_bos",
          "tokens_eos",
          "tokens",
      )
      def text_pipeline(semantics):
          yield semantics
          tokens_list = tokenizer.encode_as_ids(semantics)
          yield tokens_list
          tokens_bos = torch.LongTensor(
              [hparams["bos_index"]] + (tokens_list)
          )
          yield tokens_bos
          tokens_eos = torch.LongTensor(
              tokens_list + [hparams["eos_index"]]
          )
          yield tokens_eos
          tokens = torch.LongTensor(tokens_list)
          yield tokens
  
      sb.dataio.dataset.add_dynamic_item(datasets, text_pipeline)
  
      # 4. Set output:
      sb.dataio.dataset.set_output_keys(
          datasets,
          [
              "id",
              "sig",
              "semantics",
              "tokens_bos",
              "tokens_eos",
              "tokens",
          ],
      )
      return train_data, valid_data, test_data, tokenizer
  
file_path: speechbrain/recipes/fluent-speech-commands/direct/train.py
imports: import sys
  import torch
  import speechbrain
  import logging
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main, if_main_process
label_desc: Use image node_id 1 for calling a global function with example usage: dataio_prepare(hparams) and returns: train_data,  valid_data,  test_data,  tokenizer, sig