code: def pscore(detections, annotations, tolerance=PSCORE_TOLERANCE):
      """
      Calculate the P-score accuracy for the given detections and annotations.
  
      The P-score is determined by taking the sum of the cross-correlation
      between two impulse trains, representing the detections and annotations
      allowing for a tolerance of 20% of the median annotated interval [1]_.
  
      Parameters
      ----------
      detections : list or numpy array
          Detected beats.
      annotations : list or numpy array
          Annotated beats.
      tolerance : float, optional
          Evaluation tolerance (fraction of the median beat interval).
  
      Returns
      -------
      pscore : float
          P-Score.
  
      Notes
      -----
      Contrary to the original implementation which samples the two impulse
      trains with 100Hz, we do not quantise the annotations and detections but
      rather count all detections falling withing the defined tolerance window.
  
      References
      ----------
      .. [1] M. McKinney, D. Moelants, M. Davies and A. Klapuri,
             "Evaluation of audio beat tracking and music tempo extraction
             algorithms",
             Journal of New Music Research, vol. 36, no. 1, 2007.
  
      """
      # at least 2 annotations must be given to calculate an interval
      if len(annotations) < 2:
          raise BeatIntervalError(
              "At least 2 annotations are needed for" "P-Score."
          )
      # tolerance must be greater than 0
      if float(tolerance) <= 0:
          raise ValueError("`tolerance` must be greater than 0.")
      # the error window is the given fraction of the median beat interval
      window = tolerance * np.median(np.diff(annotations))
      # errors
      errors = calc_absolute_errors(detections, annotations)
      # count the instances where the error is smaller or equal than the window
      p = len(detections[errors <= window])
      # normalize by the max number of detections/annotations
      p /= float(max(len(detections), len(annotations)))
      # return p-score
      return p
  
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 8 for calling a global function with example usage: pscore(detections, annotations, tolerance) and returns: p