class_docstr: Compute Exact match (also known as subset accuracy).
  
  Exact Match is a stricter version of accuracy where all labels have to match exactly for the sample to be
  correctly classified.
  
  This module is a simple wrapper to get the task specific versions of this metric, which is done by setting the
  ``task`` argument to either ``'multiclass'`` or ``multilabel``. See the documentation of
  :class:`~torchmetrics.classification.MulticlassExactMatch` and
  :class:`~torchmetrics.classification.MultilabelExactMatch` for the specific details of each argument influence and
  examples.
  
  Legacy Example:
      >>> from torch import tensor
      >>> 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 = ExactMatch(task="multiclass", num_classes=3, multidim_average='global')
      >>> metric(preds, target)
      tensor(0.5000)
  
      >>> 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 = ExactMatch(task="multiclass", num_classes=3, multidim_average='samplewise')
      >>> metric(preds, target)
      tensor([1., 0.])
class_docstr_tok: ["Compute","Exact","match","(","also","known","as","subset","accuracy",")",".","Exact","Match","is","a","stricter","version","of","accuracy","where","all","labels","have","to","match","exactly","for","the","sample","to","be","correctly","classified",".","This","module","is","a","simple","wrapper","to","get","the","task","specific","versions","of","this","metric",",","which","is","done","by","setting","the","``","task","``","argument","to","either","``","'multiclass","'","``","or","``","multilabel","``",".","See","the","documentation","of",":","class",":","`","~torchmetrics.classification.MulticlassExactMatch","`","and",":","class",":","`","~torchmetrics.classification.MultilabelExactMatch","`","for","the","specific","details","of","each","argument","influence","and","examples",".","Legacy","Example",":",">",">",">","from","torch","import","tensor",">",">",">","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","=","ExactMatch","(","task=","''","multiclass","''",",","num_classes=3",",","multidim_average='global","'",")",">",">",">","metric","(","preds",",","target",")","tensor","(","0.5000",")",">",">",">","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","=","ExactMatch","(","task=","''","multiclass","''",",","num_classes=3",",","multidim_average='samplewise","'",")",">",">",">","metric","(","preds",",","target",")","tensor","(","[","1.",",","0",".","]",")"]
docstr: Initialize task metric.
docstr_tok: ["Initialize","task","metric","."]
code: def __new__(
      cls: Type["ExactMatch"],
      task: Literal["binary", "multiclass", "multilabel"],
      threshold: float = 0.5,
      num_classes: Optional[int] = None,
      num_labels: Optional[int] = None,
      multidim_average: Literal["global", "samplewise"] = "global",
      ignore_index: Optional[int] = None,
      validate_args: bool = True,
      **kwargs: Any,
  ) -> Metric:
      """Initialize task metric."""
      task = ClassificationTaskNoBinary.from_str(task)
      kwargs.update(
          {
              "multidim_average": multidim_average,
              "ignore_index": ignore_index,
              "validate_args": validate_args,
          }
      )
      if task == ClassificationTaskNoBinary.MULTICLASS:
          if not isinstance(num_classes, int):
              raise ValueError(
                  f"`num_classes` is expected to be `int` but `{type(num_classes)} was passed.`"
              )
          return MulticlassExactMatch(num_classes, **kwargs)
      if task == ClassificationTaskNoBinary.MULTILABEL:
          if not isinstance(num_labels, int):
              raise ValueError(
                  f"`num_labels` is expected to be `int` but `{type(num_labels)} was passed.`"
              )
          return MultilabelExactMatch(num_labels, threshold, **kwargs)
      raise ValueError(f"Task {task} not supported!")
  
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 1 for calling the ExactMatch obj's underlying member method code with example usage: obj.__new__(cls, task, threshold, num_classes, num_labels, multidim_average, ignore_index, validate_args) and returns: MulticlassExactMatch, MultilabelExactMatch