code: def mix_examples(mixid_exs, sample_rate, load_audio_with_librosa):
      """Mix several Examples together to create a new example."""
      mixid, exs = mixid_exs
      del mixid
  
      example_samples = []
      example_sequences = []
  
      for ex_str in exs:
          ex = tf.train.Example.FromString(ex_str)
          wav_data = ex.features.feature["audio"].bytes_list.value[0]
          if load_audio_with_librosa:
              samples = audio_io.wav_data_to_samples_librosa(
                  wav_data, sample_rate
              )
          else:
              samples = audio_io.wav_data_to_samples(
                  wav_data, sample_rate
              )
          example_samples.append(samples)
          ns = music_pb2.NoteSequence.FromString(
              ex.features.feature["sequence"].bytes_list.value[0]
          )
          example_sequences.append(ns)
  
      (
          mixed_samples,
          mixed_sequence,
      ) = audio_label_data_utils.mix_sequences(
          individual_samples=example_samples,
          sample_rate=sample_rate,
          individual_sequences=example_sequences,
      )
  
      mixed_wav_data = audio_io.samples_to_wav_data(
          mixed_samples, sample_rate
      )
  
      mixed_id = "::".join(
          ["mixed"] + [ns.id for ns in example_sequences]
      )
      mixed_sequence.id = mixed_id
      mixed_filename = "::".join(
          ["mixed"] + [ns.filename for ns in example_sequences]
      )
      mixed_sequence.filename = mixed_filename
  
      examples = list(
          audio_label_data_utils.process_record(
              mixed_wav_data,
              mixed_sequence,
              mixed_id,
              min_length=0,
              max_length=-1,
              sample_rate=sample_rate,
          )
      )
      assert len(examples) == 1
      return examples[0]
  
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 4 for calling a global function with example usage: mix_examples(mixid_exs, sample_rate, load_audio_with_librosa) and returns: examples