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["train_csv"],
          replacements={"data_root": data_folder},
      )
  
      valid_data = sb.dataio.dataset.DynamicItemDataset.from_csv(
          csv_path=hparams["valid_csv"],
          replacements={"data_root": data_folder},
      )
  
      # test is separate
      test_datasets = {}
      for csv_file in hparams["test_csv"]:
          name = Path(csv_file).stem
          test_datasets[
              name
          ] = sb.dataio.dataset.DynamicItemDataset.from_csv(
              csv_path=csv_file, replacements={"data_root": data_folder}
          )
  
      datasets = [train_data, valid_data] + [
          i for k, i in test_datasets.items()
      ]
  
      # We get the tokenizer as we need it to encode the labels when creating
      # mini-batches.
      tokenizer = hparams["tokenizer"]
  
      """Define text pipeline"""
  
      # TODO: implement text augmentations pipelines
      @sb.utils.data_pipeline.takes("wrd")
      @sb.utils.data_pipeline.provides(
          "wrd", "tokens_bos", "tokens_eos"
      )
      def text_pipeline(wrd):
          yield wrd
          tokens_list = tokenizer.encode_as_ids(wrd)
          tokens_bos = torch.LongTensor(
              [hparams["bos_index"]] + (tokens_list)
          )
          yield tokens_bos
          tokens_eos = torch.LongTensor(
              tokens_list + [hparams["eos_index"]]
          )
          yield tokens_eos
  
      sb.dataio.dataset.add_dynamic_item(datasets, text_pipeline)
  
      # 4. Set output:
      sb.dataio.dataset.set_output_keys(
          datasets,
          ["id", "wrd", "tokens_bos", "tokens_eos"],
      )
      return train_data, valid_data, test_datasets
  
file_path: speechbrain/recipes/KsponSpeech/LM/train.py
imports: import sys
  import logging
  from pathlib import Path
  import torch
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain
  from speechbrain.utils.distributed import run_on_main
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_datasets