code: def extract_chords(
      quantized_sequence, max_steps=None, all_transpositions=False
  ):
      """Extracts a single chord progression from a quantized NoteSequence.
  
      This function will extract the underlying chord progression (encoded as text
      annotations) from `quantized_sequence`.
  
      Args:
        quantized_sequence: A quantized NoteSequence.
        max_steps: An integer, maximum length of a chord progression. Chord
            progressions will be trimmed to this length. If None, chord
            progressions will not be trimmed.
        all_transpositions: If True, also transpose the chord progression into all
            12 keys.
  
      Returns:
        chord_progressions: If `all_transpositions` is False, a python list
            containing a single ChordProgression instance. If `all_transpositions`
            is True, a python list containing 12 ChordProgression instances, one
            for each transposition.
        stats: A dictionary mapping string names to `statistics.Statistic` objects.
      """
      sequences_lib.assert_is_relative_quantized_sequence(
          quantized_sequence
      )
  
      stats = dict(
          [("chords_truncated", statistics.Counter("chords_truncated"))]
      )
      chords = ChordProgression()
      chords.from_quantized_sequence(
          quantized_sequence,
          0,
          quantized_sequence.total_quantized_steps,
      )
      if max_steps is not None:
          if len(chords) > max_steps:
              chords.set_length(max_steps)
              stats["chords_truncated"].increment()
      if all_transpositions:
          chord_progressions = []
          for amount in range(-6, 6):
              transposed_chords = copy.deepcopy(chords)
              transposed_chords.transpose(amount)
              chord_progressions.append(transposed_chords)
          return chord_progressions, stats.values()
      else:
          return [chords], 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 1 for calling a global function with example usage: extract_chords(quantized_sequence, max_steps, all_transpositions) and returns: chord_progressions,  stats, list,  stats