class_docstr: Compute `Accuracy`_.
  
  .. math::
      \text{Accuracy} = \frac{1}{N}\sum_i^N 1(y_i = \hat{y}_i)
  
  Where :math:`y` is a tensor of target values, and :math:`\hat{y}` is a tensor of predictions.
  
  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 ``'binary'``, ``'multiclass'`` or ``multilabel``. See the documentation of
  :class:`~torchmetrics.classification.BinaryAccuracy`, :class:`~torchmetrics.classification.MulticlassAccuracy` and
  :class:`~torchmetrics.classification.MultilabelAccuracy` for the specific details of each argument influence and
  examples.
  
  Legacy Example:
      >>> from torch import tensor
      >>> target = tensor([0, 1, 2, 3])
      >>> preds = tensor([0, 2, 1, 3])
      >>> accuracy = Accuracy(task="multiclass", num_classes=4)
      >>> accuracy(preds, target)
      tensor(0.5000)
  
      >>> target = tensor([0, 1, 2])
      >>> preds = tensor([[0.1, 0.9, 0], [0.3, 0.1, 0.6], [0.2, 0.5, 0.3]])
      >>> accuracy = Accuracy(task="multiclass", num_classes=3, top_k=2)
      >>> accuracy(preds, target)
      tensor(0.6667)
docstr: Initialize task metric.
docstr_tok: ["Initialize","task","metric","."]
code: def __new__(  # type: ignore[misc]
      cls: Type["Accuracy"],
      task: Literal["binary", "multiclass", "multilabel"],
      threshold: float = 0.5,
      num_classes: Optional[int] = None,
      num_labels: Optional[int] = None,
      average: Optional[
          Literal["micro", "macro", "weighted", "none"]
      ] = "micro",
      multidim_average: Literal["global", "samplewise"] = "global",
      top_k: Optional[int] = 1,
      ignore_index: Optional[int] = None,
      validate_args: bool = True,
      **kwargs: Any,
  ) -> Metric:
      """Initialize task metric."""
      task = ClassificationTask.from_str(task)
  
      kwargs.update(
          {
              "multidim_average": multidim_average,
              "ignore_index": ignore_index,
              "validate_args": validate_args,
          }
      )
  
      if task == ClassificationTask.BINARY:
          return BinaryAccuracy(threshold, **kwargs)
      if task == ClassificationTask.MULTICLASS:
          if not isinstance(num_classes, int):
              raise ValueError(
                  f"Optional arg `num_classes` must be type `int` when task is {task}. Got {type(num_classes)}"
              )
          if not isinstance(top_k, int):
              raise ValueError(
                  f"Optional arg `top_k` must be type `int` when task is {task}. Got {type(top_k)}"
              )
          return MulticlassAccuracy(
              num_classes, top_k, average, **kwargs
          )
      if task == ClassificationTask.MULTILABEL:
          if not isinstance(num_labels, int):
              raise ValueError(
                  f"Optional arg `num_labels` must be type `int` when task is {task}. Got {type(num_labels)}"
              )
          return MultilabelAccuracy(
              num_labels, threshold, average, **kwargs
          )
      raise ValueError(f"Not handled value: {task}")
  
imports: from typing import Any, Optional, Sequence, Type, Union
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.classification.base import _ClassificationTaskWrapper
  from torchmetrics.classification.stat_scores import BinaryStatScores, MulticlassStatScores, MultilabelStatScores
  from torchmetrics.functional.classification.accuracy import _accuracy_reduce
  from torchmetrics.metric import Metric
  from torchmetrics.utilities.enums import ClassificationTask
  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 Accuracy obj's underlying member method code with example usage: obj.__new__(cls, task, threshold, num_classes, num_labels, average, multidim_average, top_k, ignore_index, validate_args) and returns: BinaryAccuracy, MulticlassAccuracy, MultilabelAccuracy