code: def _pack_per_partition_metrics(
      utility_result: List[Any], n_configurations: int
  ) -> Tuple[metrics.PerPartitionMetrics]:
      """Packs per-partition metrics.
  
      Arguments:
          utility_result: a list with per-partition results, which contains
            results for all configurations.
          n_configurations: the number of configuration of parameters for which
            the utility analysis is computed.
  
      Returns: a list of element (i_configuration, PerPartitionMetrics),
      where each element corresponds to one of the configuration of the input
      parameters.
      """
      n_metrics = len(utility_result) // n_configurations
  
      raw_statistics = utility_result[0]
      # Create 'result' with empty elements.
      empty_partition_metric = lambda: metrics.PerPartitionMetrics(
          1, raw_statistics, []
      )
      result = tuple(
          empty_partition_metric() for _ in range(n_configurations)
      )
  
      # Fill 'result' from 'utility_metrics'.
      for i, metric in enumerate(utility_result[1:]):
          i_configuration = i // n_metrics
          ith_result = result[i_configuration]
          if isinstance(metric, float):  # partition selection
              ith_result.partition_selection_probability_to_keep = (
                  metric
              )
          else:
              ith_result.metric_errors.append(metric)
      return result
  
file_path: pipelinedp/analysis/utility_analysis.py
imports: from typing import Any, Iterable, List, Tuple, Union
  import pipeline_dp
  from pipeline_dp import pipeline_backend
  import analysis
  from analysis import data_structures
  from analysis import metrics
  from analysis import utility_analysis_engine
  from analysis import cross_partition_combiners
  import copy
  import bisect
label_desc: Use image node_id 3 for calling a global function with example usage: _pack_per_partition_metrics(utility_result, n_configurations) and returns: result