Ë
    ýÿæig
  ã                   ód   — d dl mZ d dlmZmZ d dlmZ d dlmZ 	 ddededee	   d	ee
   d
ef
d„Zy)é    )ÚOptional)ÚTensorÚtensor)Úbinary_auroc)Ú"_check_retrieval_functional_inputsNÚpredsÚtargetÚtop_kÚmax_fprÚreturnc                 ó‚  — t        | |«      \  } }|xs | j                  d   }t        |t        «      r|dkD  st	        d«      ‚| j                  t        || j                  d   «      dd¬«      d   }||   }d|vsd|vr"t        d| j                  | j                  ¬«      S | |   } t        | |j                  «       |¬	«      S )
až  Compute area under the receiver operating characteristic curve (AUROC) for information retrieval.

    ``preds`` and ``target`` should be of the same shape and live on the same device. If no ``target`` is ``True``,
    ``0`` is returned. ``target`` must be either `bool` or `integers` and ``preds`` must be ``float``,
    otherwise an error is raised.

    Args:
        preds: estimated probabilities of each document to be relevant.
        target: ground truth about each document being relevant or not.
        top_k: consider only the top k elements (default: ``None``, which considers them all)
        max_fpr: If not ``None``, calculates standardized partial AUC over the range ``[0, max_fpr]``.

    Return:
        a single-value tensor with the auroc value of the predictions ``preds`` w.r.t. the labels ``target``.

    Raises:
        ValueError:
            If ``top_k`` is not ``None`` or an integer larger than 0.

    Example:
        >>> from torchmetrics.functional.retrieval import retrieval_auroc
        >>> preds = tensor([0.2, 0.3, 0.5])
        >>> target = tensor([True, False, True])
        >>> retrieval_auroc(preds, target)
        tensor(0.5000)

    éÿÿÿÿr   z,`top_k` has to be a positive integer or NoneT)ÚsortedÚdimé   g        )ÚdeviceÚdtype)r   )r   ÚshapeÚ
isinstanceÚintÚ
ValueErrorÚtopkÚminr   r   r   r   )r   r	   r
   r   Ú	top_k_idxs        ú|/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/torchmetrics/functional/retrieval/auroc.pyÚretrieval_aurocr      s·   € ô< 7°u¸fÓEM€Eˆ6àÒ$U—[‘[ ‘_€EÜuœcÔ" u¨q¢yÜÐGÓHÐHà—
‘
œ3˜u e§k¡k°"¡oÓ6¸tÈ
ÓLÈQÑO€IØIÑ€FØ	‰˜Q f™_Üc %§,¡,°e·k±kÔBÐBà)Ñ€EÜ˜˜vŸz™z›|°WÔ=Ð=ó    )NN)Útypingr   Útorchr   r   Ú,torchmetrics.functional.classification.aurocr   Útorchmetrics.utilities.checksr   r   Úfloatr   © r   r   Ú<module>r$      sP   ðõ ç  å EÝ Lð \`ñ*>Øð*>Ø!ð*>Ø*2°3©-ð*>ØIQÐRWÉð*>àô*>r   