code: def prepare_audiomnist(
      data_folder,
      save_folder,
      train_json,
      valid_json,
      test_json,
      metadata_folder=None,
      splits=DEFAULT_SPLITS,
      download=True,
      audiomnist_repo=None,
      metadata_repo=None,
      src_sample_rate=DEFAULT_SRC_SAMPLE_RATE,
      tgt_sample_rate=DEFAULT_TGT_SAMPLE_RATE,
      trim=True,
      trim_threshold=-30.0,
      norm=True,
      highpass=True,
      process_audio=None,
      skip_prep=False,
  ):
      """Auto-downloads and prepares the AudioMNIST dataset
  
      Arguments
      ---------
      data_folder: str
          the folder where the original dataset exists. It assumes the data are stored
          in data_folder/audiomnist_original. If not, data will be automatically downloaded here.
  
      save_folder: str
          the destination folder
  
      train_json: str
          the destination of the training data manifest JSON file.
  
      valid_json: str
          the destination of the valid data manifest JSON file.
  
      test_json: str
          the destination of the test data manifest JSON file.
  
      metadata_folder: str
          the folder for additional metadata
  
      download: bool
          whether the dataset and meta info should be auto-downloaded (enabled by default)
  
      audiomnist_repo: str
          the URL of the AudioMNIST repository
  
      metadata_repo: str
          the URL of the repository with meta information (e.g., train, valid, test splits)
  
      src_sample_rate: int
          the source sampling rate
  
      tgt_sample_rate: int
          the target sampling rate
  
      trim: bool
          whether to trim silence from the beginning and the end.
          Ignored if process_audio is provided
  
      trim_threshold: bool
          the trimming threshold, in decibels.
          Ignored if process_audio is provided
  
      norm: bool
          whether to normalize the amplitude between -1. and 1.
          Ignored if process_audio is provided
  
      process_audio: callable
          a custom function used to process audio files - instead of
          the standard transform (resample + normalize + trim)
  
      skip_prep: bool
          whether preparation should be skipped
  
      """
      if skip_prep:
          return
  
      # Create a dictionary with all the data-manifest files.
      json_files = {
          "train": train_json,
          "valid": valid_json,
          "test": test_json,
      }
  
      # Check if the target folder exists. Create it if it does not.
      if not os.path.exists(save_folder):
          os.makedirs(save_folder)
  
      if metadata_folder is None:
          metadata_folder = os.path.join(data_folder, "metadata")
  
      conf = {
          "trim_threshold": trim_threshold,
          "norm": norm,
          "tgt_sample_rate": tgt_sample_rate,
      }
  
      save_opt = os.path.join(save_folder, OPT_FILE)
  
      if skip(json_files, save_opt, conf):
          logger.info(
              "Skipping preparation, completed in previous run."
          )
          return
      else:
          logger.info("Data_preparation...")
  
      # Path where the original dataset will be downloaded
      data_folder_original = os.path.join(
          data_folder, "audiomnist_original"
      )
      if not os.path.exists(data_folder_original):
          os.makedirs(data_folder_original)
  
      # Download AudioMNIST if not present
      if not os.path.exists(data_folder) or not os.listdir(
          data_folder_original
      ):
          if download:
              if not audiomnist_repo:
                  audiomnist_repo = DEFAULT_AUDIOMNIST_REPO
              download_dataset(data_folder_original, audiomnist_repo)
          else:
              raise ValueError(f"AudioMNIST not found in {data_folder}")
  
      # Download meta info (needed for train, valid, and test splits)
      if not os.path.exists(metadata_folder) or not os.listdir(
          metadata_folder
      ):
          if download:
              if not metadata_repo:
                  metadata_repo = DEFAULT_METADATA_REPO
              metadata_file = os.path.join(
                  metadata_folder, "metadata.zip"
              )
              download_file(metadata_repo, metadata_file, unpack=True)
          else:
              raise ValueError(
                  f"Metadata not found in {metadata_folder}"
              )
  
      # Set up the audio preprocessing function
      if not process_audio:
          process_audio = partial(
              process_audio_default,
              src_sample_rate=src_sample_rate,
              tgt_sample_rate=tgt_sample_rate,
              trim=trim,
              trim_threshold=trim_threshold,
              norm=norm,
              highpass=highpass,
          )
  
      # Get file lists for train/valid/test splits
      splits = get_splits(metadata_folder, splits)
      json_files = {
          "train": train_json,
          "valid": valid_json,
          "test": test_json,
      }
  
      digit_lookup_file_name = os.path.join(
          metadata_folder, "digits.csv"
      )
  
      # Read the digit look-up file providing annotations text and
      # phonemes
      lookup = read_digit_lookup(digit_lookup_file_name)
  
      # Convert the dataset
      convert_dataset(
          src=data_folder_original,
          tgt=save_folder,
          splits=splits,
          json_files=json_files,
          lookup=lookup,
          process_audio=process_audio,
          sample_rate=tgt_sample_rate,
      )
  
      # saving options
      save_pkl(conf, save_opt)
  
imports: import logging
  import csv
  import math
  import json
  import os
  import torchaudio
  import speechbrain
  from glob import glob
  from functools import partial
  from tqdm.auto import tqdm
  from torchaudio import functional
  from subprocess import list2cmdline
  from speechbrain.utils.superpowers import run_shell
  from speechbrain.utils.data_utils import download_file
  from speechbrain.dataio.dataio import load_pkl, save_pkl
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_audiomnist(data_folder, save_folder, train_json, valid_json, test_json, metadata_folder, splits, download, audiomnist_repo, metadata_repo, src_sample_rate, tgt_sample_rate, trim, trim_threshold, norm, highpass, process_audio, skip_prep) without return types