+
    œ°³j7  ã                   óÈ  € R t ^ RIt^ RIHt ^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^RI
Ht ^RIHt ^RIHtHtHt ^R	IHt ]P*                  ! ]4      tR
 R ltR R ltR R ltR R ltR R lt]! RR7      ] ! R R]4      4       4       t ! R R]P<                  4      t ! R R]P<                  4      t  ! R R]P<                  4      t! ! R R]P<                  4      t"R ]!/t# ! R! R"]P<                  4      t$ ! R# R$]P<                  4      t% ! R% R&]P<                  4      t& ! R' R(]P<                  4      t'] ! R) R*]4      4       t(]! R+R7       ! R, R-](4      4       t)R*R-.t*R# ).zPyTorch SuperGlue model.N)Ú	dataclass)Únn)ÚPreTrainedModel©ÚSuperGlueConfig)Úinitialization)Úcreate_bidirectional_mask)ÚModelOutputÚauto_docstringÚlogging)ÚAutoModelForKeypointDetectionc                óº   € V ^8„  d   QhR\         \        P                  ,          R\         \        P                  ,          R\         \        P                  ,          /# )é   Útensor_tuple0Útensor_tuple1Úreturn)ÚtupleÚtorchÚTensor)Úformats   "Úq/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/superglue/modeling_superglue.pyÚ__annotate__r   "   sE   € ÷ jñ j¤¤e§l¡lÕ 3ð jÄEÌ%Ï,É,ÕDWð jÔ\aÔbg×bnÑbnÕ\oñ jó    c                ó~   € \         ;QJ d    . R \        W4       4       F  NK  	  5# ! R \        W4       4       4      # )a  
Concatenate two tuples of tensors pairwise

Args:
    tensor_tuple0 (`tuple[torch.Tensor]`):
        Tuple of tensors.
    tensor_tuple1 (`tuple[torch.Tensor]`):
        Tuple of tensors.

Returns:
    (`tuple[torch.Tensor]`): Tuple of concatenated tensors.
c              3   óT   "  € T F  w  r\         P                  ! W.4      x € K   	  R # 5i©N)r   Úcat)Ú.0Útensor0Útensor1s   &  r   Ú	<genexpr>Úconcat_pairs.<locals>.<genexpr>/   s$   é € ÐiÑGhÑ3C°7”—’˜GÐ-×.Ð.ÓGhùs   ‚&()r   Úzip)r   r   s   &&r   Úconcat_pairsr#   "   s0   € ÷ Œ5ÑiÄsÈ=ÔGhÓi�5Ðiˆ5ÑiÄsÈ=ÔGhÓiÓiÐir   c                óp   € V ^8„  d   QhR\         P                  R\        R\        R\         P                  /# )r   Ú	keypointsÚheightÚwidthr   ©r   r   Úint)r   s   "r   r   r   2   s6   € ÷ Bñ B¤5§<¡<ð B¼ð BÄSð BÌUÏ\É\ñ Br   c                ó   € \         P                  ! W!.V P                  V P                  R7      R,          pV^,          pVP	                  ^RR7      P
                  R,          pWR,          ,
          VR,          ,          # )aw  
Normalize keypoints locations based on image_shape

Args:
    keypoints (`torch.Tensor` of shape `(batch_size, num_keypoints, 2)`):
        Keypoints locations in (x, y) format.
    height (`int`):
        Image height.
    width (`int`):
        Image width.

Returns:
    Normalized keypoints locations of shape (`torch.Tensor` of shape `(batch_size, num_keypoints, 2)`).
)ÚdeviceÚdtypeNT)Úkeepdimgffffffæ?)ºNNNNr.   )r   Útensorr+   r,   ÚmaxÚvalues)r%   r&   r'   ÚsizeÚcenterÚscalings   &&&   r   Únormalize_keypointsr5   2   sf   € ô �<Š<˜˜°	×0@Ñ0@È	ÏÉÔXÐY]Õ^€DØ�A�X€FØ�h‰h�q $ˆhÓ'×.Ñ.°Õ4€GØ˜zÕ*Õ*¨g°jÕ.AÕAÐAr   c          
      ó¤   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        R\         P                  /# )r   Úlog_cost_matrixÚlog_source_distributionÚlog_target_distributionÚnum_iterationsr   r(   )r   s   "r   r   r   G   sQ   € ÷ Uñ UÜ—\‘\ðUä"Ÿ\™\ðUô #Ÿ\™\ðUô ð	Uô
 ‡\�\ñUr   c                ó¨  € \         P                  ! V4      p\         P                  ! V4      p\        V4       Fk  pV\         P                  ! WP	                  ^4      ,           ^R7      ,
          pV\         P                  ! WP	                  ^4      ,           ^R7      ,
          pKm  	  WP	                  ^4      ,           VP	                  ^4      ,           # )aJ  
Perform Sinkhorn Normalization in Log-space for stability

Args:
    log_cost_matrix (`torch.Tensor` of shape `(batch_size, num_rows, num_columns)`):
        Logarithm of the cost matrix.
    log_source_distribution (`torch.Tensor` of shape `(batch_size, num_rows)`):
        Logarithm of the source distribution.
    log_target_distribution (`torch.Tensor` of shape `(batch_size, num_columns)`):
        Logarithm of the target distribution.

Returns:
    log_cost_matrix (`torch.Tensor` of shape `(batch_size, num_rows, num_columns)`): Logarithm of the optimal
    transport matrix.
©Údim)r   Ú
zeros_likeÚrangeÚ	logsumexpÚ	unsqueeze)r7   r8   r9   r:   Úlog_u_scalingÚlog_v_scalingÚ_s   &&&&   r   Úlog_sinkhorn_iterationsrE   G   s¦   € ô* ×$Ò$Ð%<Ó=€MÜ×$Ò$Ð%<Ó=€MÜ�>Ö"ˆØ/´%·/²/À/×TkÑTkÐlmÓTnÕBnÐtuÔ2vÕvˆØ/´%·/²/À/×TkÑTkÐlmÓTnÕBnÐtuÔ2vÕvŠñ #ð ×4Ñ4°QÓ7Õ7¸-×:QÑ:QÐRSÓ:TÕTÐTr   c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )r   ÚscoresÚ	reg_paramÚ
iterationsr   r(   )r   s   "r   r   r   d   s8   € ÷ *(ñ *(¤%§,¡,ð *(¼5¿<¹<ð *(ÔUXð *(Ô]b×]iÑ]iñ *(r   c                ó`  € V P                   w  r4pV P                  ^4      pWF,          P                  V 4      WV,          P                  V 4      r‡VP                  W4^4      p	VP                  V^V4      p
VP                  V^^4      p\        P
                  ! \        P
                  ! W	.R4      \        P
                  ! W¡.R4      .^4      pWx,           P                  4       ) p\        P
                  ! VP                  V4      VP                  4       R,          V,           .4      p\        P
                  ! VP                  V4      VP                  4       R,          V,           .4      pVR,          P                  VR4      VR,          P                  VR4      rí\        W½WâR7      pWü,
          pV# )aë  
Perform Differentiable Optimal Transport in Log-space for stability

Args:
    scores: (`torch.Tensor` of shape `(batch_size, num_rows, num_columns)`):
        Cost matrix.
    reg_param: (`torch.Tensor` of shape `(batch_size, 1, 1)`):
        Regularization parameter.
    iterations: (`int`):
        Number of Sinkhorn iterations.

Returns:
    log_optimal_transport_matrix: (`torch.Tensor` of shape `(batch_size, num_rows, num_columns)`): Logarithm of the
    optimal transport matrix.
N)r:   éÿÿÿÿ)ÚshapeÚ
new_tensorÚtoÚexpandr   r   ÚlogrE   )rG   rH   rI   Ú
batch_sizeÚnum_rowsÚnum_columnsÚ
one_tensorÚnum_rows_tensorÚnum_columns_tensorÚsource_reg_paramÚtarget_reg_paramÚ	couplingsÚlog_normalizationr8   r9   Úlog_optimal_transport_matrixs   &&&             r   Úlog_optimal_transportr\   d   s‘  € ð  )/¯©Ñ%€J˜+Ø×"Ñ" 1Ó%€JØ+3Õ+@×*DÑ*DÀVÓ*LÈ{ÕOg×NkÑNkÐlrÓNsÐ'à ×'Ñ'¨
¸aÓ@ÐØ ×'Ñ'¨
°A°{ÓCÐØ× Ñ  ¨Q°Ó2€Iä—	’	œ5Ÿ9š9 fÐ%?ÀÓDÄeÇiÂiÐQaÐPmÐoqÓFrÐsÐuvÓw€Ià)Õ>×CÑCÓEÐEÐÜ#ŸišiØ	×	!Ñ	! (Ó	+Ð-?×-CÑ-CÓ-EÀdÕ-KÐN_Õ-_Ð`óÐô $ŸišiØ	×	!Ñ	! +Ó	.°×0CÑ0CÓ0EÀdÕ0KÐN_Õ0_Ð`óÐð 	  Õ%×,Ñ,¨Z¸Ó<Ø Õ%×,Ñ,¨Z¸Ó<ð 5ô
 $;ØÐ,Cô$Ð ð $@Õ#SÐ Ø'Ð'r   c                óD   € V ^8„  d   QhR\         R\        P                  /# )r   r=   r   )r)   r   r   )r   s   "r   r   r   ‘   s   € ÷ 2ñ 2œð 2¤§¡ñ 2r   c                 ór   € V P                  V P                  V,          4      P                  ^ 4      ^,
          # )é    )Únew_onesrL   Úcumsum)Úxr=   s   &&r   Úarange_likerc   ‘   s)   € Ø�:‰:�a—g‘g˜c•lÓ#×*Ñ*¨1Ó-°Õ1Ð1r   aò  
    Base class for outputs of SuperGlue keypoint matching models. Due to the nature of keypoint detection and matching, the number
    of keypoints is not fixed and can vary from image to image, which makes batching non-trivial. In the batch of
    images, the maximum number of matches is set as the dimension of the matches and matching scores. The mask tensor is
    used to indicate which values in the keypoints, matches and matching_scores tensors are keypoint matching
    information.
    )Úcustom_introc                   óL   a € ] tR t^•t o RtRtRtRtRtRt	Rt
RtV 3R ltRtV tR# )ÚSuperGlueKeypointMatchingOutputa²  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*):
    Loss computed during training.
matches (`torch.FloatTensor` of shape `(batch_size, 2, num_matches)`):
    Index of keypoint matched in the other image.
matching_scores (`torch.FloatTensor` of shape `(batch_size, 2, num_matches)`):
    Scores of predicted matches.
keypoints (`torch.FloatTensor` of shape `(batch_size, num_keypoints, 2)`):
    Absolute (x, y) coordinates of predicted keypoints in a given image.
mask (`torch.IntTensor` of shape `(batch_size, num_keypoints)`):
    Mask indicating which values in matches and matching_scores are keypoint matching information.
hidden_states (`tuple[torch.FloatTensor, ...]`, *optional*):
    Tuple of `torch.FloatTensor` (one for the output of each stage) of shape `(batch_size, 2, num_channels,
    num_keypoints)`, returned when `output_hidden_states=True` is passed or when
    `config.output_hidden_states=True`)
attentions (`tuple[torch.FloatTensor, ...]`, *optional*):
    Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, 2, num_heads, num_keypoints,
    num_keypoints)`, returned when `output_attentions=True` is passed or when `config.output_attentions=True`)
Nc                ó|  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   # )	r   NÚlossÚmatchesÚmatching_scoresr%   ÚmaskÚhidden_statesÚ
attentions)r   ÚFloatTensorÚ	IntTensorr   )r   Ú__classdict__s   "€r   r   Ú,SuperGlueKeypointMatchingOutput.__annotate__•   sÁ   ø‡ ‚ ñ> ×
Ñ
˜dÕ
"Ñ)ñ? ñ@ ×Ñ Õ%Ñ,ñA ñB ×&Ñ&¨Õ-Ñ4ñC ñD × Ñ  4Õ'Ñ.ñE ñF �/‰/˜DÕ
 Ñ'ñG ñH ™×*Ñ*Õ+¨dÕ2Ñ9ñI ñJ ‘e×'Ñ'Õ(¨4Õ/Ñ6òK r   © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rh   ri   rj   r%   rk   rl   rm   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)rp   s   @r   rf   rf   •   s7   ø‡ € ñð( &*€DØ(,€GØ04€OØ*.€IØ#'€DØ59€MØ26€J÷K ƒ r   rf   c                   óP   a a€ ] tR t^½t oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSuperGlueMultiLayerPerceptronc                ó0   <€ V ^8„  d   QhRS[ RS[RS[RR/# )r   ÚconfigÚin_channelsÚout_channelsr   N)r   r)   )r   rp   s   "€r   r   Ú*SuperGlueMultiLayerPerceptron.__annotate__¾   s+   ø€ ÷ $ñ $™ð $¹Sð $ÑPSð $ÐX\ñ $r   c                óÄ   <€ \         SV `  4        \        P                  ! W#4      V n        \        P
                  ! V4      V n        \        P                  ! 4       V n        R # r   )	ÚsuperÚ__init__r   ÚLinearÚlinearÚBatchNorm1dÚ
batch_normÚReLUÚ
activation)Úselfr~   r   r€   Ú	__class__s   &&&&€r   r„   Ú&SuperGlueMultiLayerPerceptron.__init__¾   s;   ø€ Ü‰ÑÔÜ—i’i Ó:ˆŒÜŸ.š.¨Ó6ˆŒÜŸ'š'›)ˆŽr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   Úhidden_stater   ©r   r   )r   rp   s   "€r   r   r�   Ä   s#   ø€ ÷ ñ ¡E§L¡Lð ±U·\±\ñ r   c                ó´   € V P                  V4      pVP                  RR4      pV P                  V4      pVP                  RR4      pV P                  V4      pV# )é   rK   éþÿÿÿ)r†   Ú	transposerˆ   rŠ   )r‹   r�   s   &&r   ÚforwardÚ%SuperGlueMultiLayerPerceptron.forwardÄ   sV   € Ø—{‘{ <Ó0ˆØ#×-Ñ-¨b°"Ó5ˆØ—‘ |Ó4ˆØ#×-Ñ-¨b°"Ó5ˆØ—‘ |Ó4ˆØÐr   )rŠ   rˆ   r†   ©	rs   rt   ru   rv   r„   r•   ry   rz   Ú__classcell__©rŒ   rp   s   @@r   r|   r|   ½   s   ù‡ € ÷$ó $÷÷ ð r   r|   c                   óT   a a€ ] tR t^Ít oV3R lV 3R lltRV3R lR lltRtVtV ;t# )ÚSuperGlueKeypointEncoderc                ó$   <€ V ^8„  d   QhRS[ RR/# ©r   r~   r   Nr   )r   rp   s   "€r   r   Ú%SuperGlueKeypointEncoder.__annotate__Î   s   ø€ ÷ -ñ -™ð -°4ñ -r   c           	     ó²  <€ \         SV `  4        VP                  pVP                  p^.V,           V.,           p\	        ^\        V4      ^,
          4       Uu. uF#  p\        WV^,
          ,          WE,          4      NK%  	  ppVP                  \        P                  ! VR,          VR,          4      4       \        P                  ! V4      V n        R# u upi )é   Nr“   rK   )rƒ   r„   Úkeypoint_encoder_sizesÚhidden_sizer?   Úlenr|   Úappendr   r…   Ú
ModuleListÚencoder)r‹   r~   Úlayer_sizesr¢   Úencoder_channelsÚiÚlayersrŒ   s   &&     €r   r„   Ú!SuperGlueKeypointEncoder.__init__Î   sº   ø€ Ü‰ÑÔØ×3Ñ3ˆØ×(Ñ(ˆà˜3 Õ,°¨}Õ<Ðô ˜1œcÐ"2Ó3°aÕ7Ô8ó
á8�ô *¨&À1ÀqÅ5Õ2IÐK[ÕK^Ö_Ù8ð 	ð 
ð 	�‰”b—i’iÐ 0°Õ 4Ð6FÀrÕ6JÓKÔLÜ—}’} VÓ,ˆŽùò
s   Á)Cc                óÄ   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[R,          RS[S[ P                  S[S[ P                  ,          R,          3,          /# )r   r%   rG   Úoutput_hidden_statesNr   ©r   r   Úboolr   )r   rp   s   "€r   r   rž   Ü   s[   ø€ ÷ /ñ /á—<‘<ð/ñ —‘ð/ñ # T�kð	/ñ
 
‰u�|‰|™U¡5§<¡<Õ0°4Õ7Ð7Õ	8ñ/r   c                óÐ   € VP                  ^4      p\        P                  ! W.^R7      pV'       d   RMRpV P                   F  pV! V4      pV'       g   K  WT3,           pK   	  WE3# )r   r<   Nrr   )rA   r   r   r¦   )r‹   r%   rG   r­   r�   Úall_hidden_statesÚlayers   &&&&   r   r•   Ú SuperGlueKeypointEncoder.forwardÜ   se   € ð ×!Ñ! !Ó$ˆÜ—y’y )Ð!4¸!Ô<ˆß"6™B¸DÐØ—\”\ˆEÙ  Ó.ˆLß#Ñ#Ø$5¸Õ$GÒ!ñ "ð Ð.Ð.r   )r¦   )Fr—   r™   s   @@r   r›   r›   Í   s   ù‡ € ÷-ó -÷/÷ /ò /r   r›   c                   óH   a a€ ] tR t^ìt oV 3R ltRV3R lR lltRtVtV ;t# )ÚSuperGlueSelfAttentionc                ó   <€ \         SV `  4        VP                  VP                  ,          ^ 8w  d9   \	        VR4      '       g'   \        RVP                   RVP                   R24      hVP                  V n        \        VP                  VP                  ,          4      V n        V P                  V P                  ,          V n        \        P                  ! VP                  V P                  4      V n        \        P                  ! VP                  V P                  4      V n        \        P                  ! VP                  V P                  4      V n        \        P                  ! VP                  4      V n        VP"                  V n        R# )r_   Úembedding_sizezThe hidden size (z6) is not a multiple of the number of attention heads (Ú)N)rƒ   r„   r¢   Únum_attention_headsÚhasattrÚ
ValueErrorr)   Úattention_head_sizeÚall_head_sizer   r…   ÚqueryÚkeyÚvalueÚDropoutÚattention_probs_dropout_probÚdropoutÚ
is_decoder©r‹   r~   rŒ   s   &&€r   r„   ÚSuperGlueSelfAttention.__init__í   s,  ø€ Ü‰ÑÔØ×Ñ × :Ñ :Õ:¸aÔ?ÌÐPVÐXh×HiÒHiÜØ# F×$6Ñ$6Ð#7ð 8Ø ×4Ñ4Ð5°Qð8óð ð
 $*×#=Ñ#=ˆÔ Ü#& v×'9Ñ'9¸F×<VÑ<VÕ'VÓ#WˆÔ Ø!×5Ñ5¸×8PÑ8PÕPˆÔä—Y’Y˜v×1Ñ1°4×3EÑ3EÓFˆŒ
Ü—9’9˜V×/Ñ/°×1CÑ1CÓDˆŒÜ—Y’Y˜v×1Ñ1°4×3EÑ3EÓFˆŒ
ä—z’z &×"EÑ"EÓFˆŒà ×+Ñ+ˆŽr   c                óê   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[S[ P                  ,          /# ©r   rl   Úattention_maskNÚencoder_hidden_statesÚencoder_attention_maskÚoutput_attentionsr   ©r   r   rn   r¯   r   )r   rp   s   "€r   r   Ú#SuperGlueSelfAttention.__annotate__  sy   ø€ ÷ 9ñ 9á—|‘|ð9ñ ×)Ñ)¨DÕ0ð9ñ  %×0Ñ0°4Õ7ð	9ñ
 !&× 1Ñ 1°DÕ 8ð9ñ   $�;ð9ñ 
‰u�|‰|Õ	ñ9r   c                óR  € VR JpV'       d   TMTpV'       d   TMTpVP                   ^ ,          pV P                  V4      P                  VRV P                  V P                  4      P                  ^^4      p	V P                  V4      P                  VRV P                  V P                  4      P                  ^^4      p
V P                  V4      P                  VRV P                  V P                  4      P                  ^^4      p\        P                  ! W¹P                  RR4      4      pV\        P                  ! V P                  4      ,          pVe	   WÂ,           p\        P                  P                  VRR7      pV P                  V4      p\        P                  ! WÚ4      pVP!                  ^ ^^^4      P#                  4       pVP%                  4       R R V P&                  3,           pVP                  V4      pV'       d   Wí3MV3pV P(                  '       d
   VR,           pV# )Nr<   rK   r“   r   )rL   r¿   Úviewr¹   r¼   r”   rÀ   r¾   r   ÚmatmulÚmathÚsqrtr   Ú
functionalÚsoftmaxrÃ   ÚpermuteÚ
contiguousr2   r½   rÄ   )r‹   rl   rÉ   rÊ   rË   rÌ   Úis_cross_attentionÚcurrent_statesrQ   Ú	key_layerÚvalue_layerÚquery_layerÚattention_scoresÚattention_probsÚcontext_layerÚnew_context_layer_shapeÚoutputss   &&&&&&           r   r•   ÚSuperGlueSelfAttention.forward  sÛ  € ð 3¸$Ð>Ðß2DÑ.È-ˆß3EÑ/È>ˆà"×(Ñ(¨Õ+ˆ
à�H‰H�^Ó$ß‰T�*˜b $×":Ñ":¸D×<TÑ<TÓUß‰Y�q˜!‹_ð 	ð �J‰J�~Ó&ß‰T�*˜b $×":Ñ":¸D×<TÑ<TÓUß‰Y�q˜!‹_ð 	ð �J‰J�}Ó%ß‰T�*˜b $×":Ñ":¸D×<TÑ<TÓUß‰Y�q˜!‹_ð 	ô !Ÿ<š<¨×5HÑ5HÈÈRÓ5PÓQÐà+¬d¯iªi¸×8PÑ8PÓ.QÕQÐØÒ%à/Õ@Ðô Ÿ-™-×/Ñ/Ð0@ÀbÐ/ÓIˆð Ÿ,™, Ó7ˆäŸš _ÓBˆà%×-Ñ-¨a°°A°qÓ9×DÑDÓFˆØ"/×"4Ñ"4Ó"6°s¸Ð";¸t×?QÑ?QÐ>SÕ"SÐØ%×*Ñ*Ð+BÓCˆç6G�=Ñ2ÈmÐM]ˆà�?�?ˆ?Ø Õ'ˆGØˆr   )r½   r¼   rÃ   rÄ   r¿   r¹   r¾   rÀ   ©NNNFr—   r™   s   @@r   rµ   rµ   ì   s   ù‡ € õ,÷(9÷ 9ò 9r   rµ   c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSuperGlueSelfOutputi=  c                ó    <€ V ^8„  d   QhRS[ /# ©r   r~   r   )r   rp   s   "€r   r   Ú SuperGlueSelfOutput.__annotate__>  s   ø€ ÷ Gñ G™ñ Gr   c                ó„   <€ \         SV `  4        \        P                  ! VP                  VP                  4      V n        R # r   )rƒ   r„   r   r…   r¢   ÚdenserÅ   s   &&€r   r„   ÚSuperGlueSelfOutput.__init__>  s,   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŽ
r   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   rl   r   r�   )r   rp   s   "€r   r   rè   B  s#   ø€ ÷ ñ ¡U§\¡\ð ¹U¿\¹\ñ r   c                ó(   € V P                  V4      pV# r   ©rê   )r‹   rl   Úargss   &&*r   r•   ÚSuperGlueSelfOutput.forwardB  s   € ØŸ
™
 =Ó1ˆØÐr   rî   r—   r™   s   @@r   rå   rå   =  s    ù‡ € ÷Gó G÷÷ ð r   rå   Úeagerc                   óH   a a€ ] tR tRt oV 3R ltRV3R lR lltRtVtV ;t# )ÚSuperGlueAttentioniL  c                óˆ   <€ \         SV `  4        \        VP                  ,          ! V4      V n        \        V4      V n        R # r   )rƒ   r„   Ú SUPERGLUE_SELF_ATTENTION_CLASSESÚ_attn_implementationr‹   rå   ÚoutputrÅ   s   &&€r   r„   ÚSuperGlueAttention.__init__M  s2   ø€ Ü‰ÑÔÜ4°V×5PÑ5PÖQÐRXÓYˆŒ	Ü)¨&Ó1ˆŽr   c                óê   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[S[ P                  ,          /# rÈ   rÍ   )r   rp   s   "€r   r   ÚSuperGlueAttention.__annotate__R  sw   ø€ ÷ ñ á—|‘|ðñ ×)Ñ)¨DÕ0ðñ  %×0Ñ0°4Õ7ð	ñ
 !&§¡¨tÕ 3ðñ   $�;ðñ 
‰u�|‰|Õ	ñr   c                ó†   € V P                  VVVVVR 7      pV P                  V^ ,          V4      pV3VR,          ,           pV# )©rÉ   rÊ   rË   rÌ   ºr’   NN)r‹   r÷   )	r‹   rl   rÉ   rÊ   rË   rÌ   Úself_outputsÚattention_outputrá   s	   &&&&&&   r   r•   ÚSuperGlueAttention.forwardR  sT   € ð —y‘yØØ)Ø"7Ø#9Ø/ð !ó 
ˆð  Ÿ;™; |°A¥¸ÓFÐØ#Ð%¨°RÕ(8Õ8ˆØˆr   )r÷   r‹   rã   r—   r™   s   @@r   ró   ró   L  s   ù‡ € õ2÷
÷ ò r   ró   c                   óT   a a€ ] tR tRt oV3R lV 3R lltRV3R lR lltRtVtV ;t# )ÚSuperGlueAttentionalPropagationif  c                ó$   <€ V ^8„  d   QhRS[ RR/# r�   r   )r   rp   s   "€r   r   Ú,SuperGlueAttentionalPropagation.__annotate__g  s   ø€ ÷ 
)ñ 
)™ð 
)°4ñ 
)r   c           	     ó¼  <€ \         SV `  4        VP                  p\        V4      V n        V^,          V^,          V.p\        ^\        V4      ^,
          4       Uu. uF#  p\        WV^,
          ,          W4,          4      NK%  	  ppVP                  \        P                  ! VR,          VR,          4      4       \        P                  ! V4      V n        R# u upi )r   Nr“   rK   )rƒ   r„   r¢   ró   Ú	attentionr?   r£   r|   r¤   r   r…   r¥   Úmlp)r‹   r~   r¢   Úmlp_channelsr©   rª   rŒ   s   &&    €r   r„   Ú(SuperGlueAttentionalPropagation.__init__g  s¶   ø€ Ü‰ÑÔØ×(Ñ(ˆÜ+¨FÓ3ˆŒØ# a�¨°q­¸+ÐFˆô ˜1œc ,Ó/°!Õ3Ô4ó
á4�ô *¨&¸qÀ1½uÕ2EÀ|ÅÖWÙ4ð 	ð 
ð 	�‰”b—i’i ¨RÕ 0°,¸rÕ2BÓCÔDÜ—=’= Ó(ˆŽùò
s   Á)Cc                óP  <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[RS[RS[S[ P                  S[S[ P                  ,          R,          S[S[ P                  ,          R,          3,          /# )	r   ÚdescriptorsrÉ   NrÊ   rË   rÌ   r­   r   r®   )r   rp   s   "€r   r   r  s  sœ   ø€ ÷ :ñ :á—\‘\ð:ñ Ÿ™ tÕ+ð:ñ  %Ÿ|™|¨dÕ2ð	:ñ
 !&§¡¨tÕ 3ð:ñ  ð:ñ #ð:ñ 
‰u�|‰|™U¡5§<¡<Õ0°4Õ7¹¹u¿|¹|Õ9LÈtÕ9SÐSÕ	Tñ:r   c                ó   € V P                  VVVVVR 7      pV^ ,          pVR,          p	\        P                  ! W.^R7      p
V'       d   RMRpV P                   F  pV! V
4      p
V'       g   K  Wº3,           pK   	  W«V	3# )rü   rý   r<   Nrr   )r  r   r   r  )r‹   r  rÉ   rÊ   rË   rÌ   r­   Úattention_outputsr÷   r  r�   r±   r²   s   &&&&&&&      r   r•   Ú'SuperGlueAttentionalPropagation.forwards  s�   € ð !ŸN™NØØ)Ø"7Ø#9Ø/ð +ó 
Ðð # 1Õ%ˆØ% bÕ)ˆ	ä—y’y +Ð!6¸AÔ>ˆç"6™B¸DÐØ—X”XˆEÙ  Ó.ˆLß#Ñ#Ø$5¸Õ$GÒ!ñ ð
 °	Ð9Ð9r   )r  r  )NNNFFr—   r™   s   @@r   r  r  f  s   ù‡ € ÷
)ó 
)÷:÷ :ò :r   r  c                   óT   a a€ ] tR tRt oV3R lV 3R lltRV3R lR lltRtVtV ;t# )ÚSuperGlueAttentionalGNNi‘  c                ó$   <€ V ^8„  d   QhRS[ RR/# r�   r   )r   rp   s   "€r   r   Ú$SuperGlueAttentionalGNN.__annotate__’  s   ø€ ÷ vñ v™ð v°4ñ vr   c                ó  <€ \         SV `  4        VP                  V n        VP                  V n        \
        P                  ! \        \        V P                  4      4       Uu. uF  p\        V4      NK  	  up4      V n
        R # u upi r   )rƒ   r„   r¢   Úgnn_layers_typesÚlayers_typesr   r¥   r?   r£   r  rª   )r‹   r~   rD   rŒ   s   && €r   r„   Ú SuperGlueAttentionalGNN.__init__’  sh   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔØ"×3Ñ3ˆÔÜ—m’mÔV[Ô\_Ð`d×`qÑ`qÓ\rÔVsÓ$tÑVsÐQRÔ%DÀVÖ%LÑVsÑ$tÓuˆŽùÒ$ts   Á"Bc                óÆ   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[RS[R,          RS[S[ P                  S[R,          S[R,          3,          /# )r   r  rk   NrÌ   r­   r   r®   )r   rp   s   "€r   r   r  ˜  sf   ø€ ÷ ->ñ ->á—\‘\ð->ñ �l‰l˜TÕ!ð->ñ  ð	->ñ
 # T�kð->ñ 
‰u�|‰|™U T�\©5°4­<Ð7Õ	8ñ->r   c           
     ó€  € V'       d   RMR pV'       d   RMR pVP                   w  rxp	V'       d
   WQ3,           p\        V P                  V P                  4       Fß  w  r«R pR pVR8X  dƒ   VP	                  R^W€P
                  4      P                  ^4      P	                  WxV P
                  4      pVe7   VP	                  R^^^V4      P                  ^4      P	                  V^^V4      MR pV
! VVVVVVR7      pV^ ,          pV'       d   W^^,          ,           pV'       d   Wn^,          ,           pW,           pKá  	  WV3# )NÚcross)rÉ   rÊ   rË   r­   rÌ   rr   rK   )rL   r"   rª   r  Úreshaper¢   Úflip)r‹   r  rk   rÌ   r­   r±   Úall_attentionsrQ   Únum_keypointsrD   Ú	gnn_layerÚ
layer_typerÊ   rË   Úgnn_outputsÚdeltas   &&&&&           r   r•   ÚSuperGlueAttentionalGNN.forward˜  sB  € ÷ #7™B¸DÐß0™°dˆà'2×'8Ñ'8Ñ$ˆ
 1ßØ 1°NÕ BÐä%(¨¯©°d×6GÑ6GÖ%HÑ!ˆIØ$(Ð!Ø%)Ð"Ø˜WÔ$à×'Ñ'¨¨A¨}×>NÑ>NÓOß‘T˜!“Wß‘W˜Z¸×8HÑ8HÓIð &ð Ò'ð —L‘L  Q¨¨1¨mÓ<×AÑAÀ!ÓD×LÑLÈZÐYZÐ\]Ð_lÔmàð 'ñ $ØØ#Ø&;Ø'=Ø%9Ø"3ôˆKð   •NˆEç#Ø$5ÀA½Õ$FÐ!ß Ø!/¸aµ.Õ!@�à%Õ-ŠKñ= &Ið> ¨~Ð=Ð=r   )r¢   rª   r  )NFFr—   r™   s   @@r   r  r  ‘  s    ù‡ € ÷vó v÷->÷ ->ò ->r   r  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚSuperGlueFinalProjectioniÈ  c                ó$   <€ V ^8„  d   QhRS[ RR/# r�   r   )r   rp   s   "€r   r   Ú%SuperGlueFinalProjection.__annotate__É  s   ø€ ÷ Iñ I™ð I°4ñ Ir   c                óv   <€ \         SV `  4        VP                  p\        P                  ! W"R R7      V n        R# )T)ÚbiasN)rƒ   r„   r¢   r   r…   Ú
final_proj)r‹   r~   r¢   rŒ   s   && €r   r„   Ú!SuperGlueFinalProjection.__init__É  s+   ø€ Ü‰ÑÔØ×(Ñ(ˆÜŸ)š) KÀ4ÔHˆŽr   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   r  r   r�   )r   rp   s   "€r   r   r&  Î  s#   ø€ ÷ ,ñ ,¡5§<¡<ð ,±E·L±Lñ ,r   c                ó$   € V P                  V4      # r   ©r)  )r‹   r  s   &&r   r•   Ú SuperGlueFinalProjection.forwardÎ  s   € Ø�‰˜{Ó+Ð+r   r-  r—   r™   s   @@r   r$  r$  È  s    ù‡ € ÷Ió I÷
,÷ ,ð ,r   r$  c                   ó~   a a€ ] tR tRt oRtRtRt]P                  ! 4       V3R lV 3R ll4       t	V3R lt
RtVtV ;t# )	ÚSuperGluePreTrainedModeliÒ  Ú	superglueÚpixel_valuesc                ó8   <€ V ^8„  d   QhRS[ P                  RR/# )r   Úmoduler   N)r   ÚModule)r   rp   s   "€r   r   Ú%SuperGluePreTrainedModel.__annotate__Ú  s   ø€ ÷ )ñ )¡B§I¡Ið )°$ñ )r   c                óŽ   <€ \         SV `  V4       \        VR4      '       d#   \        P                  ! VP
                  4       R# R# )zInitialize the weightsÚ	bin_scoreN)rƒ   Ú_init_weightsrº   ÚinitÚones_r8  )r‹   r4  rŒ   s   &&€r   r9  Ú&SuperGluePreTrainedModel._init_weightsÙ  s6   ø€ ô 	‰Ñ˜fÔ%Ü�6˜;×'Ò'Ü�JŠJ�v×'Ñ'Ö(ñ (r   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rç   r   )r   rp   s   "€r   r   r6  Ò  s   ø‡ ‚ áÑò r   rr   )Úimage)rs   rt   ru   rv   Úbase_model_prefixÚmain_input_nameÚinput_modalitiesr   Úno_gradr9  rx   ry   rz   r˜   r™   s   @@r   r0  r0  Ò  s<   ù‡ € ð $ÐØ$€OØ!Ðà
‡]‚]ƒ_÷)ò )ó ð)÷ … r   r0  zV
    SuperGlue model taking images as inputs and outputting the matching of them.
    c                   óx   a a€ ] tR tRt oRtV3R lV 3R lltR
V3R lR llt]RV3R lR ll4       tR	t	Vt
V ;t# )ÚSuperGlueForKeypointMatchingiá  aÈ  SuperGlue feature matching middle-end

Given two sets of keypoints and locations, we determine the
correspondences by:
  1. Keypoint Encoding (normalization + visual feature and location fusion)
  2. Graph Neural Network with multiple self and cross-attention layers
  3. Final projection layer
  4. Optimal Transport Layer (a differentiable Hungarian matching algorithm)
  5. Thresholding matrix based on mutual exclusivity and a match_threshold

The correspondence ids use -1 to indicate non-matching points.

Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, and Andrew
Rabinovich. SuperGlue: Learning Feature Matching with Graph Neural
Networks. In CVPR, 2020. https://huggingface.co/papers/1911.11763
c                ó$   <€ V ^8„  d   QhRS[ RR/# r�   r   )r   rp   s   "€r   r   Ú)SuperGlueForKeypointMatching.__annotate__ø  s   ø€ ÷ ñ ™ð °4ñ r   c                óz  <€ \         SV `  V4       \        P                  ! VP                  4      V n        \        V4      V n        \        V4      V n	        \        V4      V n        \        P                  P                  \        P                  ! R 4      4      pV P!                  RV4       V P#                  4        R# )g      ð?r8  N)rƒ   r„   r   Úfrom_configÚkeypoint_detector_configÚkeypoint_detectorr›   Úkeypoint_encoderr  Úgnnr$  Úfinal_projectionr   r   Ú	Parameterr/   Úregister_parameterÚ	post_init)r‹   r~   r8  rŒ   s   && €r   r„   Ú%SuperGlueForKeypointMatching.__init__ø  s†   ø€ Ü‰Ñ˜Ô ä!>×!JÒ!JÈ6×KjÑKjÓ!kˆÔä 8¸Ó @ˆÔÜ*¨6Ó2ˆŒÜ 8¸Ó @ˆÔä—H‘H×&Ñ&¤u§|¢|°CÓ'8Ó9ˆ	Ø×Ñ ¨YÔ7à�‰Ör   c                ó  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[RS[RS[ P                  R,          RS[R,          R	S[R,          R
S[S[ P                  S[ P                  S[S[3,          /	# )r   r%   r  rG   r&   r'   rk   NrÌ   r­   r   )r   r   r)   r¯   r   )r   rp   s   "€r   r   rF    s£   ø€ ÷ Q
ñ Q
á—<‘<ðQ
ñ —\‘\ðQ
ñ —‘ð	Q
ñ
 ðQ
ñ ðQ
ñ �l‰l˜TÕ!ðQ
ñ   $�;ðQ
ñ # T�kðQ
ñ 
‰u�|‰|™UŸ\™\©5±%Ð7Õ	8ñQ
r   c	                óø
  a&a'€ V'       d   RMRp	V'       d   RMRp
VP                   ^,          ^ 8X  dE   VP                   RR pVP                  VR\        P                  R7      VP	                  V4      V	V
3# VP                   w  o&po'pVP                  S&^,          S'^4      pVP                  S&^,          S'V P                  P                  4      pVP                  S&^,          S'4      pVe   VP                  S&^,          S'4      MRp\        WV4      pV P                  WVR7      pV^ ,          pW.,           p\        V P                  VR,          VR7      pV P                  VVVVR7      pV^ ,          pV P                  V4      pVP                  S&^S'V P                  P                  4      pVR,          pVR,          pVVP                  ^^4      ,          pW0P                  P                  R,          ,          pVe˜   VP                  S&^S'4      pVR,          P                  ^4      pVR,          P                  ^4      p\        P                  ! VV4      pVP!                  V^ 8H  \        P"                  ! VP$                  4      P&                  4      p\)        W0P*                  V P                  P,                  R7      pVRRR1RR13,          P/                  ^4      pVRRR1RR13,          P/                  ^4      pVP0                  pVP0                  p\3        V^4      R,          VP5                  ^V4      8H  p\3        V^4      R,          VP5                  ^V4      8H  pVP7                  ^ 4      p\        P8                  ! VVP:                  P=                  4       V4      p\        P8                  ! VV P                  P>                  8„  VV4      p\        P8                  ! VVP5                  ^V4      V4      pVVV8„  ,          p VV P5                  ^V4      ,          p!\        P8                  ! V VVP7                  R4      4      p"\        P8                  ! V!VVP7                  R4      4      p#\        P@                  ! V"V#.^R	7      P                  S&^R4      p$\        P@                  ! VV.^R	7      P                  S&^R4      p%V'       d^   W�^,          ,           p	V	V^,          ,           p	V	V3,           p	\B        ;QJ d    . V&V'3R
 lV	 4       F  NK  	  5M! V&V'3R
 lV	 4       4      p	V'       dE   V
V^,          ,           p
\B        ;QJ d    . V&V'3R lV
 4       F  NK  	  5M! V&V'3R lV
 4       4      p
V$V%V	V
3# )aM  
Perform keypoint matching between two images.

Args:
    keypoints (`torch.Tensor` of shape `(batch_size, 2, num_keypoints, 2)`):
        Keypoints detected in the pair of image.
    descriptors (`torch.Tensor` of shape `(batch_size, 2, descriptor_dim, num_keypoints)`):
        Descriptors of the keypoints detected in the image pair.
    scores (`torch.Tensor` of shape `(batch_size, 2, num_keypoints)`):
        Confidence scores of the keypoints detected in the image pair.
    height (`int`): Image height.
    width (`int`): Image width.
    mask (`torch.Tensor` of shape `(batch_size, 2, num_keypoints)`, *optional*):
        Mask indicating which values in the keypoints, matches and matching_scores tensors are keypoint matching
        information.
    output_attentions (`bool`, *optional*):
        Whether or not to return the attentions tensors. Default to `config.output_attentions`.
    output_hidden_states (`bool`, *optional*):
        Whether or not to return the hidden states of all layers. Default to `config.output_hidden_states`.

Returns:
    matches (`torch.Tensor` of shape `(batch_size, 2, num_keypoints)`):
        For each image pair, for each keypoint in image0, the index of the keypoint in image1 that was matched
        with. And for each keypoint in image1, the index of the keypoint in image0 that was matched with.
    matching_scores (`torch.Tensor` of shape `(batch_size, 2, num_keypoints)`):
        Scores of predicted matches for each image pair
    all_hidden_states (`tuple(torch.FloatTensor)`, *optional*):
        Tuple of `torch.FloatTensor` (one for the output of each stage) of shape `(1, 2, num_keypoints,
        num_channels)`.
    all_attentions (`tuple(torch.FloatTensor)`, *optional*):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(1, 2, num_heads, num_keypoints,
        num_keypoints)`.
N)r,   )r­   r.   )r~   Úinputs_embedsrÉ   )rk   r­   rÌ   g      à?)rI   r<   c              3   ój   <"  € T F(  qP                  S^SR4      P                  RR4      x € K*  	  R# 5i)r   NrK   r“   )r  r”   ©r   rb   rQ   r  s   & €€r   r    ÚASuperGlueForKeypointMatching._match_image_pair.<locals>.<genexpr>‹  s3   øé € ð &ÙWhÐRS—	‘	˜* a¨¸Ó;×EÑEÀbÈ"×MÐMÓWhùs   ƒ03c              3   óL   <"  € T F  qP                  S^RSS4      x € K  	  R# 5i)r   NrK   )r  rV  s   & €€r   r    rW  �  s&   øé € Ð"vÑguÐbc§9¡9¨Z¸¸BÀÈ}×#]Ð#]Óguùs   ƒ!$rr   rK   )r.   :r_   r’   Nr.   )r.   r_   )r.   r’   )"rL   Únew_fullr   r)   Ú	new_zerosr  r~   r¢   r5   rK  r   rL  rM  r”   rA   Úlogical_andÚmasked_fillÚfinfor,   Úminr\   r8  Úsinkhorn_iterationsr0   Úindicesrc   ÚgatherrM   Úwherer1   ÚexpÚmatching_thresholdr   r   )(r‹   r%   r  rG   r&   r'   rk   rÌ   r­   r±   r  rL   rD   Úencoded_keypointsÚlast_hidden_stateÚextended_attention_maskr   Úprojected_descriptorsÚfinal_descriptorsÚfinal_descriptors0Úfinal_descriptors1Úmask0Úmask1Úmax0Úmax1Úindices0Úindices1Úmutual0Úmutual1ÚzeroÚmatching_scores0Úmatching_scores1Úvalid0Úvalid1Úmatches0Úmatches1ri   rj   rQ   r  s(   &&&&&&&&&                             @@r   Ú_match_image_pairÚ.SuperGlueForKeypointMatching._match_image_pair  sì  ù€ ÷X #7™B¸DÐß0™°dˆà�?‰?˜1Õ Ô"Ø—O‘O C RÐ(ˆEà×"Ñ" 5¨"´E·I±IÐ"Ó>Ø×#Ñ# EÓ*Ø!Øð	ð ð +4¯/©/Ñ'ˆ
�A�} aà×%Ñ% j°1¥n°mÀQÓGˆ	Ø!×)Ñ)¨*°q­.¸-ÈÏÉ×I`ÑI`ÓaˆØ—‘ 
¨Q¥°Ó>ˆØ>BÒ>Nˆt�|‰|˜J¨�N¨MÔ:ÐTXˆô (¨	¸5ÓAˆ	à ×1Ñ1°)ÐZnÐ1ÓoÐà-¨aÕ0Ðð "Õ5ˆä";Ø—;‘;Ø% iÕ0Øô#
Ðð —h‘hØØ(Ø!5Ø/ð	 ó 
ˆð " !•nˆð !%× 5Ñ 5°kÓ BÐð 2×9Ñ9¸*ÀaÈÐX\×XcÑXc×XoÑXoÓpÐØ.¨tÕ4ÐØ.¨tÕ4Ðð $Ð&8×&BÑ&BÀ1ÀaÓ&HÕHˆØŸ+™+×1Ñ1°3Õ6Õ6ˆàÒØ—<‘< 
¨A¨}Ó=ˆDØ˜•J×(Ñ(¨Ó+ˆEØ˜•J×(Ñ(¨Ó+ˆEÜ×$Ò$ U¨EÓ2ˆDØ×'Ñ'¨°©	´5·;²;¸v¿|¹|Ó3L×3PÑ3PÓQˆFô ' v¯~©~È$Ï+É+×JiÑJiÔjˆð �a˜˜"˜˜c˜r˜c�kÕ"×&Ñ& qÓ)ˆØ�a˜˜"˜˜c˜r˜c�kÕ"×&Ñ& qÓ)ˆØ—<‘<ˆØ—<‘<ˆÜ˜h¨Ó*¨4Õ0°H·O±OÀAÀxÓ4PÑPˆÜ˜h¨Ó*¨4Õ0°H·O±OÀAÀxÓ4PÑPˆØ× Ñ  Ó#ˆÜ Ÿ;š; w°·±·±Ó0AÀ4ÓHÐÜ Ÿ;š;Ð'7¸$¿+¹+×:XÑ:XÑ'XÐZjÐlpÓqÐÜ Ÿ;š; wÐ0@×0GÑ0GÈÈ8Ó0TÐVZÓ[ÐØÐ,¨tÑ3Õ4ˆØ˜6Ÿ=™=¨¨HÓ5Õ5ˆÜ—;’;˜v x°×1DÑ1DÀRÓ1HÓIˆÜ—;’;˜v x°×1DÑ1DÀRÓ1HÓIˆä—)’)˜X xÐ0°aÔ8×@Ñ@ÀÈQÐPRÓSˆÜŸ)š)Ð%5Ð7GÐ$HÈaÔP×XÑXÐYcÐefÐhjÓkˆçØ 1ÀaÕ4HÕ HÐØ 1°KÀµNÕ BÐØ 1Ð5JÐ4LÕ LÐß %¤õ &ÙWhó&§¡õ &ÙWhó&ó !Ð÷ Ø+¨k¸!­nÕ<ˆNß"œUÕ"vÑguÓ"vŸU™UÕ"vÑguÓ"vÓvˆNð ØØØð	
ð 	
r   c                ó®   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[R,          RS[R,          RS[R,          RS[S[,          /# )r   r2  ÚlabelsNrÌ   r­   Úreturn_dictr   )r   rn   Ú
LongTensorr¯   r   rf   )r   rp   s   "€r   r   rF  š  sr   ø€ ÷ Y
ñ Y
á×'Ñ'ðY
ñ × Ñ  4Õ'ðY
ñ   $�;ð	Y
ñ
 # T�kðY
ñ ˜D•[ðY
ñ 
Ñ0Õ	0ñY
r   c                ó.  € RpVe   \        R4      hVe   TMV P                  P                  pVe   TMV P                  P                  pVe   TMV P                  P                  pVP
                  ^8w  g   VP                  ^4      ^8w  d   \        R4      hVP                  w  r‰r«pVP                  V^,          W«V4      pV P                  V4      pVR,          w  rïppVP                  V^R^4      P                  V4      pVP                  V^R4      P                  V4      pVP                  V^RV P                  P                  4      P                  V4      pVP                  V^R4      pVP                  4       pVR	,          V,          VR	&   VR
,          V,          VR
&   V P                  VVVVVVVVR7      w  ppppV'       g;   \        ;QJ d    . R VVVVVVV3 4       F  NK  	  5# ! R VVVVVVV3 4       4      # \        VVVVVVVR7      # )aÿ  
Examples:

```python
>>> from transformers import AutoImageProcessor, AutoModel
>>> import torch
>>> from PIL import Image
>>> import httpx
>>> from io import BytesIO

>>> url = "https://github.com/magicleap/SuperGluePretrainedNetwork/blob/master/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg?raw=true"
>>> with httpx.stream("GET", url) as response:
...     image_1 = Image.open(BytesIO(response.read()))

>>> url = "https://github.com/magicleap/SuperGluePretrainedNetwork/blob/master/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg?raw=true"
>>> with httpx.stream("GET", url) as response:
...     image_2 = Image.open(BytesIO(response.read()))

>>> images = [image_1, image_2]

>>> processor = AutoImageProcessor.from_pretrained("magic-leap-community/superglue_outdoor")
>>> model = AutoModel.from_pretrained("magic-leap-community/superglue_outdoor")

>>> with torch.no_grad():
>>>     inputs = processor(images, return_tensors="pt")
>>>     outputs = model(**inputs)
```Nz9SuperGlue is not trainable, no labels should be provided.zOInput must be a 5D tensor of shape (batch_size, 2, num_channels, height, width):Né   N)rk   rÌ   r­   c              3   ó2   "  € T F  pVf   K	  Vx € K  	  R # 5ir   rr   )r   Úvs   & r   r    Ú7SuperGlueForKeypointMatching.forward.<locals>.<genexpr>å  s   é € ð áe�AØ÷ ’Ûeùs   ‚�
)rh   ri   rj   r%   rk   rl   rm   rK   )r.   r.   r.   r_   )r.   r.   r.   r’   )r»   r~   rÌ   r­   r  Úndimr2   rL   r  rJ  rN   r¢   Úcloner{  r   rf   )r‹   r2  r~  rÌ   r­   r  Úkwargsrh   rQ   rD   Úchannelsr&   r'   Úkeypoint_detectionsr%   rG   r  rk   Úabsolute_keypointsri   rj   rl   rm   s   &&&&&&,                r   r•   Ú$SuperGlueForKeypointMatching.forward™  sF  € ðJ ˆØÒÜÐXÓYÐYà1BÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆà×Ñ Ô! \×%6Ñ%6°qÓ%9¸QÔ%>ÜÐnÓoÐoà1=×1CÑ1CÑ.ˆ
�x¨Ø#×+Ñ+¨J¸­N¸HÈeÓTˆØ"×4Ñ4°\ÓBÐà/BÀ2Õ/FÑ,ˆ	˜;¨Ø×%Ñ% j°!°R¸Ó;×>Ñ>¸|ÓLˆ	Ø—‘ 
¨A¨rÓ2×5Ñ5°lÓCˆØ!×)Ñ)¨*°a¸¸T¿[¹[×=TÑ=TÓU×XÑXÐYeÓfˆØ�|‰|˜J¨¨2Ó.ˆà&Ÿ_™_Ó.ÐØ);¸JÕ)GÈ%Õ)OÐ˜:Ñ&Ø);¸JÕ)GÈ&Õ)PÐ˜:Ñ&à>B×>TÑ>TØØØØØØØ/Ø!5ð ?Uó 	?
Ñ;ˆ� -°÷ ß”5ñ à ¨¸)ÀTÈ=ÐZdÑeó—5ð �5ñ à ¨¸)ÀTÈ=ÐZdÑeóó ð ô /ØØØ+ØØØ'Ø!ô
ð 	
r   )rM  rL  rJ  rK  )NNN)NNNN)rs   rt   ru   rv   rw   r„   r{  r
   r•   ry   rz   r˜   r™   s   @@r   rD  rD  á  sC   ù‡ € ñ÷"ó ÷Q
ò Q
ðf ÷Y
ñ Y
ó ÷Y
ð Y
r   rD  )+rw   rÒ   Údataclassesr   r   r   Útransformersr   Ú5transformers.models.superglue.configuration_supergluer   Ú r   r:  Úmasking_utilsr   Úutilsr	   r
   r   Úautor   Ú
get_loggerrs   Úloggerr#   r5   rE   r\   rc   rf   r5  r|   r›   rµ   rå   rõ   ró   r  r  r$  r0  rD  Ú__all__rr   r   r   Ú<module>r—     sp  ðñ ã Ý !ã Ý å (Ý Qå &Ý 6ß 9Ñ 9Ý 0ð 
×	Ò	˜HÓ	%€õjõ Bõ*Uõ:*(õZ2ñ ðôð ô7 kó 7ó óð7ô< B§I¡Iô ô /˜rŸy™yô /ô>N˜RŸY™Yô Nôb˜"Ÿ)™)ô ð Ð#ð$Ð  ô
˜Ÿ™ô ô4(: b§i¡iô (:ôV4>˜bŸi™iô 4>ôn,˜rŸy™yô ,ð ô)˜ó )ó ð)ñ ðôô
M
Ð#;ó M
óð
M
ð` &Ð'EÐ
F‚r   