+
    œ°³j)V  ã                   ó  € ^ RI t ^ RIHt ^ RIHu Ht ^RIHtHtH	t	 ^RI
HtHtHtHtHt ]! 4       '       d   ^ RIHt ]! 4       '       d   ^ RIHt R t ! R R]P*                  4      t ! R	 R
]P*                  4      tRR ltR# )é    N)Úis_scipy_availableÚis_vision_availableÚrequires_backends)Úbox_iouÚ	dice_lossÚgeneralized_box_iouÚnested_tensor_from_tensor_listÚsigmoid_focal_loss)Úlinear_sum_assignment)Úcenter_to_corners_formatc                 óT   € \        W4       UUu. uF  w  r#R VRV/NK  	  upp# u uppi )ÚlogitsÚ
pred_boxes)Úzip)Úoutputs_classÚoutputs_coordÚaÚbs   &&  Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/loss/loss_rt_detr.pyÚ_set_aux_lossr   &   s,   € Ü7:¸=Ô7XÔYÑ7X©t¨qˆX�q˜,¨Ó*Ñ7XÒYÐYùÓYs   �$c                   ód   a a€ ] tR t^*t oRtV 3R lt]P                  ! 4       R 4       tRt	Vt
V ;t# )ÚRTDetrHungarianMatcheraƒ  This class computes an assignment between the targets and the predictions of the network

For efficiency reasons, the targets don't include the no_object. Because of this, in general, there are more
predictions than targets. In this case, we do a 1-to-1 matching of the best predictions, while the others are
un-matched (and thus treated as non-objects).

Args:
    config: RTDetrConfig
c                ó’  <€ \         SV `  4        \        V R .4       VP                  V n        VP
                  V n        VP                  V n        VP                  V n	        VP                  V n        VP                  V n        V P                  V P                  u;8X  d   V P                  u;8X  d   ^ 8X  d   M R# \        R4      hR# )Úscipyz#All costs of the Matcher can't be 0N)ÚsuperÚ__init__r   Úmatcher_class_costÚ
class_costÚmatcher_bbox_costÚ	bbox_costÚmatcher_giou_costÚ	giou_costÚuse_focal_lossÚmatcher_alphaÚalphaÚmatcher_gammaÚgammaÚ
ValueError)ÚselfÚconfigÚ	__class__s   &&€r   r   ÚRTDetrHungarianMatcher.__init__5   sœ   ø€ Ü‰ÑÔÜ˜$  	Ô*à ×3Ñ3ˆŒØ×1Ñ1ˆŒØ×1Ñ1ˆŒà$×3Ñ3ˆÔØ×)Ñ)ˆŒ
Ø×)Ñ)ˆŒ
à�?‰?˜dŸn™nÖC°·±ÖCÀ!×CÐCÜÐBÓCÐCñ Dó    c           
     óB  € VR,          P                   R,          w  r4VR,          P                  ^ ^4      p\        P                  ! V Uu. uF  qfR,          NK  	  up4      p\        P                  ! V Uu. uF  qfR,          NK  	  up4      pV P                  '       dØ   \
        P                  ! VR,          P                  ^ ^4      4      p	V	RV3,          p	^V P                  ,
          W�P                  ,          ,          ^V	,
          R,           P                  4       ) ,          p
V P                  ^V	,
          V P                  ,          ,          V	R,           P                  4       ) ,          pWº,
          pM4VR,          P                  ^ ^4      P                  R
4      p	V	RV3,          ) p\        P                  ! WX^R7      p\        \        V4      \        V4      4      ) pV P                  V,          V P                  V,          ,           V P                   V,          ,           pVP#                  W4R
4      P%                  4       pV Uu. uF  p\'        VR,          4      NK  	  pp\)        VP+                  VR
4      4       UUu. uF  w  pp\-        VV,          4      NK  	  pppV UUu. uFR  w  pp\        P.                  ! V\        P0                  R	7      \        P.                  ! V\        P0                  R	7      3NKT  	  upp# u upi u upi u upi u uppi u uppi )a  Performs the matching

Params:
    outputs: This is a dict that contains at least these entries:
         "logits": Tensor of dim [batch_size, num_queries, num_classes] with the classification logits
         "pred_boxes": Tensor of dim [batch_size, num_queries, 4] with the predicted box coordinates

    targets: This is a list of targets (len(targets) = batch_size), where each target is a dict containing:
         "class_labels": Tensor of dim [num_target_boxes] (where num_target_boxes is the number of ground-truth
                   objects in the target) containing the class labels
         "boxes": Tensor of dim [num_target_boxes, 4] containing the target box coordinates

Returns:
    A list of size batch_size, containing tuples of (index_i, index_j) where:
        - index_i is the indices of the selected predictions (in order)
        - index_j is the indices of the corresponding selected targets (in order)
    For each batch element, it holds:
        len(index_i) = len(index_j) = min(num_queries, num_target_boxes)
r   ºNé   Nr   Úclass_labelsÚboxesºNNNg:Œ0âŽyE>)Úp©Údtypeéÿÿÿÿ)ÚshapeÚflattenÚtorchÚcatr#   ÚFÚsigmoidr%   r'   ÚlogÚsoftmaxÚcdistr   r   r    r   r"   ÚviewÚcpuÚlenÚ	enumerateÚsplitr   Ú	as_tensorÚint64)r)   ÚoutputsÚtargetsÚ
batch_sizeÚnum_queriesÚout_bboxÚvÚ
target_idsÚtarget_bboxÚout_probÚneg_cost_classÚpos_cost_classr   r    r"   Úcost_matrixÚsizesÚiÚcÚindicesÚjs   &&&                  r   ÚforwardÚRTDetrHungarianMatcher.forwardD   sy  € ð* #*¨(Õ"3×"9Ñ"9¸"Õ"=Ñˆ
ð ˜<Õ(×0Ñ0°°AÓ6ˆä—Y’Y¹7ÓC¹7°a .× 1Ð 1¹7ÑCÓDˆ
Ü—i’i±WÓ =±W° 7§ ±WÑ =Ó>ˆð ××ÐÜ—y’y ¨Õ!2×!:Ñ!:¸1¸aÓ!@ÓAˆHØ  : Õ.ˆHØ $§*¡*�n°¿:¹:Õ1EÕFÈAÐPXÍLÐ[_ÕL_×KdÑKdÓKfÐJfÕgˆNØ!ŸZ™Z¨A°­L¸T¿Z¹ZÕ+GÕHÈhÐY]Ío×MbÑMbÓMdÐLdÕeˆNØ'Õ8‰Jà˜xÕ(×0Ñ0°°AÓ6×>Ñ>¸rÓBˆHØ" 1 j =Õ1Ð1ˆJô —K’K ¸Ô;ˆ	ä(Ô)AÀ(Ó)KÔMeÐfqÓMrÓsÐsˆ	à—n‘n yÕ0°4·?±?ÀZÕ3OÕOÐRV×R`ÑR`ÐclÕRlÕlˆØ!×&Ñ& zÀÓC×GÑGÓIˆá*1Ó2©' Q”�Q�w•Z–©'ˆÐ2Ü;DÀ[×EVÑEVÐW\Ð^`ÓEaÔ;bÔcÑ;b±4°1°aÔ(¨¨1­Ö.Ñ;bˆÑcákrÔsÑkrÑcgÐcdÐfg”—’ ¬%¯+©+Ô6¼¿ºÈÔQV×Q\ÑQ\Ô8]Ó^ÑkrÒsÐsùò5  DùÚ =ùò, 3ùÛcùãss   Á
LÁ6LÉ	LÊLÊ*AL)r%   r    r   r'   r"   r#   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r:   Úno_gradrY   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r+   Ú__classdict__s   @@r   r   r   *   s2   ù‡ € ñõDð ‡]‚]ƒ_ñ3tó ÷3tð 3tr-   r   c                   óÀ   a a€ ] tR t^{t oRtV 3R ltRR ltRR lt]P                  ! 4       R 4       t
R tR tRR ltR	 tR
 tRR ltR t]R 4       tR tRtVtV ;t# )Ú
RTDetrLossa  
This class computes the losses for RTDetr. The process happens in two steps: 1) we compute hungarian assignment
between ground truth boxes and the outputs of the model 2) we supervise each pair of matched ground-truth /
prediction (supervise class and box).

Args:
    matcher (`DetrHungarianMatcher`):
        Module able to compute a matching between targets and proposals.
    weight_dict (`Dict`):
        Dictionary relating each loss with its weights. These losses are configured in RTDetrConf as
        `weight_loss_vfl`, `weight_loss_bbox`, `weight_loss_giou`
    losses (`list[str]`):
        List of all the losses to be applied. See `get_loss` for a list of all available losses.
    alpha (`float`):
        Parameter alpha used to compute the focal loss.
    gamma (`float`):
        Parameter gamma used to compute the focal loss.
    eos_coef (`float`):
        Relative classification weight applied to the no-object category.
    num_classes (`int`):
        Number of object categories, omitting the special no-object category.
c                óÖ  <€ \         SV `  4        \        V4      V n        VP                  V n        R VP                  RVP                  RVP                  /V n	        RR.V n
        VP                  V n        \        P                  ! VP                  ^,           4      pV P                  VR&   \        P                   ! V4      V n        VP$                  V n        VP(                  V n        R# )Úloss_vflÚ	loss_bboxÚ	loss_giouÚvflr2   Nr7   )r   r   r   ÚmatcherÚ
num_labelsÚnum_classesÚweight_loss_vflÚweight_loss_bboxÚweight_loss_giouÚweight_dictÚlossesÚeos_coefficientÚeos_coefr:   ÚonesÚnnÚBufferÚempty_weightÚfocal_loss_alphar%   Úfocal_loss_gammar'   )r)   r*   rz   r+   s   && €r   r   ÚRTDetrLoss.__init__“   sÀ   ø€ Ü‰ÑÔä-¨fÓ5ˆŒØ!×,Ñ,ˆÔà˜×.Ñ.Ø˜×0Ñ0Ø˜×0Ñ0ð
ˆÔð
 ˜gÐ&ˆŒØ×.Ñ.ˆŒÜ—z’z &×"3Ñ"3°aÕ"7Ó8ˆØŸ=™=ˆ�RÑÜŸIšI lÓ3ˆÔØ×,Ñ,ˆŒ
Ø×,Ñ,ˆŽ
r-   c           	     óª  € R V9  d   \        R4      hRV9  d   \        R4      hV P                  V4      pVR ,          V,          p\        P                  ! \	        W#4       UU	U
u. uF  w  pw  ršVR,          V
,          NK  	  up
p	p^ R7      p\        \        VP                  4       4      \        V4      4      w  rÉ\        P                  ! V4      pVR,          pVP                  p\        P                  ! \	        W#4       UU	U
u. uF  w  pw  ršVR,          V
,          NK  	  up
p	p4      p\        P                  ! VP                  R,          V P                  \        P                  VP                  R7      pVVV&   \        P                   ! VV P                  ^,           R	7      R
RR13,          p\        P"                  ! VVR7      pVP%                  V4      VV&   VP'                  R4      V,          p\        P(                  ! VP                  4       4      pV P*                  VP-                  V P.                  4      ,          ^V,
          ,          V,           P%                  V4      p\        P0                  ! VVVRR7      pVP3                  ^4      P5                  4       VP                  ^,          ,          V,          pRV/# u up
p	pi u up
p	pi )r   ú#No predicted boxes found in outputsr   z$No predicted logits found in outputsr2   ©Údimr1   r/   ©r6   Údevice©ro   .Nr5   Únone)ÚweightÚ	reductionri   r7   )ÚKeyErrorÚ_get_source_permutation_idxr:   r;   r   r   r   ÚdetachÚdiagr6   Úfullr8   ro   rG   rƒ   r<   Úone_hotÚ
zeros_likeÚtoÚ	unsqueezer=   r%   Úpowr'   Ú binary_cross_entropy_with_logitsÚmeanÚsum)r)   rH   rI   rW   Ú	num_boxesr>   ÚidxÚ	src_boxesÚ_targetÚ_rU   Útarget_boxesÚiousÚ
src_logitsr6   Útarget_classes_originalÚtarget_classesÚtargetÚtarget_score_originalÚtarget_scoreÚ
pred_scorer†   Úlosss   &&&&&&                 r   Úloss_labels_vflÚRTDetrLoss.loss_labels_vfl¥   sQ  € Ø˜wÔ&ÜÐ@ÓAÐAØ˜7Ô"ÜÐAÓBÐBØ×.Ñ.¨wÓ7ˆà˜LÕ)¨#Õ.ˆ	Ü—y’yÌSÐQXÔMbÕ!cÑMb¹/¸'Á6ÀA '¨'Õ"2°1×"5Ð"5ÑMbÓ!cÐijÔkˆÜÔ2°9×3CÑ3CÓ3EÓFÔH`ÐamÓHnÓo‰ˆÜ�zŠz˜$Óˆà˜XÕ&ˆ
Ø× Ñ ˆÜ"'§)¢)Ô_bÐcjÔ_tÕ,uÑ_tÉOÈGÑU[ÐVW¨W°^Õ-DÀQ×-GÐ-GÑ_tÓ,uÓ"vÐÜŸšØ×Ñ˜RÕ  $×"2Ñ"2¼%¿+¹+Èj×N_ÑN_ô
ˆð 6ˆ�sÑÜ—’˜>°t×7GÑ7GÈ!Õ7KÔLÈSÐRUÐSUÐRUÈXÕVˆä %× 0Ò 0°ÀuÔ MÐØ%)§W¡W¨U£^Ð˜cÑ"Ø,×6Ñ6°rÓ:¸VÕCˆä—Y’Y˜z×0Ñ0Ó2Ó3ˆ
à—*‘*˜zŸ~™~¨d¯j©jÓ9Õ9¸QÀ½ZÕHÈ<ÕW×[Ñ[Ð\aÓbˆä×1Ò1°*¸lÐSYÐekÔlˆØ�y‰y˜‹|×ÑÓ! J×$4Ñ$4°QÕ$7Õ7¸)ÕCˆØ˜DÐ!Ð!ùô/ "dùô -vs   Á%KÄKc           	     ó  € RV9  d   \        R4      hVR,          pV P                  V4      p\        P                  ! \	        W#4       UU	U
u. uF  w  pw  ršVR,          V
,          NK  	  up
p	p4      p\        P
                  ! VP                  R,          V P                  \        P                  VP                  R7      pW¼V&   \        P                  ! VP                  ^^4      WÀP                  4      pRV/pV# u up
p	pi )zyClassification loss (NLL)
targets dicts must contain the key "class_labels" containing a tensor of dim [nb_target_boxes]
r   z#No logits were found in the outputsr1   r/   r‚   Úloss_ce)rˆ   r‰   r:   r;   r   rŒ   r8   ro   rG   rƒ   r<   Úcross_entropyÚ	transposeÚclass_weight)r)   rH   rI   rW   r•   r>   rœ   r–   r˜   r™   rU   r�   rž   r§   rt   s   &&&&&&         r   Úloss_labelsÚRTDetrLoss.loss_labelsÆ   sâ   € ð ˜7Ô"ÜÐ@ÓAÐAà˜XÕ&ˆ
à×.Ñ.¨wÓ7ˆÜ"'§)¢)Ô_bÐcjÔ_tÕ,uÑ_tÉOÈGÑU[ÐVW¨W°^Õ-DÀQ×-GÐ-GÑ_tÓ,uÓ"vÐÜŸšØ×Ñ˜RÕ  $×"2Ñ"2¼%¿+¹+Èj×N_ÑN_ô
ˆð 6�sÑä—/’/ *×"6Ñ"6°q¸!Ó"<¸n×N_ÑN_Ó`ˆØ˜WÐ%ˆØˆùô -vs   ÁC;c           	     ó   € VR,          pVP                   p\        P                  ! V Uu. uF  p\        VR,          4      NK  	  upVR7      pVP	                  4       P                  R4      P                  R8„  P                  ^4      p	\        P                  P                  V	P                  4       VP                  4       4      p
RV
/pV# u upi )zÉ
Compute the cardinality error, i.e. the absolute error in the number of predicted non-empty boxes. This is not
really a loss, it is intended for logging purposes only. It doesn't propagate gradients.
r   r1   )rƒ   g      à?Úcardinality_errorr7   )rƒ   r:   rF   rC   r=   ÚmaxÚvaluesr”   rx   Ú
functionalÚl1_lossÚfloat)r)   rH   rI   rW   r•   r   rƒ   rM   Útarget_lengthsÚ	card_predÚcard_errrt   s   &&&&&       r   Úloss_cardinalityÚRTDetrLoss.loss_cardinalityÚ   s©   € ð ˜Õ"ˆØ—‘ˆÜŸšÉ'Ó)RÉ'ÀQ¬#¨a°Õ.?Ö*@É'Ñ)RÐ[aÔbˆà—^‘^Ó%×)Ñ)¨"Ó-×4Ñ4°sÑ:×?Ñ?ÀÓBˆ	Ü—=‘=×(Ñ(¨¯©Ó):¸N×<PÑ<PÓ<RÓSˆØ% xÐ0ˆØˆùò *Ss   ªCc           	     ó  € RV9  d   \        R4      hV P                  V4      pVR,          V,          p\        P                  ! \	        W#4       UUU	u. uF  w  pw  r‰VR,          V	,          NK  	  up	pp^ R7      p
/ p\
        P                  ! WjRR7      pVP                  4       V,          VR&   ^\        P                  ! \        \        V4      \        V
4      4      4      ,
          pVP                  4       V,          VR&   V# u up	ppi )	a  
Compute the losses related to the bounding boxes, the L1 regression loss and the GIoU loss. Targets dicts must
contain the key "boxes" containing a tensor of dim [nb_target_boxes, 4]. The target boxes are expected in
format (center_x, center_y, w, h), normalized by the image size.
r   r   r2   r€   r…   ©r‡   rj   rk   )rˆ   r‰   r:   r;   r   r<   r²   r”   r‹   r   r   )r)   rH   rI   rW   r•   r–   r—   Útr™   rU   rš   rt   rj   rk   s   &&&&&         r   Ú
loss_boxesÚRTDetrLoss.loss_boxesé   sæ   € ð ˜wÔ&ÜÐ@ÓAÐAØ×.Ñ.¨wÓ7ˆØ˜LÕ)¨#Õ.ˆ	Ü—y’yÄÀWÔAVÕ!WÑAV±I°A±v¸ ! G¥*¨Q§- -ÑAVÓ!WÐ]^Ô_ˆàˆä—I’I˜iÀÔHˆ	Ø'Ÿm™m›o°	Õ9ˆˆ{ÑàœŸ
š
ÜÔ 8¸Ó CÔE]Ð^jÓEkÓló
õ 
ˆ	ð (Ÿm™m›o°	Õ9ˆˆ{ÑØˆùô "Xs   ÁDc                óZ  € RV9  d   \        R4      hV P                  V4      pV P                  V4      pVR,          pWu,          pV Uu. uF  qˆR,          NK  	  p	p\        V	4      P	                  4       w  r«V
P                  V4      p
W¦,          p
\        P                  P                  VR
,          V
P                  RR RRR7      pVR,          P                  ^4      pV
P                  ^4      p
V
P                  VP                  4      p
R\        WzV4      R	\        WzV4      /pV# u upi )z«
Compute the losses related to the masks: the focal loss and the dice loss. Targets dicts must contain the key
"masks" containing a tensor of dim [nb_target_boxes, h, w].
Ú
pred_masksz#No predicted masks found in outputsÚmasksNÚbilinearF)ÚsizeÚmodeÚalign_cornersÚ	loss_maskÚ	loss_dice)r3   Néþÿÿÿ)r3   r   )rˆ   r‰   Ú_get_target_permutation_idxr	   Ú	decomposer�   rx   r±   Úinterpolater8   r9   rA   r
   r   )r)   rH   rI   rW   r•   Ú
source_idxÚ
target_idxÚsource_masksr»   rÀ   Útarget_masksÚvalidrt   s   &&&&&        r   Ú
loss_masksÚRTDetrLoss.loss_masks   s.  € ð
 ˜wÔ&ÜÐ@ÓAÐAà×5Ñ5°gÓ>ˆ
Ø×5Ñ5°gÓ>ˆ
Ø˜|Õ,ˆØ#Õ/ˆÙ%,Ó-¡W �7—�¡WˆÐ-Ü<¸UÓC×MÑMÓOÑˆØ#—‘ |Ó4ˆØ#Õ/ˆô —}‘}×0Ñ0Ø˜Õ!¨×(:Ñ(:¸2¸3Ð(?ÀjÐ`eð 1ó 
ˆð $ DÕ)×1Ñ1°!Ó4ˆà#×+Ñ+¨AÓ.ˆØ#×(Ñ(¨×);Ñ);Ó<ˆàÔ+¨LÈ	ÓRØœ <¸yÓIð
ˆð ˆùò# .s   Á
D(c           	     óš  € VR ,          pV P                  V4      p\        P                  ! \        W#4       UU	U
u. uF  w  pw  ršVR,          V
,          NK  	  up
p	p4      p\        P                  ! VP
                  R,          V P                  \        P                  VP                  R7      pW¼V&   \        P                  ! WÀP                  ^,           R7      RRR13,          p\        P                  ! WmR,          RR	7      pVP                  ^4      P                  4       VP
                  ^,          ,          V,          pR
V/# u up
p	pi )r   r1   r/   r‚   r„   .Ng      ð?r…   rº   Úloss_bcer7   )r‰   r:   r;   r   rŒ   r8   ro   rG   rƒ   r<   r�   r’   r“   r”   ©r)   rH   rI   rW   r•   r>   rœ   r–   r˜   r™   rU   r�   rž   rŸ   r£   s   &&&&&&         r   Úloss_labels_bceÚRTDetrLoss.loss_labels_bce  s  € Ø˜XÕ&ˆ
Ø×.Ñ.¨wÓ7ˆÜ"'§)¢)Ô_bÐcjÔ_tÕ,uÑ_tÉOÈGÑU[ÐVW¨W°^Õ-DÀQ×-GÐ-GÑ_tÓ,uÓ"vÐÜŸšØ×Ñ˜RÕ  $×"2Ñ"2¼%¿+¹+Èj×N_ÑN_ô
ˆð 6�sÑä—’˜>×7GÑ7GÈ!Õ7KÔLÈSÐRUÐSUÐRUÈXÕVˆÜ×1Ò1°*Às½lÐV\Ô]ˆØ�y‰y˜‹|×ÑÓ! J×$4Ñ$4°QÕ$7Õ7¸)ÕCˆØ˜DÐ!Ð!ùô -vs   ºEc                ó  € \         P                  ! \        V4       UUUu. uF  w  pw  r4\         P                  ! W24      NK   	  uppp4      p\         P                  ! V UUu. uF  w  r4VNK	  	  upp4      pWV3# u upppi u uppi ©N©r:   r;   rD   Ú	full_like)r)   rW   rU   Úsourcer™   Ú	batch_idxrË   s   &&     r   r‰   Ú&RTDetrLoss._get_source_permutation_idx-  sh   € ä—I’IÔPYÐZaÔPbÕcÑPb¹n¸aÁÀ&œuŸš¨vÖ9ÑPbÓcÓdˆ	Ü—Y’Y¹'ÔB¹'©;¨F£¹'ÒBÓCˆ
ØÐ$Ð$ùô dùÛBó    $A:Á"B
c                ó  € \         P                  ! \        V4       UUUu. uF  w  pw  r4\         P                  ! WB4      NK   	  uppp4      p\         P                  ! V UUu. uF  w  r4VNK	  	  upp4      pWV3# u upppi u uppi rØ   rÙ   )r)   rW   rU   r™   rŸ   rÜ   rÌ   s   &&     r   rÈ   Ú&RTDetrLoss._get_target_permutation_idx3  sh   € ä—I’IÔPYÐZaÔPbÕcÑPb¹n¸aÁÀ!œuŸš¨vÖ9ÑPbÓcÓdˆ	Ü—Y’Y¹'ÔB¹'©;¨A£¹'ÒBÓCˆ
ØÐ$Ð$ùô dùÛBrÞ   c           	     óÂ  € R V9  d   \        R4      hVR ,          pV P                  V4      p\        P                  ! \	        W#4       UU	U
u. uF  w  pw  ršVR,          V
,          NK  	  up
p	p4      p\        P
                  ! VP                  R,          V P                  \        P                  VP                  R7      pW¼V&   \        P                  ! WÀP                  ^,           R7      RRR	13,          p\        WmV P                  V P                  4      pVP                  ^4      P!                  4       VP                  ^,          ,          V,          pRV/# u up
p	pi )
r   zNo logits found in outputsr1   r/   r‚   r„   .NÚ
loss_focalr7   )rˆ   r‰   r:   r;   r   rŒ   r8   ro   rG   rƒ   r<   r�   r
   r%   r'   r“   r”   rÔ   s   &&&&&&         r   Úloss_labels_focalÚRTDetrLoss.loss_labels_focal9  s#  € Ø˜7Ô"ÜÐ7Ó8Ð8à˜XÕ&ˆ
à×.Ñ.¨wÓ7ˆÜ"'§)¢)Ô_bÐcjÔ_tÕ,uÑ_tÉOÈGÑU[ÐVW¨W°^Õ-DÀQ×-GÐ-GÑ_tÓ,uÓ"vÐÜŸšØ×Ñ˜RÕ  $×"2Ñ"2¼%¿+¹+Èj×N_ÑN_ô
ˆð 6�sÑä—’˜>×7GÑ7GÈ!Õ7KÔLÈSÐRUÐSUÐRUÈXÕVˆÜ! *°d·j±jÀ$Ç*Á*ÓMˆØ�y‰y˜‹|×ÑÓ! J×$4Ñ$4°QÕ$7Õ7¸)ÕCˆØ˜dÐ#Ð#ùô -vs   ÁEc                óö   € R V P                   RV P                  RV P                  RV P                  RV P                  RV P
                  RV P                  /pW9  d   \        RV R24      hWa,          ! W#WE4      # )	ÚlabelsÚcardinalityr2   rÀ   ÚbceÚfocalrl   zLoss z not supported)r«   r·   r¼   rÐ   rÕ   rã   r¤   r(   )r)   r£   rH   rI   rW   r•   Úloss_maps   &&&&&& r   Úget_lossÚRTDetrLoss.get_lossK  s}   € à�d×&Ñ&Ø˜4×0Ñ0Ø�T—_‘_Ø�T—_‘_Ø�4×'Ñ'Ø�T×+Ñ+Ø�4×'Ñ'ð
ˆð ÔÜ˜u T F¨.Ð9Ó:Ð:ØŽ~˜g°ÓCÐCr-   c           
     ó„  € V R ,          V R,          r2V Uu. uF  p\        VR,          4      NK  	  ppV^ ,          R,          P                  p. p\        V4       FÝ  w  r‰V	^ 8”  du   \        P                  ! V	\        P
                  VR7      p
V
P                  V4      p
\        W(,          4      \        V
4      8X  g   Q hVP                  W(,          V
34       K€  VP                  \        P                  ! ^ \        P
                  VR7      \        P                  ! ^ \        P
                  VR7      34       Kß  	  V# u upi )Údn_positive_idxÚdn_num_groupr1   r‚   )	rC   rƒ   rD   r:   ÚarangerG   ÚtileÚappendÚzeros)Údn_metarI   rî   rï   r»   Únum_gtsrƒ   Údn_match_indicesrU   Únum_gtÚgt_idxs   &&         r   Úget_cdn_matched_indicesÚ"RTDetrLoss.get_cdn_matched_indicesY  s   € à(/Ð0AÕ(BÀGÈNÕD[˜Ù3:Ó;±7¨a”3�q˜Õ(Ö)±7ˆÐ;Ø˜•˜NÕ+×2Ñ2ˆàÐÜ" 7Ö+‰IˆAØ˜ŒzÜŸš f´E·K±KÈÔO�ØŸ™ \Ó2�Ü˜?Õ-Ó.´#°f³+Ô=Ð=Ð=Ø ×'Ñ'¨Õ);¸VÐ(DÖEà ×'Ñ'äŸš A¬U¯[©[ÀÔHÜŸš A¬U¯[©[ÀÔHðöñ ,ð  Ðùò% <s   –D=c           
     óÂ  € VP                  4        UUu/ uF  w  r4RV9  g   K  W4bK  	  pppV P                  WR4      p\        R V 4       4      p\        P                  ! V.\        P
                  \        \        VP                  4       4      4      P                  R7      p\        P                  ! V^R7      P                  4       p/ pV P                   Fi  p	V P                  W‘W&V4      p
V
 Uu/ uF6  q3V P                  9   g   K  W:V,          V P                  V,          ,          bK8  	  p
pVP                  V
4       Kk  	  RV9   dÝ   \!        VR,          4       FÆ  w  r¼V P                  WÂ4      pV P                   F   p	V	R8X  d   K  V P                  WœW&V4      p
V
 Uu/ uF6  q3V P                  9   g   K  W:V,          V P                  V,          ,          bK8  	  p
pV
P                  4        UUu/ uF  w  r4VRV 2,           VbK  	  p
ppVP                  V
4       K¢  	  KÈ  	  RV9   Ed   RV9  d   \#        R	4      hV P%                  VR,          V4      pWqR,          R
,          ,          p\!        VR,          4       F¹  w  r¼V P                   F¤  p	V	R8X  d   K  / pV P                  ! WœW&V3/ VB p
V
 Uu/ uF6  q3V P                  9   g   K  W:V,          V P                  V,          ,          bK8  	  p
pV
P                  4        UUu/ uF  w  r4VRV 2,           VbK  	  p
ppVP                  V
4       K¦  	  K»  	  V# u uppi u upi u upi u uppi u upi u uppi )aj  
This performs the loss computation.

Args:
     outputs (`dict`, *optional*):
        Dictionary of tensors, see the output specification of the model for the format.
     targets (`list[dict]`, *optional*):
        List of dicts, such that `len(targets) == batch_size`. The expected keys in each dict depends on the
        losses applied, see each loss' doc.
Úauxiliary_outputsc              3   óF   "  € T F  p\        VR ,          4      x € K  	  R# 5i)r1   N)rC   )Ú.0r»   s   & r   Ú	<genexpr>Ú%RTDetrLoss.forward.<locals>.<genexpr>�  s   é € Ð@¹°1œ˜A˜nÕ-×.Ð.»ùs   ‚!r‚   )ÚminrÀ   Ú_aux_Údn_auxiliary_outputsÚdenoising_meta_valuesz}The output must have the 'denoising_meta_values` key. Please, ensure that 'outputs' includes a 'denoising_meta_values' entry.rï   Ú_dn_)Úitemsrm   r”   r:   rF   r³   ÚnextÚiterr°   rƒ   ÚclampÚitemrt   rë   rs   ÚupdaterD   r(   rù   )r)   rH   rI   ÚkrM   Úoutputs_without_auxrW   r•   rt   r£   Úl_dictrU   rü   Úkwargss   &&&           r   rY   ÚRTDetrLoss.forwardp  s  € ð 18·±´Ô`±©¨ÐCVÐ^_ÑC_œt˜qšt±ÐÑ`ð —,‘,Ð2Ó<ˆô Ñ@¹Ó@Ó@ˆ	Ü—O’O Y K´u·{±{Ì4ÔPTÐU\×UcÑUcÓUeÓPfÓKg×KnÑKnÔoˆ	Ü—K’K 	¨qÔ1×6Ñ6Ó8ˆ	ð ˆØ—K”KˆDØ—]‘] 4°'ÀIÓNˆFÙBHÓbÁ&¸QÐQU×QaÑQaÑLaÔ8�a � T×%5Ñ%5°aÕ%8Õ8Ò8Á&ˆFÐbØ�M‰M˜&Ö!ñ  ð  'Ô)Ü(1°'Ð:MÕ2NÖ(OÑ$�ØŸ,™,Ð'8ÓB�Ø ŸKœK�DØ˜w”á Ø!Ÿ]™]¨4ÀGÐV_Ó`�FÙJPÓjÉ&ÀQÐY]×YiÑYiÑTiÔ@˜a¨¥¨T×-=Ñ-=¸aÕ-@Õ!@Ò@É&�FÐjØ=C¿\¹\¼^ÔL¹^±T°Q˜a E¨!¨ +�o¨qÒ0¹^�FÑLØ—M‘M &Ö)ó (ñ )Pð " WÕ,Ø&¨gÔ5Ü ð Tóð ð ×2Ñ2°7Ð;RÕ3SÐU\Ó]ˆGØ!Ð,CÕ$DÀ^Õ$TÕTˆIä(1°'Ð:PÕ2QÖ(RÑ$�à ŸKœK�DØ˜w”á Ø�FØ!Ÿ]š]¨4ÀGÐV_ÑjÐciÑj�FÙJPÓjÉ&ÀQÐY]×YiÑYiÑTiÔ@˜a¨¥¨T×-=Ñ-=¸aÕ-@Õ!@Ò@É&�FÐjØ<B¿L¹L¼NÔK¹N±D°A˜a D¨¨ *�n¨aÒ/¹N�FÑKØ—M‘M &Ö)ó (ñ )Sð ˆùóg aùò cùò kùÛLùò( kùÛKs:   ”M ¤M Ã0MÄ%MÆ!MÆ8%MÇ2M
Ê9MË%MÌ
M
)r%   rz   rv   r'   rt   rm   ro   rs   )T)r[   r\   r]   r^   r_   r   r¤   r«   r:   r`   r·   r¼   rÐ   rÕ   r‰   rÈ   rã   rë   Ústaticmethodrù   rY   ra   rb   rc   rd   s   @@r   rg   rg   {   sv   ù‡ € ñõ.-ô$"ôBð( ‡]‚]ƒ_ñó ðòò.ô>"ò%ò%ô$ò$Dð ñ ó ð ÷,>ò >r-   rg   c
                 ó�  € \        V4      pVP                  V4       / pWR &   W<R&   RpVP                  '       dè   V	eC   \        P                  ! WiR,          ^R7      w  ræ\        P                  ! WYR,          ^R7      w  rõ\        VRRR	13,          P                  ^ ^4      VRRR	13,          P                  ^ ^4      4      pWÜR&   VR,          P                  \        V.V.4      4       V	e4   \        XP                  ^ ^4      XP                  ^ ^4      4      VR&   WœR&   V! WÁ4      p\        VP                  4       4      pVVV3# )
r   r   NÚdn_num_splitr€   r3   rü   r  r  r7   )
rg   r�   Úauxiliary_lossr:   rE   r   r©   Úextendr”   r°   )r   ræ   rƒ   r   r*   r   r   Úenc_topk_logitsÚenc_topk_bboxesr  r  Ú	criterionÚoutputs_lossrü   Údn_out_coordÚdn_out_classÚ	loss_dictr£   s   &&&&&&&&&&,       r   ÚRTDetrForObjectDetectionLossr  ±  s[  € ô ˜6Ó"€IØ‡L�L�Ôà€LØ#�ÑØ!+�ÑØÐØ××ÐØ Ò,Ü*/¯+ª+°mÐ[iÕEjÐpqÔ*rÑ'ˆLÜ*/¯+ª+°mÐ[iÕEjÐpqÔ*rÑ'ˆLä)¨-¸¸3¸B¸3¸Õ*?×*IÑ*IÈ!ÈQÓ*OÐQ^Ð_`ÐbeÐceÐbeÐ_eÕQf×QpÑQpÐqrÐtuÓQvÓwÐØ,=Ð(Ñ)ØÐ(Õ)×0Ñ0´ÀÐ?PÐSbÐRcÓ1dÔeØ Ò,Ü3@Ø×&Ñ& q¨!Ó,¨l×.DÑ.DÀQÈÓ.Jó4ˆLÐ/Ñ0ð 5JÐ0Ñ1á˜,Ó/€Iäˆy×ÑÓ!Ó"€DØ�Ð-Ð-Ð-r-   )NNNNN)r:   Útorch.nnrx   Útorch.nn.functionalr±   r<   Úutilsr   r   r   Úloss_for_object_detectionr   r   r   r	   r
   Úscipy.optimizer   Útransformers.image_transformsr   r   ÚModuler   rg   r  © r-   r   Ú<module>r&     sr   ðó Ý ß Ð ç NÑ N÷õ ñ ×ÒÝ4ñ ×ÒÝFòZôNt˜RŸY™Yô Ntôbs�—‘ô söl	%.r-   