code: def extract_chords_for_melodies(quantized_sequence, melodies):
      """Extracts a chord progression from the quantized NoteSequence for melodies.
  
      This function will extract the underlying chord progression (encoded as text
      annotations) from `quantized_sequence` for each monophonic melody in
      `melodies`.  Each chord progression will be the same length as its
      corresponding melody.
  
      Args:
        quantized_sequence: A quantized NoteSequence object.
        melodies: A python list of Melody instances.
  
      Returns:
        chord_progressions: A python list of ChordProgression instances, the same
            length as `melodies`. If a progression fails to be extracted for a
            melody, the corresponding list entry will be None.
        stats: A dictionary mapping string names to `statistics.Statistic` objects.
      """
      chord_progressions = []
      stats = dict(
          [
              (
                  "coincident_chords",
                  statistics.Counter("coincident_chords"),
              )
          ]
      )
      for melody in melodies:
          try:
              chords = ChordProgression()
              chords.from_quantized_sequence(
                  quantized_sequence, melody.start_step, melody.end_step
              )
          except CoincidentChordsError:
              stats["coincident_chords"].increment()
              chords = None
          chord_progressions.append(chords)
  
      return chord_progressions, list(stats.values())
  
file_path: magenta/magenta/pipelines/chord_pipelines.py
imports: import copy
  from magenta.pipelines import pipeline
  from magenta.pipelines import statistics
  from note_seq import chord_symbols_lib
  from note_seq import ChordProgression
  from note_seq import chords_lib
  from note_seq import events_lib
  from note_seq import sequences_lib
  from note_seq.chords_lib import CoincidentChordsError
  from note_seq.protobuf import music_pb2
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: extract_chords_for_melodies(quantized_sequence, melodies) and returns: chord_progressions,  list