code: def aggregate_precision_recall(
      labels_pred_iterable: Iterable,
      precision_recall_fn: Callable = buffered_precision_recall,
  ) -> Tuple[float, float]:
      """
      Computes aggregate range-based precision recall metrics for the given
      prediction labels.
  
      Parameters
      ----------
      labels_pred_iterable
          An iterable that gives 2-tuples of boolean lists corresponding to `true_labels` and
          `pred_labels` respectively.
      precision_recall_fn
          Function to call in order to get the precision, recall metrics.
  
      Returns
      -------
      A tuple containing average precision and recall in that order.
      """
      total_prec, total_reca, total_prec_w, total_reca_w = (
          0.0,
          0.0,
          0.0,
          0.0,
      )
      for true_labels, pred_labels in labels_pred_iterable:
          true_ranges = labels_to_ranges(true_labels)
          pred_ranges = labels_to_ranges(pred_labels)
  
          _prec, _reca = precision_recall_fn(true_ranges, pred_ranges)
          _prec_w, _reca_w = len(pred_ranges), len(true_ranges)
          total_prec += _prec * _prec_w
          total_prec_w += _prec_w
  
          total_reca += _reca * _reca_w
          total_reca_w += _reca_w
  
      return (
          total_prec / total_prec_w if total_prec_w > 0 else 0,
          total_reca / total_reca_w if total_reca_w > 0 else 0,
      )
  
file_path: gluonts/src/gluonts/nursery/anomaly_detection/supervised_metrics/_precision_recall_utils.py
imports: from typing import Callable, Iterable, List, NamedTuple, Optional, Tuple
  import numpy
  from joblib import Parallel, delayed
  from .None import buffered_precision_recall
  from .utils import labels_to_ranges
label_desc: Use image node_id 4 for calling a global function with example usage: aggregate_precision_recall(labels_pred_iterable, precision_recall_fn) and returns: unknown,  unknown