code: def _get_metric_value_with_ci(
      metric_value: metrics_for_slice_pb2.MetricValue,
      confidence_interval: metrics_for_slice_pb2.ConfidenceInterval,
  ) -> metrics_for_slice_pb2.MetricValue:
      """Converts a double_value metric to bounded_value if CIs are present.
  
      In order to display CIs in the UI, the confidence intervals when the lower and
      upper bound must be expressed in BoundedValues. Because the TFMa pipeline
      stores CIs in a separate message outside of the MetricValue, and stores the
      point estimates in the MetricValue.double_value, this function adapts the
      pipeline output protos to a format that will render CIs in the UI.
  
      Args:
        metric_value: The metric_value containing the point estimate
        confidence_interval: The confidence interval message containing the
          confidence intervals if any
  
      Returns:
        If the input metric_value contains a double_value and confidence_interval is
        non-empty, a MetricValue proto with a bounded_value field containing the CI
        lower and upper bounds. Otherwise, the input metric_value is return
        unchanged
      """
      if (
          confidence_interval.HasField("lower_bound")
          and confidence_interval.HasField("upper_bound")
          and metric_value.HasField("double_value")
      ):
          # If we have CI and double_value, convert to BoudedValue for display
          bounded_value = metrics_for_slice_pb2.BoundedValue(
              lower_bound=confidence_interval.lower_bound.double_value,
              upper_bound=confidence_interval.upper_bound.double_value,
              value=metric_value.double_value,
          )
          # setting bounded_value clears double_value in the sampe oneof scope
          metric_value.bounded_value.CopyFrom(bounded_value)
      return metric_value
  
imports: import json
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  from absl import logging
  from tensorflow_model_analysis.metrics import example_count
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import weighted_example_count
  from tensorflow_model_analysis.post_export_metrics import metric_keys
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
  from tensorflow_model_analysis.slicer import slicer_lib
  from tensorflow_model_analysis.view import view_types
  from google.protobuf import json_format
label_desc: Use image node_id 9 for calling a global function with example usage: _get_metric_value_with_ci(metric_value, confidence_interval) and returns: metric_value