o
    €o™iâ  ã                
   @   sH   d dl mZmZ d dlmZ ddededeedf dee fd	d
„ZdS )é    )ÚListÚTuple)ÚTensor©é   ÚpredÚtargetÚtopk.Úreturnc                    sj   t t|ƒ|  ¡ d ƒ‰| d¡‰ |  ˆddd¡\}} |  ¡ } |  | dd¡ | ¡¡‰‡ ‡‡fdd„|D ƒS )až  Compute the accuracy over the k top predictions for the specified values of k.

    Args:
        pred: the input tensor with the logits to evaluate.
        target: the tensor containing the ground truth.
        topk: the expected topk ranking.

    Example:
        >>> logits = torch.tensor([[0, 1, 0]])
        >>> target = torch.tensor([[1]])
        >>> accuracy(logits, target)
        [tensor(100.)]

    r   r   Téÿÿÿÿc                    s6   g | ]}ˆd t |ˆƒ…  d¡ ¡  d¡d ˆ  ‘qS )Nr   r   g      Y@)ÚminÚreshapeÚfloatÚsum)Ú.0Úk©Ú
batch_sizeÚcorrectÚmaxk© úK/home/ubuntu/.local/lib/python3.10/site-packages/kornia/metrics/accuracy.pyÚ
<listcomp>+   s   6 zaccuracy.<locals>.<listcomp>)r   ÚmaxÚsizer	   ÚtÚeqr   Ú	expand_as)r   r   r	   Ú_r   r   r   Úaccuracy   s   
r   N)r   )Útypingr   r   Úkornia.corer   Úintr   r   r   r   r   Ú<module>   s   ,