code: def compute_calibration(
      label_predictions: List[LabelPrediction],
  ) -> Tuple[float, float, float]:
      conf_list = [
          math.exp(
              prediction.label_scores[prediction.predicted_label]
          )  # exp(log(p))
          for prediction in label_predictions
      ]
      pred_list = [
          prediction.predicted_label for prediction in label_predictions
      ]
      true_list = [
          prediction.expected_label for prediction in label_predictions
      ]
  
      bucket_values, bucket_indices = get_bucket_scores(conf_list)
      bucket_confidence = get_bucket_confidence(bucket_values)
      bucket_accuracy = get_bucket_accuracy(
          bucket_indices, true_list, pred_list
      )
  
      expected_error, max_error, total_error = calculate_error(
          n_samples=len(conf_list),
          bucket_values=bucket_values,
          bucket_confidence=bucket_confidence,
          bucket_accuracy=bucket_accuracy,
      )
  
      return CalibrationMetrics(
          expected_error=expected_error,
          max_error=max_error,
          total_error=total_error,
      )
  
file_path: pytext/pytext/metrics/calibration_metrics.py
imports: import math
  from typing import Dict, List, NamedTuple, Tuple
  import numpy
  from pytext.metrics import LabelPrediction
label_desc: Use image node_id 5 for calling a global function with example usage: compute_calibration(label_predictions) and returns: CalibrationMetrics