code: def main(argv):
      del argv
  
      flags.mark_flags_as_required(["csv", "output_directory"])
  
      tf.io.gfile.makedirs(FLAGS.output_directory)
  
      with tf.io.gfile.GFile(FLAGS.csv) as f:
          reader = csv.DictReader(f)
  
          splits = collections.defaultdict(list)
          for row in reader:
              splits[row["split"]].append(
                  (
                      os.path.join(
                          FLAGS.midi_dir, row["midi_filename"]
                      ),
                      os.path.join(
                          FLAGS.wav_dir, row["audio_filename"]
                      ),
                  )
              )
  
      if sorted(splits.keys()) != sorted(
          FLAGS.expected_splits.split(",")
      ):
          raise ValueError(
              "Got unexpected set of splits: %s" % list(splits.keys())
          )
  
      pipeline_options = beam.options.pipeline_options.PipelineOptions(
          FLAGS.pipeline_options
      )
      with beam.Pipeline(options=pipeline_options) as p:
          for split in splits:
              split_p = p | "prepare_split_%s" % split >> beam.Create(
                  splits[split]
              )
              split_p |= "create_examples_%s" % split >> beam.ParDo(
                  CreateExampleDoFn(
                      FLAGS.wav_dir, FLAGS.midi_dir, FLAGS.add_wav_glob
                  )
              )
              split_p |= "write_%s" % split >> beam.io.WriteToTFRecord(
                  os.path.join(
                      FLAGS.output_directory, "%s.tfrecord" % split
                  ),
                  coder=beam.coders.ProtoCoder(tf.train.Example),
                  num_shards=FLAGS.num_shards,
              )
  
file_path: magenta/magenta/models/onsets_frames_transcription/onsets_frames_transcription_create_tfrecords.py
imports: import collections
  import copy
  import csv
  import os
  from absl import app
  from absl import flags
  from absl import logging
  import apache_beam
  from apache_beam.metrics import Metrics
  from magenta.models.onsets_frames_transcription import audio_label_data_utils
  from note_seq import midi_io
  from note_seq.protobuf import music_pb2
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: main(argv) without return types