code: def _collect_data(directory, input_ext, transcription_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 (media_filepath, label)
      data_files = {}
      for root, _, filenames in os.walk(directory):
          transcripts = [
              filename
              for filename in filenames
              if transcription_ext in filename
          ]
          for transcript in transcripts:
              transcript_path = os.path.join(root, transcript)
              with open(transcript_path, "r") as transcript_file:
                  for transcript_line in transcript_file:
                      line_contents = transcript_line.strip().split(
                          " ", 1
                      )
                      media_base, label = line_contents
                      key = os.path.join(root, media_base)
                      assert key not in data_files
                      media_name = "%s.%s" % (media_base, input_ext)
                      media_path = os.path.join(root, media_name)
                      data_files[key] = (media_base, media_path, label)
      return data_files
  
imports: import os
  import tarfile
  from tensor2tensor.data_generators import generator_utils
  from tensor2tensor.data_generators import problem
  from tensor2tensor.data_generators import speech_recognition
  from tensor2tensor.utils import registry
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 1 for calling a global function with example usage: _collect_data(directory, input_ext, transcription_ext) and returns: data_files