code: def _per_partition_to_utility_report(
      per_partition_utility: metrics.PerPartitionMetrics,
      dp_metrics: List[pipeline_dp.Metric],
      public_partitions: bool,
      partition_weight: float,
  ) -> metrics.UtilityReport:
      """Converts per-partition metrics to cross-partition utility report."""
      # Fill partition selection metrics.
      if public_partitions:
          prob_to_keep = 1
          is_empty_partition = (
              per_partition_utility.raw_statistics.count == 0
          )
          partition_metrics = _partition_metrics_public_partitions(
              is_empty_partition
          )
      else:
          prob_to_keep = (
              per_partition_utility.partition_selection_probability_to_keep
          )
          partition_metrics = _partition_metrics_private_partitions(
              prob_to_keep
          )
      # Fill metric errors.
      metric_errors = None
      if dp_metrics:
          assert len(per_partition_utility.metric_errors) == len(
              dp_metrics
          )
          metric_errors = []
          for metric_error, dp_metric in zip(
              per_partition_utility.metric_errors, dp_metrics
          ):
              metric_errors.append(
                  _sum_metrics_to_metric_utility(
                      metric_error,
                      dp_metric,
                      prob_to_keep,
                      partition_weight,
                  )
              )
  
      return metrics.UtilityReport(
          configuration_index=-1,
          partitions_info=partition_metrics,
          metric_errors=metric_errors,
      )
  
imports: import copy
  import pipeline_dp
  from analysis import metrics
  import dataclasses
  from typing import List, Tuple, Callable
  import math
label_desc: Use image node_id 9 for calling a global function with example usage: _per_partition_to_utility_report(per_partition_utility, dp_metrics, public_partitions, partition_weight) and returns: metrics