code: def compute_diagnostics(result: List[CVResult]) -> CVDiagnostics:
      """Computes diagnostics for given cross validation results.
  
      It provides a dictionary with values for the following diagnostics, for
      each metric:
  
      - 'Mean prediction CI': the average width of the CIs at each of the CV
        predictions, relative to the observed mean.
      - 'MAPE': mean absolute percentage error of the estimated mean relative
        to the observed mean.
      - 'wMAPE': Weighted mean absolute percentage error.
      - 'Total raw effect': the multiple change from the smallest observed
        mean to the largest observed mean, i.e. `(max - min) / min`.
      - 'Correlation coefficient': the Pearson correlation of the estimated
        and observed means.
      - 'Rank correlation': the Spearman correlation of the estimated
        and observed means.
      - 'Fisher exact test p': we test if the model is able to distinguish the
        bottom half of the observations from the top half, using Fisher's
        exact test and the observed/estimated means. A low p value indicates
        that the model has some ability to identify good arms. A high p value
        indicates that the model cannot identify arms better than chance, or
        that the observations are too noisy to be able to tell.
  
      Each of these is returned as a dictionary from metric name to value for
      that metric.
  
      Args:
          result: Output of cross_validate
  
      Returns:
          A dictionary keyed by diagnostic name with results as described above.
      """
      # Extract per-metric outcomes from CVResults.
      y_obs = defaultdict(list)
      y_pred = defaultdict(list)
      se_pred = defaultdict(list)
      for res in result:
          for j, metric_name in enumerate(
              res.observed.data.metric_names
          ):
              y_obs[metric_name].append(res.observed.data.means[j])
              # Find the matching prediction
              k = res.predicted.metric_names.index(metric_name)
              y_pred[metric_name].append(res.predicted.means[k])
              se_pred[metric_name].append(
                  np.sqrt(res.predicted.covariance[k, k])
              )
      y_obs = _arrayify_dict_values(y_obs)
      y_pred = _arrayify_dict_values(y_pred)
      se_pred = _arrayify_dict_values(se_pred)
  
      diagnostic_fns = {
          MEAN_PREDICTION_CI: _mean_prediction_ci,
          MAPE: _mape,
          wMAPE: _wmape,
          TOTAL_RAW_EFFECT: _total_raw_effect,
          CORRELATION_COEFFICIENT: _correlation_coefficient,
          RANK_CORRELATION: _rank_correlation,
          FISHER_EXACT_TEST_P: _fisher_exact_test_p,
          LOG_LIKELIHOOD: _log_likelihood,
      }
      diagnostics = compute_model_fit_metrics(
          y_obs=y_obs,
          y_pred=y_pred,
          se_pred=se_pred,
          fit_metrics_dict=diagnostic_fns,
      )
      return diagnostics
  
imports: from abc import ABC, abstractmethod
  from collections import defaultdict
  from enum import Enum
  from functools import partial
  from logging import Logger
  from numbers import Number
  from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Set, Tuple
  import numpy
  from ax.core.observation import Observation, ObservationData
  from ax.core.optimization_config import OptimizationConfig
  from ax.modelbridge.base import ModelBridge
  from ax.utils.common.logger import get_logger
  from ax.utils.stats.model_fit_stats import _correlation_coefficient, _fisher_exact_test_p, _log_likelihood, _mape, _mean_prediction_ci, _rank_correlation, _total_raw_effect, _wmape, compute_model_fit_metrics
label_desc: Use image node_id 3 for calling a global function with example usage: compute_diagnostics(result) and returns: diagnostics