+
    åûj¯  ã                   óR   € ^ RI t ^ RIHtHt ^ RIHt R R ltR R ltR
R R	 lltR# )é    N)ÚKORNIA_CHECKÚKORNIA_CHECK_IS_TENSOR)Úis_compilingc                óH   € V ^8„  d   QhR\         R\        P                  RR/# )é   ÚnameÚlabelsÚreturnN)ÚstrÚtorchÚTensor)Úformats   "Ú[C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\metrics\confusion_matrix.pyÚ__annotate__r      s%   € ÷ ñ œð ¤U§\¡\ð °dñ ó    c                 óÌ   € \        VR V  R24       \        VP                  P                  ;'       g    VP                  P                  '       * R V  RVP                   24       R# )úInput z# must be a tensor of integer labelsz! must have an integer dtype. Got N)r   r   ÚdtypeÚis_floating_pointÚ
is_complex)r   r	   s   &&r   Ú_check_labelsr      sU   € Ü˜6 V¨D¨6Ð1TÐ#UÔVäØ�\‰\×+Ñ+×FÐF¨v¯|©|×/FÑ/FÔGØ
��Ð7¸¿¹°~ÐFör   c                óT   € V ^8„  d   QhR\         R\        P                  R\        RR/# )r   r   r	   Únum_classesr
   N)r   r   r   Úint)r   s   "r   r   r   $   s,   € ÷ ñ œSð ¬%¯,©,ð ÄSð ÈTñ r   c                 óº   a aaa€ \        VP                  4       4      \        VP                  4       4      uoo\        ^ S8*  ;'       d    SS8  VVV V3R l4       R# )r   c            	      ó"   <€ R S RS RS RS  R2	# )r   z must contain values in [0, z). Got values in [z, Ú]© )ÚhighÚlowr   r   s   €€€€r   Ú<lambda>Ú$_check_label_range.<locals>.<lambda>(   s(   ø€ �&˜˜Ð:¸;¸-ÐGYÐZ]ÐY^Ð^`ÐaeÐ`fÐfgÑhr   N)r   ÚminÚmaxr   )r   r	   r   r   r    s   f&f@@r   Ú_check_label_ranger%   $   sC   û€ Ü�F—J‘J“LÓ!¤3 v§z¡z£|Ó#4€I€CˆÜØ	ˆS‰×'Ð'�T˜KÑ'ßhör   c          
      ó�   € V ^8„  d   QhR\         P                  R\         P                  R\        R\        R\         P                  /# )r   ÚpredÚtargetr   Ú
normalizedr
   )r   r   r   Úbool)r   s   "r   r   r   ,   sG   € ÷ Wñ WÜ
�,‰,ðWÜ %§¡ðWÜ;>ðWÜLPðWä
‡\�\ñWr   c                óò  € \        RV 4       \        RV4       V P                  VP                  8X  g&   \        RV P                   RVP                   24      hV P                  VP                  8X  g&   \        RV P                   RVP                   24      h\	        V\
        4      '       d   V^8  d   \        RV 24      hV P                  ^ ,          pV^ 8X  d3   \        P                  ! ^ W"V P                  \        P                  R7      # \        4       '       g.   V P                  4       ^ 8”  d   \        RW4       \        RW4       V P                  4       VP                  4       V,          ,           P                  VR4      pW",          pVP                  '       d   \        ^\!        R	R
V,          4      4      M^pV^8”  dI   V\        P"                  ! VP                  ^,          VP                  R7      V,          V,          ,           p\        P                  ! WGV,          V P                  \        P$                  R7      pVP'                  ^V\        P(                  ! V4      4       V^8”  d"   VP+                  WGV4      P-                  ^4      pVP+                  WBV4      P/                  \        P                  4      p	V'       d)   \        P,                  ! V	^RR7      p
WšR,           ,          p	V	# )au  Count predicted against target class labels, one confusion matrix per sample.

``cm = confusion_matrix(pred, target, num_classes)`` takes two integer label tensors of shape ``(B, *)`` and
returns float32 matrices with shape ``(B, K, K)``, where ``cm[b, target, pred]`` counts the positions of sample
``b`` with that target and that prediction.

Convention:
    - ``pred`` and ``target`` have the same shape, with an integer dtype: ``uint8`` or any signed type; a bool
      tensor counts as the labels 0 and 1. A floating-point label tensor raises, and so does a label outside
      :math:`[0, K)`, unless graph capture traces the range check (``torch.export``,
      ``torch.compile(fullgraph=True)``), which skips it: an out-of-range label is then counted in another cell
      or makes the call fail.
    - The first axis is always the batch and the result is never pooled over it, so a flat ``(N,)`` label vector
      gives :math:`N` matrices that count one label each. Sum over the first axis for the matrix of a whole batch
      or dataset.
    - Swapping the two arguments transposes every count matrix, but not a ``normalized`` one.
      :ref:`Losses and metrics <losses-metrics-conventions>` maps the matrix and ``normalized`` onto
      scikit-learn.

Args:
    pred: predicted class labels in :math:`[0, K)`, with shape ``(B, *)``.
    target: ground-truth class labels in :math:`[0, K)`, with the shape of ``pred``.
    num_classes: the number of classes :math:`K`, at least 2.
    normalized: whether to divide each target row by its sum plus ``1e-6``. Non-empty rows then sum to
      approximately one; empty rows stay zero.

Returns:
    the matrices with shape ``(B, K, K)``: counts, or row fractions with ``normalized=True``.

See Also:
    - :func:`~kornia.metrics.mean_iou`: the per-class IoU computed from this matrix.
    - :func:`~kornia.metrics.accuracy`: top-k accuracy from class scores, not labels.

Example:
    >>> logits = torch.tensor([[0, 1, 0]])
    >>> target = torch.tensor([[0, 1, 0]])
    >>> confusion_matrix(logits, target, num_classes=3)
    tensor([[[2., 0., 0.],
             [0., 1., 0.],
             [0., 0., 0.]]])

r'   r(   z6Inputs pred and target must have the same shape. Got: z and z(Inputs must be in the same device. Got: z - z?The number of classes must be an integer of at least two. Got: )Údevicer   é   i @  )r,   T)ÚdimÚkeepdimg�íµ ÷Æ°>éÿÿÿÿ)r   ÚshapeÚ
ValueErrorr,   Ú
isinstancer   r   ÚzerosÚfloat32r   Únumelr%   ÚlongÚreshapeÚis_cudar$   r#   ÚarangeÚint64Úscatter_add_Ú	ones_likeÚviewÚsumÚto)r'   r(   r   r)   Ú
batch_sizeÚindicesÚ	num_cellsÚcopiesÚconfusion_vecÚconfusion_matÚnorm_vals   &&&&       r   Úconfusion_matrixrH   ,   sJ  € ôZ �&˜$ÔÜ�(˜FÔ#Ø�:‰:˜Ÿ™Ô%ÜÐQÐRV×R\ÑR\ÐQ]Ð]bÐci×coÑcoÐbpÐqÓrÐrØ�;‰;˜&Ÿ-™-Ô'ÜÐCÀDÇKÁKÀ=ÐPSÐTZ×TaÑTaÐSbÐcÓdÐdä�k¤3×'Ò'¨;¸¬?ÜÐZÐ[fÐZgÐhÓiÐià—j‘j •m€Jð �Q„Ü�{Š{˜1˜k¸t¿{¹{ÔRW×R_ÑR_Ô`Ð`ô �>Š>˜dŸj™j›l¨QÔ.Ü˜6 4Ô5Ü˜8 VÔ9ð �y‰y‹{˜VŸ[™[›]¨[Õ8Õ8×AÑAÀ*ÈbÓQ€Gð Õ)€Ið 6=·_·_°_ŒS�”C˜˜U iÕ/Ó0Ô1È!€FØ�„zØœUŸ\š\¨'¯-©-¸Õ*:À7Ç>Á>ÔRÐU[Õ[Ð_hÕhÕhˆÜ—K’K 
°YÕ,>ÀtÇ{Á{ÔZ_×ZeÑZeÔf€MØ×Ñ˜q '¬5¯?ª?¸7Ó+CÔDØ�„zØ%×*Ñ*¨:¸yÓI×MÑMÈaÓPˆØ"/×"4Ñ"4°ZÈkÓ"Z×"]Ñ"]Ô^c×^kÑ^kÓ"l€MçÜ!&§¢¨=¸aÈÔ!NˆØ%°D­Õ9ˆàÐr   )F)	r   Úkornia.core.checkr   r   Úkornia.core.utilsr   r   r%   rH   r   r   r   Ú<module>rK      s&   ðó$ ç BÝ *õõ÷Wñ Wr   