§
    ’©ºj!]  ã                   ó>  — d dl mZmZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d d	lmZ d d
lm Z m!Z!m"Z"m#Z# esg d¢Z$ G d„ de¦  «        Z% G d„ de¦  «        Z& G d„ de¦  «        Z' G d„ de¦  «        Z(dS )é    )ÚAnyÚOptionalN)ÚTensor)ÚLiteral)Ú_ClassificationTaskWrapper)Ú'_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)ÚMetric)ÚClassificationTask)Ú_MATPLOTLIB_AVAILABLE)Ú_AX_TYPEÚ
_CMAP_TYPEÚ_PLOT_OUT_TYPEÚplot_confusion_matrix)zBinaryConfusionMatrix.plotzMulticlassConfusionMatrix.plotzMultilabelConfusionMatrix.plotc                   ó4  ‡ — e Zd ZU dZdZeed<   dZee         ed<   dZ	eed<   e
ed<   	 	 	 	 dd
edee         deed                  dededdfˆ fd„Zde
de
ddfd„Zde
fd„Z	 	 	 	 	 ddee
         dee         dedeee                  dee         defd„Zˆ xZS )ÚBinaryConfusionMatrixa9  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]])

    FÚis_differentiableNÚhigher_is_betterÚfull_state_updateÚconfmatç      à?TÚ	thresholdÚignore_indexÚ	normalize©ÚtrueÚpredÚallÚnoneÚvalidate_argsÚkwargsÚreturnc                 ó  •—  t          ¦   «         j        di |¤Ž |rt          |||¦  «         || _        || _        || _        || _        |                      dt          j	        ddt          j
        ¬¦  «        d¬¦  «         d S ©Nr#   é   ©ÚdtypeÚsum©Údist_reduce_fx© )ÚsuperÚ__init__r   r%   r&   r'   r-   Ú	add_stateÚtorchÚzerosÚlong)Úselfr%   r&   r'   r-   r.   Ú	__class__s         €ú|/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/torchmetrics/classification/confusion_matrix.pyr:   zBinaryConfusionMatrix.__init__v   s�   ø€ ð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Øð 	XÝ3°I¸|ÈYÑWÔWÐWØ"ˆŒØ(ˆÔØ"ˆŒØ*ˆÔà�Š�y¥%¤+¨a°½%¼*Ð"EÑ"EÔ"EÐV[ˆÑ\Ô\Ð\Ð\Ð\ó    ÚpredsÚtargetc                 ó¾   — | j         rt          ||| j        ¦  «         t          ||| j        | j        ¦  «        \  }}t          ||¦  «        }| xj        |z  c_        dS ©z*Update state with predictions and targets.N)r-   r   r&   r
   r%   r   r#   ©r?   rC   rD   r#   s       rA   ÚupdatezBinaryConfusionMatrix.updateˆ   sc   € àÔð 	YÝ6°u¸fÀdÔFWÑXÔXÐXÝ7¸¸vÀtÄ~ÐW[ÔWhÑiÔi‰ˆˆvÝ1°%¸Ñ@Ô@ˆØˆŒ˜ÑˆŒˆˆrB   c                 ó6   — t          | j        | j        ¦  «        S ©zCompute confusion matrix.)r	   r#   r'   ©r?   s    rA   ÚcomputezBinaryConfusionMatrix.compute�   s   € å/°´¸d¼nÑMÔMÐMrB   ÚvalÚaxÚadd_textÚlabelsÚcmapc                 ó¶   — |�|n|                       ¦   «         }t          |t          ¦  «        st          d|› �¦  «        ‚t	          |||||¬¦  «        \  }}||fS ©a¼  Plot a single or multiple values from the metric.

        Args:
            val: Either a single result from calling `metric.forward` or `metric.compute` or a list of these results.
                If no value is provided, will automatically call `metric.compute` and plot that result.
            ax: An matplotlib axis object. If provided will add plot to that axis
            add_text: if the value of each cell should be added to the plot
            labels: a list of strings, if provided will be added to the plot to indicate the different classes
            cmap: matplotlib colormap to use for the confusion matrix
                https://matplotlib.org/stable/users/explain/colors/colormaps.html

        Returns:
            Figure and Axes object

        Raises:
            ModuleNotFoundError:
                If `matplotlib` is not installed

        .. plot::
            :scale: 75

            >>> from torch import randint
            >>> from torchmetrics.classification import MulticlassConfusionMatrix
            >>> metric = MulticlassConfusionMatrix(num_classes=5)
            >>> metric.update(randint(5, (20,)), randint(5, (20,)))
            >>> fig_, ax_ = metric.plot()

        Nz+Expected val to be a single tensor but got )rN   rO   rP   rQ   ©rL   Ú
isinstancer   Ú	TypeErrorr   ©r?   rM   rN   rO   rP   rQ   Úfigs          rA   ÚplotzBinaryConfusionMatrix.plot”   ój   € ðH �_ˆcˆc¨$¯,ª,©.¬.ˆÝ˜#�vÑ&Ô&ð 	QÝÐOÈ#ÐOÐOÑPÔPÐPÝ'¨°¸XÈfÐ[_Ð`Ñ`Ô`‰ˆˆRØ�BˆwˆrB   ©r$   NNT©NNTNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    ÚboolÚ__annotations__r!   r   r"   r   ÚfloatÚintr   r   r:   rH   rL   r   ÚlistÚstrr   r   rY   Ú__classcell__©r@   s   @rA   r   r   3   sº  ø€ € € € € € ð:ð :ðx $Ð�tÐ#Ð#Ñ#Ø'+Ð�h˜t”nÐ+Ð+Ñ+Ø#Ð�tÐ#Ð#Ñ#à€O€O�Oð Ø&*ØFJØ"ð]ð ]àð]ð ˜s”mð]ð ˜GÐ$AÔBÔCð	]ð
 ð]ð ð]ð 
ð]ð ]ð ]ð ]ð ]ð ]ð$ ˜Fð  ¨Fð  °tð  ð  ð  ð  ðN˜ð Nð Nð Nð Nð !%Ø!%ØØ&*Ø%)ð(ð (à�fÔð(ð �XÔð(ð ð	(ð
 ˜˜cœÔ#ð(ð �zÔ"ð(ð 
ð(ð (ð (ð (ð (ð (ð (ð (rB   r   c                   ó2  ‡ — e Zd ZU dZdZeed<   dZee         ed<   dZ	eed<   e
ed<   	 	 	 dd	ed
ee         deed                  dededdfˆ fd„Zde
de
ddfd„Zde
fd„Z	 	 	 	 	 ddee
         dee         dedeee                  dee         defd„Zˆ xZS )ÚMulticlassConfusionMatrixa±  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_{j=1, j\neq i}^N C_{j, i}` 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]])

    Fr    Nr!   r"   r#   TÚnum_classesr&   r'   ©r,   r)   r*   r+   r-   r.   r/   c                 ó  •—  t          ¦   «         j        di |¤Ž |rt          |||¦  «         || _        || _        || _        || _        |                      dt          j	        ||t          j
        ¬¦  «        d¬¦  «         d S )Nr#   r3   r5   r6   r8   )r9   r:   r   rk   r&   r'   r-   r;   r<   r=   r>   )r?   rk   r&   r'   r-   r.   r@   s         €rA   r:   z"MulticlassConfusionMatrix.__init__  s�   ø€ ð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Øð 	^Ý7¸À\ÐS\Ñ]Ô]Ð]Ø&ˆÔØ(ˆÔØ"ˆŒØ*ˆÔà�Š�y¥%¤+¨k¸;ÍeÌjÐ"YÑ"YÔ"YÐjoˆÑpÔpÐpÐpÐprB   rC   rD   c                 óÊ   — | j         rt          ||| j        | j        ¦  «         t	          ||| j        ¦  «        \  }}t          ||| j        ¦  «        }| xj        |z  c_        dS rF   )r-   r   rk   r&   r   r   r#   rG   s       rA   rH   z MulticlassConfusionMatrix.update  si   € àÔð 	oÝ:¸5À&È$ÔJZÐ\`Ô\mÑnÔnÐnÝ;¸EÀ6È4ÔK\Ñ]Ô]‰ˆˆvÝ5°e¸VÀTÔEUÑVÔVˆØˆŒ˜ÑˆŒˆˆrB   c                 ó6   — t          | j        | j        ¦  «        S rJ   )r   r#   r'   rK   s    rA   rL   z!MulticlassConfusionMatrix.compute   ó   € å3°D´LÀ$Ä.ÑQÔQÐQrB   rM   rN   rO   rP   rQ   c                 ó¶   — |�|n|                       ¦   «         }t          |t          ¦  «        st          d|› �¦  «        ‚t	          |||||¬¦  «        \  }}||fS rS   rT   rW   s          rA   rY   zMulticlassConfusionMatrix.plot$  rZ   rB   )NNTr\   )r]   r^   r_   r`   r    ra   rb   r!   r   r"   r   rd   r   r   r:   rH   rL   r   re   rf   r   r   rY   rg   rh   s   @rA   rj   rj   ¿   s·  ø€ € € € € € ð>ð >ð@ $Ð�tÐ#Ð#Ñ#Ø'+Ð�h˜t”nÐ+Ð+Ñ+Ø#Ð�tÐ#Ð#Ñ#à€O€O�Oð
 '+ØFJØ"ðqð qàðqð ˜s”mðqð ˜GÐ$AÔBÔCð	qð
 ðqð ðqð 
ðqð qð qð qð qð qð$ ˜Fð  ¨Fð  °tð  ð  ð  ð  ðR˜ð Rð Rð Rð Rð !%Ø!%ØØ&*Ø%)ð(ð (à�fÔð(ð �XÔð(ð ð	(ð
 ˜˜cœÔ#ð(ð �zÔ"ð(ð 
ð(ð (ð (ð (ð (ð (ð (ð (rB   rj   c                   ó8  ‡ — e Zd ZU dZdZeed<   dZee         ed<   dZ	eed<   e
ed<   	 	 	 	 dd
ededee         deed                  dededdfˆ fd„Zde
de
ddfd„Zde
fd„Z	 	 	 	 	 ddee
         dee         dedeee                  dee         defd„Zˆ xZS )ÚMultilabelConfusionMatrixaÙ  Compute the `confusion matrix`_ for multilabel 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 multilabel tasks, the confusion matrix is a Nx2x2 tensor, where each 2x2 matrix corresponds to the confusion
    for that label. The structure of each 2x2 matrix is as follows:

    - :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 'update' the metric accepts the following input:

    - ``preds`` (int or float tensor): ``(N, C, ...)``. 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, C, ...)``

    As output of 'compute' the metric returns the following output:

    - ``confusion matrix``: [num_labels,2,2] matrix

    Args:
        num_classes: Integer specifying the number of 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
        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 torch import tensor
        >>> from torchmetrics.classification import MultilabelConfusionMatrix
        >>> target = tensor([[0, 1, 0], [1, 0, 1]])
        >>> preds = tensor([[0, 0, 1], [1, 0, 1]])
        >>> metric = MultilabelConfusionMatrix(num_labels=3)
        >>> metric(preds, target)
        tensor([[[1, 0], [0, 1]],
                [[1, 0], [1, 0]],
                [[0, 1], [0, 1]]])

    Example (preds is float tensor):
        >>> from torchmetrics.classification import MultilabelConfusionMatrix
        >>> target = tensor([[0, 1, 0], [1, 0, 1]])
        >>> preds = tensor([[0.11, 0.22, 0.84], [0.73, 0.33, 0.92]])
        >>> metric = MultilabelConfusionMatrix(num_labels=3)
        >>> metric(preds, target)
        tensor([[[1, 0], [0, 1]],
                [[1, 0], [1, 0]],
                [[0, 1], [0, 1]]])

    Fr    Nr!   r"   r#   r$   TÚ
num_labelsr%   r&   r'   rl   r-   r.   r/   c           	      ó  •—  t          ¦   «         j        di |¤Ž |rt          ||||¦  «         || _        || _        || _        || _        || _        |                      dt          j
        |ddt          j        ¬¦  «        d¬¦  «         d S r1   )r9   r:   r   rt   r%   r&   r'   r-   r;   r<   r=   r>   )r?   rt   r%   r&   r'   r-   r.   r@   s          €rA   r:   z"MultilabelConfusionMatrix.__init__•  s™   ø€ ð 	�‰ŒÔÐ"Ð"˜6Ð"Ð"Ð"Øð 	hÝ7¸
ÀIÈ|Ð]fÑgÔgÐgØ$ˆŒØ"ˆŒØ(ˆÔØ"ˆŒØ*ˆÔà�Š�y¥%¤+¨j¸!¸QÅeÄjÐ"QÑ"QÔ"QÐbgˆÑhÔhÐhÐhÐhrB   rC   rD   c                 óâ   — | j         rt          ||| j        | j        ¦  «         t	          ||| j        | j        | j        ¦  «        \  }}t          ||| j        ¦  «        }| xj        |z  c_        dS rF   )r-   r   rt   r&   r   r%   r   r#   rG   s       rA   rH   z MultilabelConfusionMatrix.update©  sv   € àÔð 	nÝ:¸5À&È$Ì/Ð[_Ô[lÑmÔmÐmÝ;Ø�6˜4œ?¨D¬N¸DÔ<Mñ
ô 
‰ˆˆvõ 6°e¸VÀTÄ_ÑUÔUˆØˆŒ˜ÑˆŒˆˆrB   c                 ó6   — t          | j        | j        ¦  «        S rJ   )r   r#   r'   rK   s    rA   rL   z!MultilabelConfusionMatrix.compute³  rp   rB   rM   rN   rO   rP   rQ   c                 ó¶   — |�|n|                       ¦   «         }t          |t          ¦  «        st          d|› �¦  «        ‚t	          |||||¬¦  «        \  }}||fS rS   rT   rW   s          rA   rY   zMultilabelConfusionMatrix.plot·  rZ   rB   r[   r\   )r]   r^   r_   r`   r    ra   rb   r!   r   r"   r   rd   rc   r   r   r:   rH   rL   r   re   rf   r   r   rY   rg   rh   s   @rA   rs   rs   O  sÅ  ø€ € € € € € ð=ð =ð~ $Ð�tÐ#Ð#Ñ#Ø'+Ð�h˜t”nÐ+Ð+Ñ+Ø#Ð�tÐ#Ð#Ñ#à€O€O�Oð
 Ø&*ØFJØ"ðið iàðið ðið ˜s”mð	ið
 ˜GÐ$AÔBÔCðið ðið ðið 
ðið ið ið ið ið ið( ˜Fð  ¨Fð  °tð  ð  ð  ð  ðR˜ð Rð Rð Rð Rð !%Ø!%ØØ&*Ø%)ð(ð (à�fÔð(ð �XÔð(ð ð	(ð
 ˜˜cœÔ#ð(ð �zÔ"ð(ð 
ð(ð (ð (ð (ð (ð (ð (ð (rB   rs   c                   ó¤   — e Zd ZdZ	 	 	 	 	 	 dded          ded         ded	ee         d
ee         deed                  dee         de	de
defd„ZdS )ÚConfusionMatrixa‹  Compute the `confusion matrix`_.

    This function 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.BinaryConfusionMatrix`,
    :class:`~torchmetrics.classification.MulticlassConfusionMatrix` and
    :class:`~torchmetrics.classification.MultilabelConfusionMatrix` for the specific details of each argument influence
    and examples.

    Legacy Example:
        >>> from torch import tensor
        >>> target = tensor([1, 1, 0, 0])
        >>> preds = tensor([0, 1, 0, 0])
        >>> confmat = ConfusionMatrix(task="binary", num_classes=2)
        >>> confmat(preds, target)
        tensor([[2, 0],
                [1, 1]])

        >>> target = tensor([2, 1, 0, 0])
        >>> preds = tensor([2, 1, 0, 1])
        >>> confmat = ConfusionMatrix(task="multiclass", num_classes=3)
        >>> confmat(preds, target)
        tensor([[1, 1, 0],
                [0, 1, 0],
                [0, 0, 1]])

        >>> target = tensor([[0, 1, 0], [1, 0, 1]])
        >>> preds = tensor([[0, 0, 1], [1, 0, 1]])
        >>> confmat = ConfusionMatrix(task="multilabel", num_labels=3)
        >>> confmat(preds, target)
        tensor([[[1, 0], [0, 1]],
                [[1, 0], [1, 0]],
                [[0, 1], [0, 1]]])

    r$   NTÚclsÚtask)ÚbinaryÚ
multiclassÚ
multilabelr%   rk   rt   r'   r(   r&   r-   r.   r/   c                 ó  — t          j        |¦  «        }|                     |||dœ¦  «         |t           j        k    rt	          |fi |¤ŽS |t           j        k    rBt          |t          ¦  «        s t          dt          |¦  «        › d�¦  «        ‚t          |fi |¤ŽS |t           j        k    rCt          |t          ¦  «        s t          dt          |¦  «        › d�¦  «        ‚t          ||fi |¤ŽS t          d|› d�¦  «        ‚)zInitialize task metric.)r'   r&   r-   z+`num_classes` is expected to be `int` but `z was passed.`z*`num_labels` is expected to be `int` but `zTask z not supported!)r   Úfrom_strrH   ÚBINARYr   Ú
MULTICLASSrU   rd   Ú
ValueErrorÚtyperj   Ú
MULTILABELrs   )	r{   r|   r%   rk   rt   r'   r&   r-   r.   s	            rA   Ú__new__zConfusionMatrix.__new__  s(  € õ "Ô*¨4Ñ0Ô0ˆØ�Š I¸|Ð^kÐlÐlÑmÔmÐmØÕ%Ô,Ò,Ð,Ý(¨Ð=Ð=°fÐ=Ð=Ð=ØÕ%Ô0Ò0Ð0Ý˜k­3Ñ/Ô/ð qÝ Ð!oÍtÐT_ÑO`ÔO`Ð!oÐ!oÐ!oÑpÔpÐpÝ,¨[ÐCÐC¸FÐCÐCÐCØÕ%Ô0Ò0Ð0Ý˜j­#Ñ.Ô.ð oÝ Ð!mÍdÐS]ÑN^ÔN^Ð!mÐ!mÐ!mÑnÔnÐnÝ,¨Z¸ÐMÐMÀfÐMÐMÐMÝÐ6 Ð6Ð6Ð6Ñ7Ô7Ð7rB   )r$   NNNNT)r]   r^   r_   r`   r…   r   rc   r   rd   ra   r   r   r‡   r8   rB   rA   rz   rz   â  sÏ   € € € € € ð"ð "ðN Ø%)Ø$(ØFJØ&*Ø"ð8ð 8ØÐ#Ô$ð8àÐ:Ô;ð8ð ð8ð ˜c”]ð	8ð
 ˜S”Mð8ð ˜GÐ$AÔBÔCð8ð ˜s”mð8ð ð8ð ð8ð 
ð8ð 8ð 8ð 8ð 8ð 8rB   rz   ))Útypingr   r   r<   r   Útyping_extensionsr   Ú torchmetrics.classification.baser   Ú7torchmetrics.functional.classification.confusion_matrixr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   Útorchmetrics.metricr   Útorchmetrics.utilities.enumsr   Útorchmetrics.utilities.importsr   Útorchmetrics.utilities.plotr   r   r   r   Ú__doctest_skip__r   rj   rs   rz   r8   rB   rA   ú<module>r‘      sL  ðð !Ð  Ð  Ð  Ð  Ð  Ð  Ð  à €€€Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à GÐ GÐ GÐ GÐ GÐ Gðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð" 'Ð &Ð &Ð &Ð &Ð &Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø @Ð @Ð @Ð @Ð @Ð @Ø cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ cÐ càð ðð ð ÐðIð Ið Ið Ið I˜Fñ Iô Ið IðXMð Mð Mð Mð M ñ Mô Mð Mð`Pð Pð Pð Pð P ñ Pô Pð Pðf=8ð =8ð =8ð =8ð =8Ð0ñ =8ô =8ð =8ð =8ð =8rB   