class_docstr: The pack-sum format
  
  Parameters
  ----------
  dmatrix : xgb.DMatrix
      A float64 array of shape [n, m],
      where `n` is the packed number of blocks,
      and `m` is the length of feature vector on each block
  ids : np.ndarray
      An int64 array of shape [n] containing nonnegative integers,
      indicating which the index of a sample that a block belongs to
class_docstr_tok: ["The","pack-sum","format","Parameters","--","--","--","--","--","dmatrix",":","xgb.DMatrix","A","float64","array","of","shape","[","n",",","m","]",",","where","`","n","`","is","the","packed","number","of","blocks",",","and","`","m","`","is","the","length","of","feature","vector","on","each","block","ids",":","np.ndarray","An","int64","array","of","shape","[","n","]","containing","nonnegative","integers",",","indicating","which","the","index","of","a","sample","that","a","block","belongs","to"]
docstr: Evaluate average-peak-score@N in the pack-sum format
  
  Parameters
  ----------
  ys_pred: np.ndarray
      The raw prediction
  n : int
      The N in average-peak-score@N
  
  Returns
  -------
  name: str
      The name of the metric
  score: float
      The score of the metric
docstr_tok: ["Evaluate","average-peak-score","@","N","in","the","pack-sum","format","Parameters","--","--","--","--","--","ys_pred",":","np.ndarray","The","raw","prediction","n",":","int","The","N","in","average-peak-score","@","N","Returns","--","--","--","-","name",":","str","The","name","of","the","metric","score",":","float","The","score","of","the","metric"]
code: def average_peak_score(
      self,
      ys_pred: np.ndarray,
      n: int,
  ) -> Tuple[str, float]:
      """Evaluate average-peak-score@N in the pack-sum format
  
      Parameters
      ----------
      ys_pred: np.ndarray
          The raw prediction
      n : int
          The N in average-peak-score@N
  
      Returns
      -------
      name: str
          The name of the metric
      score: float
          The score of the metric
      """
      ys = self.dmatrix.get_label()  # type: ignore # pylint: disable=invalid-name
      ys = self.predict_with_score(ys)  # type: ignore # pylint: disable=invalid-name
      ys = ys / np.unique(self.ids, return_counts=True)[1]  # type: ignore # pylint: disable=invalid-name
      ys_pred = self.predict_with_score(ys_pred)
      trials = np.argsort(ys_pred)[::-1][:n]
      trial_scores = ys[trials]
      curve = max_curve(trial_scores) / np.max(ys)
      score = np.mean(curve)
      return f"a-peak@{n}", score
  
imports: import os
  import tempfile
  from collections import OrderedDict
  from itertools import chain
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, NamedTuple, Optional, Tuple
  from typing_extensions import Literal
  import numpy
  from ...contrib.tar import tar, untar
  from ...runtime import NDArray
  from ..cost_model import PyCostModel
  from ..feature_extractor import FeatureExtractor
  from ..logging import get_logger
  from ..runner import RunnerResult
  from ..search_strategy import MeasureCandidate
  from ..utils import cpu_count, derived_object, shash2hex
  from .metric import max_curve
label_desc: Use image node_id 5 for calling the PackSum obj's underlying member method code with example usage: obj.average_peak_score(ys_pred, n) and returns: str, n,  score