code: def _baseline_exact_match_multiclass(
      preds, target, ignore_index, multidim_average
  ):
      if preds.ndim == target.ndim + 1:
          preds = torch.argmax(preds, 1)
      preds = preds.numpy()
      target = target.numpy()
  
      if ignore_index is not None:
          preds = np.copy(preds)
          preds[target == ignore_index] = ignore_index
  
      correct = (preds == target).sum(-1) == preds.shape[1]
      correct = (
          correct.sum() if multidim_average == "global" else correct
      )
      total = len(preds) if multidim_average == "global" else 1
      return correct / total
  
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from scipy.special import expit
  from torchmetrics.classification.exact_match import ExactMatch, MulticlassExactMatch, MultilabelExactMatch
  from torchmetrics.functional.classification.exact_match import multiclass_exact_match, multilabel_exact_match
  from torchmetrics.metric import Metric
  from unittests import NUM_CLASSES, THRESHOLD
  from unittests.classification.inputs import _multiclass_cases, _multilabel_cases
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester, inject_ignore_index
label_desc: Use image node_id 1 for calling a global function with example usage: _baseline_exact_match_multiclass(preds, target, ignore_index, multidim_average) and returns: unknown