code: def merge_held(notes):
      """Combine repeated notes into one sustained note."""
      notes = list(notes)
      i = 1
      while i < len(notes):
          if (
              notes[i].pitch == notes[i - 1].pitch
              and notes[i].start == notes[i - 1].end
          ):
              notes[i - 1].end = notes[i].end
              del notes[i]
          else:
              i += 1
      return notes
  
file_path: magenta/magenta/models/coconet/lib_pianoroll.py
imports: import numpy
  import pretty_midi
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling a global function with example usage: merge_held(notes) and returns: notes