code: def split_train_val_test(
      data_dir, file_type, test_size=0.1, val_size=0.1, demo=False
  ):
      X = []
      if file_type == "speech":
          for o in os.listdir(data_dir):
              if (
                  os.path.isdir(os.path.join(data_dir, o))
                  and o.split("/")[-1] != "_background_noise_"
              ):
                  X.extend(
                      glob.glob(os.path.join(data_dir, o) + "/*.wav")
                  )
  
          if demo:
              logging.info(
                  f"For Demonstration, we use {int(len(X)/100)}/{len(X)} speech data. Make sure to remove --demo flag when you actually train your model!"
              )
              X = np.random.choice(X, int(len(X) / 100), replace=False)
  
      else:
          for o in os.listdir(data_dir):
              if os.path.isdir(os.path.join(data_dir, o)):
                  X.extend(
                      glob.glob(os.path.join(data_dir, o) + "/*.wav")
                  )
              else:  # for using "_background_noise_" from google speech commands as background data
                  if o.endswith(".wav"):
                      X.append(os.path.join(data_dir, o))
  
      X_train, X_test = train_test_split(
          X, test_size=test_size, random_state=1
      )
      val_size_tmp = val_size / (1 - test_size)
      X_train, X_val = train_test_split(
          X_train, test_size=val_size_tmp, random_state=1
      )
  
      with open(
          os.path.join(data_dir, file_type + "_training_list.txt"), "w"
      ) as outfile:
          outfile.write("\n".join(X_train))
      with open(
          os.path.join(data_dir, file_type + "_testing_list.txt"), "w"
      ) as outfile:
          outfile.write("\n".join(X_test))
      with open(
          os.path.join(data_dir, file_type + "_validation_list.txt"),
          "w",
      ) as outfile:
          outfile.write("\n".join(X_val))
  
      logging.info(
          f"Overall: {len(X)}, Train: {len(X_train)}, Validatoin: {len(X_val)}, Test: {len(X_test)}"
      )
      logging.info(
          f"Finish spliting train, val and test for {file_type}. Write to files!"
      )
  
imports: import argparse
  import glob
  import json
  import logging
  import os
  import tarfile
  import urllib.request
  import librosa
  import numpy
  import soundfile
  from sklearn.model_selection import train_test_split
label_desc: Use image node_id 4 for calling a global function with example usage: split_train_val_test(data_dir, file_type, test_size, val_size, demo) without return types