code: def calculate_error(
      n_samples: int,
      bucket_values: List[List[float]],
      bucket_confidence: List[List[float]],
      bucket_accuracy: List[List[float]],
  ) -> Tuple[float, float, float]:
      """
      Computes several metrics used to measure calibration error, including
      expected calibration error (ECE), maximum calibration error (MCE), and
      total calibration error (TCE).
      """
  
      assert (
          len(bucket_values)
          == len(bucket_confidence)
          == len(bucket_accuracy)
      )
      assert sum(map(len, bucket_values)) == n_samples
  
      expected_error, max_error, total_error = 0.0, 0.0, 0.0
      for bucket, accuracy, confidence in zip(
          bucket_values, bucket_accuracy, bucket_confidence
      ):
          if len(bucket) > 0:
              delta = abs(accuracy - confidence)
              expected_error += (len(bucket) / n_samples) * delta
              max_error = max(max_error, delta)
              total_error += delta
      return (
          expected_error * 100.0,
          max_error * 100.0,
          total_error * 100.0,
      )
  
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 4 for calling a global function with example usage: calculate_error(n_samples, bucket_values, bucket_confidence, bucket_accuracy) and returns: unknown,  unknown,  unknown