class_docstr: Compute Exact match (also known as subset accuracy) for multiclass tasks.
  
  Exact Match is a stricter version of accuracy where all labels have to match exactly for the sample to be
  correctly classified.
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, ...)`` or float tensor of shape ``(N, C, ..)``.
    If preds is a floating point we apply ``torch.argmax`` along the ``C`` dimension to automatically convert
    probabilities/logits into an int tensor.
  - ``target`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, ...)``.
  
  As output to ``forward`` and ``compute`` the metric returns the following output:
  
  - ``mcem`` (:class:`~torch.Tensor`): A tensor whose returned shape depends on the ``multidim_average`` argument:
  
      - If ``multidim_average`` is set to ``global`` the output will be a scalar tensor
      - If ``multidim_average`` is set to ``samplewise`` the output will be a tensor of shape ``(N,)``
  
  If ``multidim_average`` is set to ``samplewise`` we expect at least one additional dimension ``...`` to be present,
  which the reduction will then be applied over instead of the sample dimension ``N``.
  
  Args:
      num_classes: Integer specifying the number of labels
      multidim_average:
          Defines how additionally dimensions ``...`` should be handled. Should be one of the following:
  
          - ``global``: Additional dimensions are flatted along the batch dimension
          - ``samplewise``: Statistic will be calculated independently for each sample on the ``N`` axis.
            The statistics in this case are calculated over the additional dimensions.
  
      ignore_index:
          Specifies a target value that is ignored and does not contribute to the metric calculation
      validate_args: bool indicating if input arguments and tensors should be validated for correctness.
          Set to ``False`` for faster computations.
  
  Example (multidim tensors):
      >>> from torch import tensor
      >>> from torchmetrics.classification import MulticlassExactMatch
      >>> target = tensor([[[0, 1], [2, 1], [0, 2]], [[1, 1], [2, 0], [1, 2]]])
      >>> preds = tensor([[[0, 1], [2, 1], [0, 2]], [[2, 2], [2, 1], [1, 0]]])
      >>> metric = MulticlassExactMatch(num_classes=3, multidim_average='global')
      >>> metric(preds, target)
      tensor(0.5000)
  
  Example (multidim tensors):
      >>> from torchmetrics.classification import MulticlassExactMatch
      >>> target = tensor([[[0, 1], [2, 1], [0, 2]], [[1, 1], [2, 0], [1, 2]]])
      >>> preds = tensor([[[0, 1], [2, 1], [0, 2]], [[2, 2], [2, 1], [1, 0]]])
      >>> metric = MulticlassExactMatch(num_classes=3, multidim_average='samplewise')
      >>> metric(preds, target)
      tensor([1., 0.])
class_docstr_tok: ["Compute","Exact","match","(","also","known","as","subset","accuracy",")","for","multiclass","tasks",".","Exact","Match","is","a","stricter","version","of","accuracy","where","all","labels","have","to","match","exactly","for","the","sample","to","be","correctly","classified",".","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input",":","-","``","preds","``","(",":","class",":","`","~torch.Tensor","`",")",":","An","int","tensor","of","shape","``","(","N",",","...",")","``","or","float","tensor","of","shape","``","(","N",",","C",",","..",")","``",".","If","preds","is","a","floating","point","we","apply","``","torch.argmax","``","along","the","``","C","``","dimension","to","automatically","convert","probabilities\/logits","into","an","int","tensor",".","-","``","target","``","(",":","class",":","`","~torch.Tensor","`",")",":","An","int","tensor","of","shape","``","(","N",",","...",")","``",".","As","output","to","``","forward","``","and","``","compute","``","the","metric","returns","the","following","output",":","-","``","mcem","``","(",":","class",":","`","~torch.Tensor","`",")",":","A","tensor","whose","returned","shape","depends","on","the","``","multidim_average","``","argument",":","-","If","``","multidim_average","``","is","set","to","``","global","``","the","output","will","be","a","scalar","tensor","-","If","``","multidim_average","``","is","set","to","``","samplewise","``","the","output","will","be","a","tensor","of","shape","``","(","N",",",")","``","If","``","multidim_average","``","is","set","to","``","samplewise","``","we","expect","at","least","one","additional","dimension","``","...","``","to","be","present",",","which","the","reduction","will","then","be","applied","over","instead","of","the","sample","dimension","``","N","``",".","Args",":","num_classes",":","Integer","specifying","the","number","of","labels","multidim_average",":","Defines","how","additionally","dimensions","``","...","``","should","be","handled",".","Should","be","one","of","the","following",":","-","``","global","``",":","Additional","dimensions","are","flatted","along","the","batch","dimension","-","``","samplewise","``",":","Statistic","will","be","calculated","independently","for","each","sample","on","the","``","N","``","axis",".","The","statistics","in","this","case","are","calculated","over","the","additional","dimensions",".","ignore_index",":","Specifies","a","target","value","that","is","ignored","and","does","not","contribute","to","the","metric","calculation","validate_args",":","bool","indicating","if","input","arguments","and","tensors","should","be","validated","for","correctness",".","Set","to","``","False","``","for","faster","computations",".","Example","(","multidim","tensors",")",":",">",">",">","from","torch","import","tensor",">",">",">","from","torchmetrics.classification","import","MulticlassExactMatch",">",">",">","target","=","tensor","(","[","[","[","0",",","1","]",",","[","2",",","1","]",",","[","0",",","2","]","]",",","[","[","1",",","1","]",",","[","2",",","0","]",",","[","1",",","2","]","]","]",")",">",">",">","preds","=","tensor","(","[","[","[","0",",","1","]",",","[","2",",","1","]",",","[","0",",","2","]","]",",","[","[","2",",","2","]",",","[","2",",","1","]",",","[","1",",","0","]","]","]",")",">",">",">","metric","=","MulticlassExactMatch","(","num_classes=3",",","multidim_average='global","'",")",">",">",">","metric","(","preds",",","target",")","tensor","(","0.5000",")","Example","(","multidim","tensors",")",":",">",">",">","from","torchmetrics.classification","import","MulticlassExactMatch",">",">",">","target","=","tensor","(","[","[","[","0",",","1","]",",","[","2",",","1","]",",","[","0",",","2","]","]",",","[","[","1",",","1","]",",","[","2",",","0","]",",","[","1",",","2","]","]","]",")",">",">",">","preds","=","tensor","(","[","[","[","0",",","1","]",",","[","2",",","1","]",",","[","0",",","2","]","]",",","[","[","2",",","2","]",",","[","2",",","1","]",",","[","1",",","0","]","]","]",")",">",">",">","metric","=","MulticlassExactMatch","(","num_classes=3",",","multidim_average='samplewise","'",")",">",">",">","metric","(","preds",",","target",")","tensor","(","[","1.",",","0",".","]",")"]
docstr: Update metric states with predictions and targets.
docstr_tok: ["Update","metric","states","with","predictions","and","targets","."]
code: def update(self, preds: Tensor, target: Tensor) -> None:
      """Update metric states with predictions and targets."""
      if self.validate_args:
          _multiclass_stat_scores_tensor_validation(
              preds,
              target,
              self.num_classes,
              self.multidim_average,
              self.ignore_index,
          )
      preds, target = _multiclass_stat_scores_format(preds, target, 1)
  
      correct, total = _multiclass_exact_match_update(
          preds, target, self.multidim_average, self.ignore_index
      )
      if self.multidim_average == "samplewise":
          self.correct.append(correct)
          self.total = total
      else:
          self.correct += correct
          self.total += total
  
imports: from typing import Any, Optional, Sequence, Type, Union
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.classification.base import _ClassificationTaskWrapper
  from torchmetrics.functional.classification.exact_match import _exact_match_reduce, _multiclass_exact_match_update, _multilabel_exact_match_update
  from torchmetrics.functional.classification.stat_scores import _multiclass_stat_scores_arg_validation, _multiclass_stat_scores_format, _multiclass_stat_scores_tensor_validation, _multilabel_stat_scores_arg_validation, _multilabel_stat_scores_format, _multilabel_stat_scores_tensor_validation
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.data import dim_zero_cat
  from torchmetrics.utilities.enums import ClassificationTaskNoBinary
  from torchmetrics.utilities.imports import _MATPLOTLIB_AVAILABLE
  from torchmetrics.utilities.plot import _AX_TYPE, _PLOT_OUT_TYPE
label_desc: Use image node_id 2 for calling the MulticlassExactMatch obj's underlying member method code with example usage: obj.update(preds, target) without return types