ó
    Eñi  ã                   ó  • S SK r SSKJr  SSKJrJr    SS\ R                  S\ R                  S\S	\S
\ R                  4
S jjr	 SS\ R                  S\ R                  S	\S
\
\ R                  \ R                  4   4S jjrg)é    Né   )Ú_log_api_usage_onceé   )Ú_loss_inter_unionÚ_upcast_non_floatÚboxes1Úboxes2Ú	reductionÚepsÚreturnc                 óÖ  • [         R                  R                  5       (       d2  [         R                  R                  5       (       d  [	        [
        5        [        U 5      n [        U5      n[        XU5      u  pEUS:X  a   U$ US:X  a;  UR                  5       S:”  a  UR                  5       nU$ SUR                  5       -  nU$ US:X  a  UR                  5       nU$ [        SU S35      e)ac  
Gradient-friendly IoU loss with an additional penalty that is non-zero when the
distance between boxes' centers isn't zero. Indeed, for two exactly overlapping
boxes, the distance IoU is the same as the IoU loss.
This loss is symmetric, so the boxes1 and boxes2 arguments are interchangeable.

Both sets of boxes are expected to be in ``(x1, y1, x2, y2)`` format with
``0 <= x1 < x2`` and ``0 <= y1 < y2``, and The two boxes should have the
same dimensions.

Args:
    boxes1 (Tensor[N, 4]): first set of boxes
    boxes2 (Tensor[N, 4]): second set of boxes
    reduction (string, optional): Specifies the reduction to apply to the output:
        ``'none'`` | ``'mean'`` | ``'sum'``. ``'none'``: No reduction will be
        applied to the output. ``'mean'``: The output will be averaged.
        ``'sum'``: The output will be summed. Default: ``'none'``
    eps (float, optional): small number to prevent division by zero. Default: 1e-7

Returns:
    Tensor: Loss tensor with the reduction option applied.

Reference:
    Zhaohui Zheng et al.: Distance Intersection over Union Loss:
    https://arxiv.org/abs/1911.08287
ÚnoneÚmeanr   g        Úsumz$Invalid Value for arg 'reduction': 'z3 
 Supported reduction modes: 'none', 'mean', 'sum')ÚtorchÚjitÚis_scriptingÚ
is_tracingr   Údistance_box_iou_lossr   Ú_diou_iou_lossÚnumelr   r   Ú
ValueError)r   r	   r
   r   ÚlossÚ_s         ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/ops/diou_loss.pyr   r      sã   € ôF �9‰9×!Ñ!×#Ñ#¬E¯I©I×,@Ñ,@×,BÑ,BÜÔ1Ô2ä˜vÓ&€FÜ˜vÓ&€Fä˜V¨SÓ1�G€Dð �FÓØð €Kð 
�fÓ	Ø"Ÿj™j›l¨QÓ.ˆt�y‰y‹{ˆð €Kð 58¸$¿(¹(»*Ñ4Dˆð €Kð 
�eÓ	Ø�x‰x‹zˆð
 €Kô Ø2°9°+Ð=qÐró
ð 	
ó    c                 óÂ  • [        X5      u  p4X4U-   -  nU R                  SS9u  pgp‰UR                  SS9u  p«pÍ[        R                  " Xj5      n[        R                  " X{5      n[        R                  " XŒ5      n[        R                  " X�5      nUU-
  S-  UU-
  S-  -   U-   nX†-   S-  nX—-   S-  nX¬-   S-  nX½-   S-  nUU-
  S-  UU-
  S-  -   nSU-
  UU-  -   nUU4$ )Néÿÿÿÿ)Údimr   r   )r   Úunbindr   ÚminÚmax)r   r	   r   ÚintsctÚunionÚiouÚx1Úy1Úx2Úy2Úx1gÚy1gÚx2gÚy2gÚxc1Úyc1Úxc2Úyc2Údiagonal_distance_squaredÚx_pÚy_pÚx_gÚy_gÚcenters_distance_squaredr   s                            r   r   r   @   s	  € ô & fÓ5�M€FØ
˜C‘KÑ
 €Cà—]‘] r�]Ð*�N€BˆBØŸ™¨2˜Ð.Ñ€CˆcÜ
�)Š)�BÓ
€CÜ
�)Š)�BÓ
€CÜ
�)Š)�BÓ
€CÜ
�)Š)�BÓ
€Cà"%¨¡)°Ñ!1°s¸S±yÀQÑ6FÑ GÈ#Ñ MÐà‰7�a‰-€CØ‰7�a‰-€CØ‰9˜‰/€CØ‰9˜‰/€Cà!$ s¡¨qÑ 0°c¸C±iÀAÑ5EÑFÐð ˆs‰7Ð.Ð1JÑJÑK€DØ�ˆ9Ðr   )r   çH¯¼šò×z>)r8   )r   Úutilsr   Ú_utilsr   r   ÚTensorÚstrÚfloatr   Útupler   © r   r   Ú<module>r@      sž   ðÛ å 'ß 8ð Øñ	6Ø�L‰Lð6à�L‰Lð6ð ð6ð 
ð	6ð
 ‡\�\õ6ðx ñØ�L‰Lðà�L‰Lðð 
ðð ˆ5�<‰<˜Ÿ™Ð%Ñ&ö	r   