docs: def find_anomalies(errors, index, z_range=(0, 10)):
      """Find sequences of values that are anomalous.
  
      We first find the ideal threshold for the set of errors that we have,
      and then find the sequences of values that are above this threshold.
  
      Lastly, we compute a score proportional to the maximum error in the
      sequence, and finally return the index pairs that correspond to
      each sequence, along with its score.
      """
  
      threshold = find_threshold(errors, z_range)
      sequences = find_sequences(errors, threshold)
  
      anomalies = list()
      denominator = errors.mean() + errors.std()
      for start, stop in sequences:
          max_error = errors[start:stop + 1].max()
          score = (max_error - threshold) / denominator
          anomalies.append([index[start], index[stop], score])
  
      return np.asarray(anomalies)