class_docstr: Compute the `confusion matrix`_ for multiclass tasks.
  
  The confusion matrix :math:`C` is constructed such that :math:`C_{i, j}` is equal to the number of observations
  known to be in class :math:`i` but predicted to be in class :math:`j`. Thus row indices of the confusion matrix
  correspond to the true class labels and column indices correspond to the predicted class labels.
  
  For multiclass tasks, the confusion matrix is a NxN matrix, where:
  
  - :math:`C_{i, i}` represents the number of true positives for class :math:`i`
  - :math:`\sum_{j=1, j\neq i}^N C_{i, j}` represents the number of false negatives for class :math:`i`
  - :math:`\sum_{i=1, i\neq j}^N C_{i, j}` represents the number of false positives for class :math:`i`
  - the sum of the remaining cells in the matrix represents the number of true negatives for class :math:`i`
  
  As input to ``forward`` and ``update`` the metric accepts the following input:
  
  - ``preds`` (:class:`~torch.Tensor`): An int or float tensor of shape ``(N, ...)``. If preds is a floating point
    tensor with values outside [0,1] range we consider the input to be logits and will auto apply sigmoid per
    element. Additionally, we convert to int tensor with thresholding using the value in ``threshold``.
  - ``target`` (:class:`~torch.Tensor`): An int tensor of shape ``(N, ...)``.
  
  As output to ``forward`` and ``compute`` the metric returns the following output:
  
  - ``confusion_matrix``: [num_classes, num_classes] matrix
  
  Args:
      num_classes: Integer specifying the number of classes
      ignore_index:
          Specifies a target value that is ignored and does not contribute to the metric calculation
      normalize: Normalization mode for confusion matrix. Choose from:
  
          - ``None`` or ``'none'``: no normalization (default)
          - ``'true'``: normalization over the targets (most commonly used)
          - ``'pred'``: normalization over the predictions
          - ``'all'``: normalization over the whole matrix
      validate_args: bool indicating if input arguments and tensors should be validated for correctness.
          Set to ``False`` for faster computations.
      kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.
  
  Example (pred is integer tensor):
      >>> from torch import tensor
      >>> from torchmetrics.classification import MulticlassConfusionMatrix
      >>> target = tensor([2, 1, 0, 0])
      >>> preds = tensor([2, 1, 0, 1])
      >>> metric = MulticlassConfusionMatrix(num_classes=3)
      >>> metric(preds, target)
      tensor([[1, 1, 0],
              [0, 1, 0],
              [0, 0, 1]])
  
  Example (pred is float tensor):
      >>> from torchmetrics.classification import MulticlassConfusionMatrix
      >>> target = tensor([2, 1, 0, 0])
      >>> preds = tensor([[0.16, 0.26, 0.58],
      ...                 [0.22, 0.61, 0.17],
      ...                 [0.71, 0.09, 0.20],
      ...                 [0.05, 0.82, 0.13]])
      >>> metric = MulticlassConfusionMatrix(num_classes=3)
      >>> metric(preds, target)
      tensor([[1, 1, 0],
              [0, 1, 0],
              [0, 0, 1]])
class_docstr_tok: ["Compute","the","`","confusion","matrix","`","_","for","multiclass","tasks",".","The","confusion","matrix",":","math",":","`","C","`","is","constructed","such","that",":","math",":","`","C_","{","i",",","j","}","`","is","equal","to","the","number","of","observations","known","to","be","in","class",":","math",":","`","i","`","but","predicted","to","be","in","class",":","math",":","`","j","`",".","Thus","row","indices","of","the","confusion","matrix","correspond","to","the","true","class","labels","and","column","indices","correspond","to","the","predicted","class","labels",".","For","multiclass","tasks",",","the","confusion","matrix","is","a","NxN","matrix",",","where",":","-",":","math",":","`","C_","{","i",",","i","}","`","represents","the","number","of","true","positives","for","class",":","math",":","`","i","`","-",":","math",":","`","\\sum_","{","j=1",",","j\\neq","i","}","^N","C_","{","i",",","j","}","`","represents","the","number","of","false","negatives","for","class",":","math",":","`","i","`","-",":","math",":","`","\\sum_","{","i=1",",","i\\neq","j","}","^N","C_","{","i",",","j","}","`","represents","the","number","of","false","positives","for","class",":","math",":","`","i","`","-","the","sum","of","the","remaining","cells","in","the","matrix","represents","the","number","of","true","negatives","for","class",":","math",":","`","i","`","As","input","to","``","forward","``","and","``","update","``","the","metric","accepts","the","following","input",":","-","``","preds","``","(",":","class",":","`","~torch.Tensor","`",")",":","An","int","or","float","tensor","of","shape","``","(","N",",","...",")","``",".","If","preds","is","a","floating","point","tensor","with","values","outside","[","0,1","]","range","we","consider","the","input","to","be","logits","and","will","auto","apply","sigmoid","per","element",".","Additionally",",","we","convert","to","int","tensor","with","thresholding","using","the","value","in","``","threshold","``",".","-","``","target","``","(",":","class",":","`","~torch.Tensor","`",")",":","An","int","tensor","of","shape","``","(","N",",","...",")","``",".","As","output","to","``","forward","``","and","``","compute","``","the","metric","returns","the","following","output",":","-","``","confusion_matrix","``",":","[","num_classes",",","num_classes","]","matrix","Args",":","num_classes",":","Integer","specifying","the","number","of","classes","ignore_index",":","Specifies","a","target","value","that","is","ignored","and","does","not","contribute","to","the","metric","calculation","normalize",":","Normalization","mode","for","confusion","matrix",".","Choose","from",":","-","``","None","``","or","``","'none","'","``",":","no","normalization","(","default",")","-","``","'true","'","``",":","normalization","over","the","targets","(","most","commonly","used",")","-","``","'pred","'","``",":","normalization","over","the","predictions","-","``","'all","'","``",":","normalization","over","the","whole","matrix","validate_args",":","bool","indicating","if","input","arguments","and","tensors","should","be","validated","for","correctness",".","Set","to","``","False","``","for","faster","computations",".","kwargs",":","Additional","keyword","arguments",",","see",":","ref",":","`","Metric","kwargs","`","for","more","info",".","Example","(","pred","is","integer","tensor",")",":",">",">",">","from","torch","import","tensor",">",">",">","from","torchmetrics.classification","import","MulticlassConfusionMatrix",">",">",">","target","=","tensor","(","[","2",",","1",",","0",",","0","]",")",">",">",">","preds","=","tensor","(","[","2",",","1",",","0",",","1","]",")",">",">",">","metric","=","MulticlassConfusionMatrix","(","num_classes=3",")",">",">",">","metric","(","preds",",","target",")","tensor","(","[","[","1",",","1",",","0","]",",","[","0",",","1",",","0","]",",","[","0",",","0",",","1","]","]",")","Example","(","pred","is","float","tensor",")",":",">",">",">","from","torchmetrics.classification","import","MulticlassConfusionMatrix",">",">",">","target","=","tensor","(","[","2",",","1",",","0",",","0","]",")",">",">",">","preds","=","tensor","(","[","[","0.16",",","0.26",",","0.58","]",",","...","[","0.22",",","0.61",",","0.17","]",",","...","[","0.71",",","0.09",",","0.20","]",",","...","[","0.05",",","0.82",",","0.13","]","]",")",">",">",">","metric","=","MulticlassConfusionMatrix","(","num_classes=3",")",">",">",">","metric","(","preds",",","target",")","tensor","(","[","[","1",",","1",",","0","]",",","[","0",",","1",",","0","]",",","[","0",",","0",",","1","]","]",")"]
docstr: Compute confusion matrix.
docstr_tok: ["Compute","confusion","matrix","."]
code: def compute(self) -> Tensor:
      """Compute confusion matrix."""
      return _multiclass_confusion_matrix_compute(
          self.confmat, self.normalize
      )
  
imports: from typing import Any, List, Optional, Type
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.classification.base import _ClassificationTaskWrapper
  from torchmetrics.functional.classification.confusion_matrix import _binary_confusion_matrix_arg_validation, _binary_confusion_matrix_compute, _binary_confusion_matrix_format, _binary_confusion_matrix_tensor_validation, _binary_confusion_matrix_update, _multiclass_confusion_matrix_arg_validation, _multiclass_confusion_matrix_compute, _multiclass_confusion_matrix_format, _multiclass_confusion_matrix_tensor_validation, _multiclass_confusion_matrix_update, _multilabel_confusion_matrix_arg_validation, _multilabel_confusion_matrix_compute, _multilabel_confusion_matrix_format, _multilabel_confusion_matrix_tensor_validation, _multilabel_confusion_matrix_update
  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, plot_confusion_matrix
label_desc: Use image node_id 3 for calling the MulticlassConfusionMatrix obj's underlying member method code with example usage: obj.compute() and returns: _multiclass_confusion_matrix_compute