code: def cml(
      detections,
      annotations,
      phase_tolerance=CONTINUITY_PHASE_TOLERANCE,
      tempo_tolerance=CONTINUITY_TEMPO_TOLERANCE,
  ):
      """
      Calculate the cmlc and cmlt scores for the given detections and
      annotations.
  
      Parameters
      ----------
      detections : list or numpy array
          Detected beats.
      annotations : list or numpy array
          Annotated beats.
      phase_tolerance : float, optional
          Allowed phase tolerance.
      tempo_tolerance : float, optional
          Allowed tempo tolerance.
  
      Returns
      -------
      cmlc : float
          Longest continuous segment of correct detections normalized by the
          maximum length of both sequences (detection and annotations).
      cmlt : float
          Same as cmlc, but no continuity required.
  
      References
      ----------
      .. [1] S. Hainsworth,
             "Techniques for the automated analysis of musical audio",
             PhD. dissertation, Department of Engineering, Cambridge University,
             2004.
      .. [2] A.P. Klapuri, A. Eronen, and J. Astola,
             "Analysis of the meter of acoustic musical signals",
             IEEE Transactions on Audio, Speech and Language Processing, vol. 14,
             no. 1, 2006.
  
      """
      # at least 2 annotations must be given to calculate an interval
      if len(annotations) < 2:
          raise BeatIntervalError(
              "At least 2 annotations are needed for "
              "continuity scores, %s given." % annotations
          )
      # TODO: remove this, see TODO below
      if len(detections) < 2:
          raise BeatIntervalError(
              "At least 2 detections are needed for "
              "continuity scores, %s given." % detections
          )
      # tolerances must be greater than 0
      if float(tempo_tolerance) <= 0 or float(phase_tolerance) <= 0:
          raise ValueError(
              "Tempo and phase tolerances must be greater than 0"
          )
      # determine closest annotations to detections
      closest = find_closest_matches(detections, annotations)
      # errors of the detections wrt. to the annotations
      errors = calc_absolute_errors(detections, annotations, closest)
      # detection intervals
      det_interval = calc_intervals(detections)
      # annotation intervals (get those intervals at the correct positions)
      ann_interval = calc_intervals(annotations)[closest]
      # a detection is correct, if it fulfills 2 conditions:
      # 1) must match an annotation within a certain tolerance window, i.e. the
      #    phase must be correct
      correct_phase = detections[
          errors <= ann_interval * phase_tolerance
      ]
      # Note: the initially cited technical report has an additional condition
      #       ii) on page 5 which requires the same condition to be true for the
      #       previous detection / annotation combination. We do not enforce
      #       this, since a) this condition is kind of pointless: why shouldn't
      #       we count a correct beat just because its predecessor is not? and
      #       b) the original Matlab implementation does not enforce it either
      # 2) the tempo, i.e. the intervals, must be within the tempo tolerance
      # TODO: as agreed with Matthew, this should only be enforced from the 2nd
      #       beat onwards.
      correct_tempo = detections[
          abs(1 - (det_interval / ann_interval)) <= tempo_tolerance
      ]
      # combine the conditions
      correct = np.intersect1d(correct_phase, correct_tempo)
      # convert to indices
      correct_idx = np.searchsorted(detections, correct)
      # cmlc: longest continuous segment of detections normalized by the max.
      #       length of both sequences (detection and annotations)
      length = float(max(len(detections), len(annotations)))
      longest, _ = find_longest_continuous_segment(correct_idx)
      cmlc = longest / length
      # cmlt: same but for all detections (no need for continuity)
      cmlt = len(correct) / length
      # return a tuple
      return cmlc, cmlt
  
imports: from __future__ import absolute_import, division, print_function
  import warnings
  from functools import wraps
  import numpy
  from .None import MeanEvaluation, calc_absolute_errors, calc_errors, evaluation_io, find_closest_matches
  from .onsets import OnsetEvaluation
label_desc: Use image node_id 11 for calling a global function with example usage: cml(detections, annotations, phase_tolerance, tempo_tolerance) and returns: cmlc,  cmlt