code: def __construct_filepaths(
      all_files: List[str],
      valset_uids: Set[str],
      testset_uids: Set[str],
      class_split: str,
      class_subset: List[str],
      pattern: str,
  ) -> Tuple[
      Dict[str, int],
      Dict[str, List[tuple]],
      List[tuple],
      List[tuple],
      List[tuple],
      List[tuple],
      List[tuple],
  ]:
      """
      Prepares the filepaths for the dataset.
  
      Args:
          all_files: list of all files in the dataset
          valset_uids: set of uids of files in the validation set
          testset_uids: set of uids of files in the test set
          class_split: whether to use all classes as distinct labels, or to use
              10 classes subset and rest of the classes as noise or background
          class_subset: list of classes to consider if `class_split` is set to `sub`
          pattern: regex pattern to match the file names in the dataset
      """
  
      label_count = defaultdict(int)
      label_filepaths = defaultdict(list)
      unknown_val_filepaths = []
      unknown_test_filepaths = []
  
      train, val, test = [], [], []
      for entry in all_files:
          r = re.match(pattern, entry)
          if r:
              label, uid = r.group(2), r.group(3)
  
              if label == "_background_noise_" or label == "silence":
                  continue
  
          if class_split == "sub" and label not in class_subset:
              label = "unknown"
  
              if uid in valset_uids:
                  unknown_val_filepaths.append((label, entry))
              elif uid in testset_uids:
                  unknown_test_filepaths.append((label, entry))
  
          if uid not in valset_uids and uid not in testset_uids:
              label_count[label] += 1
              label_filepaths[label].append((label, entry))
  
          if label == "unknown":
              continue
  
          if uid in valset_uids:
              val.append((label, entry))
          elif uid in testset_uids:
              test.append((label, entry))
          else:
              train.append((label, entry))
  
      return {
          "label_count": label_count,
          "label_filepaths": label_filepaths,
          "unknown_val_filepaths": unknown_val_filepaths,
          "unknown_test_filepaths": unknown_test_filepaths,
          "train": train,
          "val": val,
          "test": test,
      }
  
imports: import argparse
  import glob
  import json
  import logging
  import os
  import re
  import tarfile
  import urllib.request
  from collections import defaultdict
  from functools import partial
  from multiprocessing import Pool
  from typing import Dict, List, Set, Tuple
  import librosa
  import numpy
  import soundfile
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: __construct_filepaths(all_files, valset_uids, testset_uids, class_split, class_subset, pattern) and returns: dict