code: def _convert_utility_analysis_to_tune_result(
      utility_reports: Tuple[metrics.UtilityReport],
      tune_options: TuneOptions,
      run_configurations: analysis.MultiParameterConfiguration,
      use_public_partitions: bool,
      contribution_histograms: histograms.DatasetHistograms,
  ):
      assert len(utility_reports) == run_configurations.size
      # TODO(dvadym): implement relative error.
      # TODO(dvadym): take into consideration partition selection from private
      # partition selection.
      assert (
          tune_options.function_to_minimize
          == MinimizingFunction.ABSOLUTE_ERROR
      )
  
      # Sort utility reports by configuration index.
      sorted_utility_reports = sorted(
          utility_reports, key=lambda e: e.configuration_index
      )
  
      index_best = -1  # not found
      # Find best index if there are metrics to compute. Absence of metrics to
      # compute means that this is SelectPartition analysis.
      if tune_options.aggregate_params.metrics:
          rmse = [
              ur.metric_errors[0].absolute_error.rmse
              for ur in sorted_utility_reports
          ]
          index_best = np.argmin(rmse)
  
      return TuneResult(
          tune_options,
          contribution_histograms,
          run_configurations,
          index_best,
          utility_reports=sorted_utility_reports,
      )
  
imports: import logging
  import math
  from numbers import Number
  import pipeline_dp
  from pipeline_dp import dp_computations
  from pipeline_dp import pipeline_backend
  from pipeline_dp import input_validators
  from pipeline_dp.dataset_histograms import histograms
  import analysis
  from analysis import metrics
  from analysis import utility_analysis
  from analysis import dp_strategy_selector
  import dataclasses
  from dataclasses import dataclass
  from typing import Callable, List, Optional, Tuple, Union, Sequence
  from enum import Enum
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: _convert_utility_analysis_to_tune_result(utility_reports, tune_options, run_configurations, use_public_partitions, contribution_histograms) and returns: TuneResult