class_docstr: Compute the `confusion matrix`_ for binary 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 binary tasks, the confusion matrix is a 2x2 matrix with the following structure:
  
  - :math:`C_{0, 0}`: True negatives
  - :math:`C_{0, 1}`: False positives
  - :math:`C_{1, 0}`: False negatives
  - :math:`C_{1, 1}`: True positives
  
  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`` (:class:`~torch.Tensor`): A tensor containing a ``(2, 2)`` matrix
  
  Additional dimension ``...`` will be flattened into the batch dimension.
  
  Args:
      threshold: Threshold for transforming probability to binary (0,1) predictions
      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 (preds is int tensor):
      >>> from torchmetrics.classification import BinaryConfusionMatrix
      >>> target = torch.tensor([1, 1, 0, 0])
      >>> preds = torch.tensor([0, 1, 0, 0])
      >>> bcm = BinaryConfusionMatrix()
      >>> bcm(preds, target)
      tensor([[2, 0],
              [1, 1]])
  
  Example (preds is float tensor):
      >>> from torchmetrics.classification import BinaryConfusionMatrix
      >>> target = torch.tensor([1, 1, 0, 0])
      >>> preds = torch.tensor([0.35, 0.85, 0.48, 0.01])
      >>> bcm = BinaryConfusionMatrix()
      >>> bcm(preds, target)
      tensor([[2, 0],
              [1, 1]])
class_docstr_tok: ["Compute","the","`","confusion","matrix","`","_","for","binary","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","binary","tasks",",","the","confusion","matrix","is","a","2x2","matrix","with","the","following","structure",":","-",":","math",":","`","C_","{","0",",","0","}","`",":","True","negatives","-",":","math",":","`","C_","{","0",",","1","}","`",":","False","positives","-",":","math",":","`","C_","{","1",",","0","}","`",":","False","negatives","-",":","math",":","`","C_","{","1",",","1","}","`",":","True","positives","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","``","(",":","class",":","`","~torch.Tensor","`",")",":","A","tensor","containing","a","``","(","2",",","2",")","``","matrix","Additional","dimension","``","...","``","will","be","flattened","into","the","batch","dimension",".","Args",":","threshold",":","Threshold","for","transforming","probability","to","binary","(","0,1",")","predictions","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","(","preds","is","int","tensor",")",":",">",">",">","from","torchmetrics.classification","import","BinaryConfusionMatrix",">",">",">","target","=","torch.tensor","(","[","1",",","1",",","0",",","0","]",")",">",">",">","preds","=","torch.tensor","(","[","0",",","1",",","0",",","0","]",")",">",">",">","bcm","=","BinaryConfusionMatrix","(",")",">",">",">","bcm","(","preds",",","target",")","tensor","(","[","[","2",",","0","]",",","[","1",",","1","]","]",")","Example","(","preds","is","float","tensor",")",":",">",">",">","from","torchmetrics.classification","import","BinaryConfusionMatrix",">",">",">","target","=","torch.tensor","(","[","1",",","1",",","0",",","0","]",")",">",">",">","preds","=","torch.tensor","(","[","0.35",",","0.85",",","0.48",",","0.01","]",")",">",">",">","bcm","=","BinaryConfusionMatrix","(",")",">",">",">","bcm","(","preds",",","target",")","tensor","(","[","[","2",",","0","]",",","[","1",",","1","]","]",")"]
docstr: Compute confusion matrix.
docstr_tok: ["Compute","confusion","matrix","."]
code: def compute(self) -> Tensor:
      """Compute confusion matrix."""
      return _binary_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 BinaryConfusionMatrix obj's underlying member method code with example usage: obj.compute() and returns: _binary_confusion_matrix_compute