code: def binary_matthews_corrcoef(
      preds: Tensor,
      target: Tensor,
      threshold: float = 0.5,
      ignore_index: Optional[int] = None,
      validate_args: bool = True,
  ) -> Tensor:
      r"""Calculate `Matthews correlation coefficient`_ for binary tasks.
  
      This metric measures the general correlation or quality of a classification.
  
      Accepts the following input tensors:
  
      - ``preds`` (int or float tensor): ``(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`` (int tensor): ``(N, ...)``
  
      Additional dimension ``...`` will be flattened into the batch dimension.
  
      Args:
          preds: Tensor with predictions
          target: Tensor with true labels
          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
          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 torch import tensor
          >>> from torchmetrics.functional.classification import binary_matthews_corrcoef
          >>> target = tensor([1, 1, 0, 0])
          >>> preds = tensor([0, 1, 0, 0])
          >>> binary_matthews_corrcoef(preds, target)
          tensor(0.5774)
  
      Example (preds is float tensor):
          >>> from torchmetrics.functional.classification import binary_matthews_corrcoef
          >>> target = tensor([1, 1, 0, 0])
          >>> preds = tensor([0.35, 0.85, 0.48, 0.01])
          >>> binary_matthews_corrcoef(preds, target)
          tensor(0.5774)
  
      """
      if validate_args:
          _binary_confusion_matrix_arg_validation(
              threshold, ignore_index, normalize=None
          )
          _binary_confusion_matrix_tensor_validation(
              preds, target, ignore_index
          )
      preds, target = _binary_confusion_matrix_format(
          preds, target, threshold, ignore_index
      )
      confmat = _binary_confusion_matrix_update(preds, target)
      return _matthews_corrcoef_reduce(confmat)
  
file_path: torchmetrics/src/torchmetrics/functional/classification/matthews_corrcoef.py
imports: from typing import Optional
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.functional.classification.confusion_matrix import _binary_confusion_matrix_arg_validation, _binary_confusion_matrix_format, _binary_confusion_matrix_tensor_validation, _binary_confusion_matrix_update, _multiclass_confusion_matrix_arg_validation, _multiclass_confusion_matrix_format, _multiclass_confusion_matrix_tensor_validation, _multiclass_confusion_matrix_update, _multilabel_confusion_matrix_arg_validation, _multilabel_confusion_matrix_format, _multilabel_confusion_matrix_tensor_validation, _multilabel_confusion_matrix_update
  from torchmetrics.utilities.enums import ClassificationTask
label_desc: Use image node_id 2 for calling a global function with example usage: binary_matthews_corrcoef(preds, target, threshold, ignore_index, validate_args) and returns: _matthews_corrcoef_reduce