code: def split_wav(
      input_example,
      min_length,
      max_length,
      sample_rate,
      debug_output_directory,
      split_example,
      load_audio_with_librosa,
  ):
      """Splits wav and midi files for the dataset."""
      tf.logging.info(
          "Splitting %s",
          input_example.features.feature["id"].bytes_list.value[0],
      )
  
      wav_data = input_example.features.feature[
          "audio"
      ].bytes_list.value[0]
  
      ns = music_pb2.NoteSequence.FromString(
          input_example.features.feature["sequence"].bytes_list.value[0]
      )
  
      Metrics.counter("split_wav", "read_midi_wav_to_split").inc()
  
      if not split_example:
          split_examples = audio_label_data_utils.process_record(
              wav_data,
              ns,
              ns.id,
              min_length=0,
              max_length=-1,
              sample_rate=sample_rate,
              allow_empty_notesequence=True,
              load_audio_with_librosa=load_audio_with_librosa,
          )
  
          for example in split_examples:
              Metrics.counter("split_wav", "full_example").inc()
              yield example
      else:
          try:
              split_examples = audio_label_data_utils.process_record(
                  wav_data,
                  ns,
                  ns.id,
                  min_length=min_length,
                  max_length=max_length,
                  sample_rate=sample_rate,
                  load_audio_with_librosa=load_audio_with_librosa,
              )
  
              for example in split_examples:
                  Metrics.counter("split_wav", "split_example").inc()
                  yield example
          except AssertionError:
              output_file = (
                  "badexample-"
                  + hashlib.md5(ns.id.encode("utf-8")).hexdigest()
                  + ".proto"
              )
              output_path = os.path.join(
                  debug_output_directory, output_file
              )
              tf.logging.error(
                  "Exception processing %s. Writing file to %s",
                  ns.id,
                  output_path,
              )
              with tf.gfile.Open(output_path, "w") as f:
                  f.write(input_example.SerializeToString())
              raise
  
file_path: magenta/magenta/models/onsets_frames_transcription/create_dataset.py
imports: import hashlib
  import os
  import apache_beam
  from apache_beam.metrics import Metrics
  from magenta.models.onsets_frames_transcription import audio_label_data_utils
  from magenta.models.onsets_frames_transcription import create_dataset_lib
  from magenta.models.onsets_frames_transcription import data
  from note_seq import audio_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: split_wav(input_example, min_length, max_length, sample_rate, debug_output_directory, split_example, load_audio_with_librosa) without return types