code: def merge_chord_intervals(intervals, labels):
      
      roots, semitones, basses = encode_many(labels, True)
      merged_ivs = []
      prev_rt = None
      prev_st = None
      prev_ba = None
      for s, e, rt, st, ba in zip(intervals[:, 0], intervals[:, 1],
                                  roots, semitones, basses):
          if rt != prev_rt or (st != prev_st).any() or ba != prev_ba:
              prev_rt, prev_st, prev_ba = rt, st, ba
              merged_ivs.append([s, e])
          else:
              merged_ivs[-1][-1] = e
      return np.array(merged_ivs)
docs: Merge consecutive chord intervals if they represent the same chord.
  
      Parameters
      ----------
      intervals : np.ndarray, shape=(n, 2), dtype=float
          Chord intervals to be merged, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.
      labels : list, shape=(n,)
          Chord labels to be merged, in the format returned by
          :func:`mir_eval.io.load_labeled_intervals`.
  
      Returns
      -------
      merged_ivs : np.ndarray, shape=(k, 2), dtype=float
          Merged chord intervals, k <= n