code: def _collect_data(directory, input_ext, target_ext):
      """Traverses directory collecting input and target files."""
      # Directory from string to tuple pair of strings
      # key: the filepath to a datafile including the datafile's basename. Example,
      #   if the datafile was "/path/to/datafile.wav" then the key would be
      #   "/path/to/datafile"
      # value: a pair of strings (input_filepath, target_filepath)
      data_files = {}
      for root, _, filenames in os.walk(directory):
          input_files = [
              filename
              for filename in filenames
              if input_ext in filename
          ]
          for input_filename in input_files:
              basename = input_filename.strip(input_ext)
              input_file = os.path.join(root, input_filename)
              target_file = os.path.join(root, basename + target_ext)
              key = os.path.join(root, basename)
              assert os.path.exists(target_file)
              assert key not in data_files
              data_files[key] = (input_file, target_file)
      return data_files
  
file_path: tensor2tensor/tensor2tensor/data_generators/audio.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import subprocess
  import tarfile
  import wave
  from absl import flags
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: _collect_data(directory, input_ext, target_ext) and returns: data_files