code: def _iter_scores(
      all_scores: Mapping[
          Target, Mapping[Tuple[int, int], numpy.ndarray]
      ],
      all_positives: Mapping[
          Target, Mapping[Tuple[int, int], numpy.ndarray]
      ],
  ) -> Iterable[ScorePack]:
      sides = sorted(all_scores.keys())
      y_score_for_side = dict()
      y_true_for_side = dict()
  
      # individual side
      for side in sides:
          # Because the order of the values of a dictionary is not guaranteed,
          # we need to retrieve scores and masks using the exact same key order.
          all_keys = list(all_scores[side].keys())
          y_score = y_score_for_side[side] = np.concatenate(
              [all_scores[side][k] for k in all_keys], axis=0
          ).flatten()
          y_true = y_true_for_side[side] = np.concatenate(
              [all_positives[side][k] for k in all_keys], axis=0
          ).flatten()
          assert y_score.shape == y_true.shape
          if y_true.size == 0:
              raise ValueError(
                  f"Cannot calculate scores from empty array (y_true.shape={y_true.shape})."
              )
          yield ScorePack(target=side, y_true=y_true, y_score=y_score)
  
      # combined
      yield ScorePack(
          target=SIDE_BOTH,
          y_true=np.concatenate(
              [y_true_for_side[side] for side in sides]
          ),
          y_score=np.concatenate(
              [y_score_for_side[side] for side in sides]
          ),
      )
  
imports: from __future__ import annotations
  import itertools
  from collections import defaultdict
  from typing import Iterable, Mapping, MutableMapping, NamedTuple, Optional, Tuple, cast
  import numpy
  import numpy
  import torch
  from .evaluator import Evaluator, MetricResults
  from ..constants import TARGET_TO_INDEX
  from ..metrics.classification import ClassificationMetric, classification_metric_resolver
  from ..typing import SIDE_BOTH, ExtendedTarget, MappedTriples, Target, normalize_target
label_desc: Use image node_id 1 for calling a global function with example usage: _iter_scores(all_scores, all_positives) without return types