code: def _netcal_multiclass_calibration_error(
      preds, target, n_bins, norm, ignore_index
  ):
      preds = preds.numpy()
      target = target.numpy().flatten()
      if not ((preds > 0) & (preds < 1)).all():
          preds = softmax(preds, 1)
      preds = np.moveaxis(preds, 1, -1).reshape((-1, preds.shape[1]))
      target, preds = remove_ignore_index(target, preds, ignore_index)
      metric = ECE if norm == "l1" else MCE
      return metric(n_bins).measure(preds, target)
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from netcal.metrics import ECE, MCE
  from scipy.special import expit
  from scipy.special import softmax
  from torchmetrics.classification.calibration_error import BinaryCalibrationError, CalibrationError, MulticlassCalibrationError
  from torchmetrics.functional.classification.calibration_error import binary_calibration_error, multiclass_calibration_error
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_1_13
  from unittests import NUM_CLASSES
  from unittests.classification.inputs import _binary_cases, _multiclass_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, inject_ignore_index, remove_ignore_index
label_desc: Use image node_id 3 for calling a global function with example usage: _netcal_multiclass_calibration_error(preds, target, n_bins, norm, ignore_index) and returns: metric