code: def generate_train_set(exclude_ids):
      """Generate the train TFRecord."""
      train_file_pairs = []
      for directory in train_dirs:
          path = os.path.join(FLAGS.input_dir, directory)
          path = os.path.join(path, "*.wav")
          wav_files = glob.glob(path)
          # find matching mid files
          for wav_file in wav_files:
              base_name_root, _ = os.path.splitext(wav_file)
              mid_file = base_name_root + ".mid"
              if filename_to_id(wav_file) not in exclude_ids:
                  train_file_pairs.append((wav_file, mid_file))
  
      train_output_name = os.path.join(
          FLAGS.output_dir, "maps_config2_train.tfrecord"
      )
  
      with tf.python_io.TFRecordWriter(train_output_name) as writer:
          for idx, pair in enumerate(train_file_pairs):
              print(
                  "{} of {}: {}".format(
                      idx, len(train_file_pairs), pair[0]
                  )
              )
              # load the wav data
              wav_data = tf.gfile.Open(pair[0], "rb").read()
              # load the midi data and convert to a notesequence
              ns = midi_io.midi_file_to_note_sequence(pair[1])
              for example in audio_label_data_utils.process_record(
                  wav_data,
                  ns,
                  pair[0],
                  FLAGS.min_length,
                  FLAGS.max_length,
                  FLAGS.sample_rate,
              ):
                  writer.write(example.SerializeToString())
  
file_path: magenta/magenta/models/onsets_frames_transcription/onsets_frames_transcription_create_dataset_maps.py
imports: import glob
  import os
  import re
  from magenta.models.onsets_frames_transcription import audio_label_data_utils
  from note_seq import audio_io
  from note_seq import midi_io
  import six
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: generate_train_set(exclude_ids) without return types