code: def calc_relative_errors(detections, annotations, matches=None):
      """
      Errors of the detections relative to the closest annotated interval.
  
      Parameters
      ----------
      detections : list or numpy array
          Detected beats.
      annotations : list or numpy array
          Annotated beats.
      matches : list or numpy array
          Indices of the closest beats.
  
      Returns
      -------
      numpy array
          Errors relative to the closest annotated beat interval.
  
      Notes
      -----
      The sequences must be ordered! To speed up the calculation, a list of
      pre-computed indices of the closest matches can be used.
  
      """
      # if no detection are given, return an empty interval array
      if len(detections) == 0:
          return np.zeros(0, dtype=float)
      # at least annotations must be given
      if len(annotations) < 2:
          raise BeatIntervalError
      # determine the closest annotations
      if matches is None:
          matches = find_closest_matches(detections, annotations)
      # calculate the absolute errors
      errors = calc_errors(detections, annotations, matches)
      # get the closest intervals
      intervals = find_closest_intervals(
          detections, annotations, matches
      )
      # return the relative errors
      return errors / intervals
  
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 7 for calling a global function with example usage: calc_relative_errors(detections, annotations, matches) and returns: unknown, np