+
    œ°³j¡  ã                   óŽ  € ^ RI Ht ^ RIHt ^ RIHt ^ RIt^ RIt^ RI	H
t
 ^ RIH
u 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Ht ^RIHt ^RI H!t!H"t"H#t#H$t$ ^RI%H&t&H't' ^RI(H)t) ^RI*H+t+H,t,H-t- ]#! RR7      ] ! R R]!4      4       4       t.]#! RR7      ] ! R R]!4      4       4       t/]#] ! R R]!4      4       4       t0 ! R R]
Pb                  4      t2 ! R R]
Pb                  4      t3R6R R llt4 ! R R ]
Pb                  4      t5 ! R! R"]
Pb                  4      t6 ! R# R$]4      t7]# ! R% R&]4      4       t8 ! R' R(]
Pb                  4      t9]#! R)R7       ! R* R+]84      4       t:]#! R,R7       ! R- R.]84      4       t; ! R/ R0]
Pb                  4      t<]# ! R1 R2]84      4       t=]#! R3R7       ! R4 R5]84      4       t>. R7Ot?R# )8é    )ÚCallable)Ú	dataclass)ÚAnyN)Úinitialization)ÚACT2FN)Úcreate_bidirectional_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚImageClassifierOutput)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)ÚModelOutputÚTransformersKwargsÚauto_docstringÚtorch_compilable_check)Úcan_return_tupleÚmerge_with_config_defaults)Úcapture_outputs)ÚSiglip2ConfigÚSiglip2TextConfigÚSiglip2VisionConfigz}
    Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.
    )Úcustom_introc                   ó@   a € ] tR t^,t o RtRtRtRtRtV 3R lt	Rt
V tR# )ÚSiglip2VisionOutputzì
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
    The image embeddings obtained by applying the projection layer to the pooler_output.
Nc                óú   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[ P                  R3,          R,          ;R&   S[S[ P                  R3,          R,          ;R&   # )é   NÚimage_embedsÚlast_hidden_state.Úhidden_statesÚ
attentions©ÚtorchÚFloatTensorÚtuple)ÚformatÚ__classdict__s   "€Úm/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/siglip2/modeling_siglip2.pyÚ__annotate__Ú Siglip2VisionOutput.__annotate__,   sy   ø‡ ‚ ñ ×#Ñ# dÕ*Ñ1ñ ñ ×(Ñ(¨4Õ/Ñ6ñ ñ ™×*Ñ*¨CÐ/Õ0°4Õ7Ñ>ñ ñ ‘e×'Ñ'¨Ð,Õ-°Õ4Ñ;ò ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r    r!   r"   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r(   s   @r)   r   r   ,   s(   ø‡ € ñð
 .2€LØ26ÐØ:>€MØ7;€J÷ ƒ r,   r   ze
    Base class for text model's outputs that also contains a pooling of the last hidden states.
    c                   ó@   a € ] tR t^>t o RtRtRtRtRtV 3R lt	Rt
V tR# )ÚSiglip2TextOutputzê
text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
    The text embeddings obtained by applying the projection layer to the pooler_output.
Nc                óú   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[ P                  R3,          R,          ;R&   S[S[ P                  R3,          R,          ;R&   # )r   NÚtext_embedsr    .r!   r"   r#   )r'   r(   s   "€r)   r*   ÚSiglip2TextOutput.__annotate__>   sy   ø‡ ‚ ñ ×"Ñ" TÕ)Ñ0ñ ñ ×(Ñ(¨4Õ/Ñ6ñ ñ ™×*Ñ*¨CÐ/Õ0°4Õ7Ñ>ñ ñ ‘e×'Ñ'¨Ð,Õ-°Õ4Ñ;ò r,   r-   )r.   r/   r0   r1   r2   r:   r    r!   r"   r3   r4   r5   r6   s   @r)   r8   r8   >   s(   ø‡ € ñð
 -1€KØ26ÐØ:>€MØ7;€J÷ ƒ r,   r8   c                   ó^   a € ] tR t^Pt o RtRtRtRtRtRt	Rt
RtV 3R lR ltV 3R ltRtV tR# )ÚSiglip2Outputaq  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `return_loss` is `True`):
    Contrastive loss for image-text similarity.
logits_per_image (`torch.FloatTensor` of shape `(image_batch_size, text_batch_size)`):
    The scaled dot product scores between `image_embeds` and `text_embeds`. This represents the image-text
    similarity scores.
logits_per_text (`torch.FloatTensor` of shape `(text_batch_size, image_batch_size)`):
    The scaled dot product scores between `text_embeds` and `image_embeds`. This represents the text-image
    similarity scores.
text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
    The text embeddings obtained by applying the projection layer to the pooled output of [`Siglip2TextModel`].
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
    The image embeddings obtained by applying the projection layer to the pooled output of [`Siglip2VisionModel`].
text_model_output (`BaseModelOutputWithPooling`):
    The output of the [`Siglip2TextModel`].
vision_model_output (`BaseModelOutputWithPooling`):
    The output of the [`Siglip2VisionModel`].
Nc                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r   Úreturn)r&   r   )r'   r(   s   "€r)   r*   ÚSiglip2Output.__annotate__n   s   ø€ ÷ _ñ _™%¡�*ñ _r,   c                ó’   € \         ;QJ d"    . R  V P                  4        4       F  NK  	  5# ! R  V P                  4        4       4      # )c              3   ór   "  € T F-  p\        V\        4      '       d   VP                  4       MTx € K/  	  R # 5i©N)Ú
isinstancer   Úto_tuple)Ú.0Úvs   & r)   Ú	<genexpr>Ú)Siglip2Output.to_tuple.<locals>.<genexpr>o   s)   é € Ð^ÑP]È1¤Z°´;×%?Ò%?�Q—Z‘Z”\ÀQÔFÓP]ùs   ‚57)r&   Úvalues©Úselfs   &r)   rF   ÚSiglip2Output.to_tuplen   s8   € ßŒuÑ^ÐPT×P[ÑP[ÔP]Ó^�uÐ^ˆuÑ^ÐPT×P[ÑP[ÔP]Ó^Ó^Ð^r,   c                ó  <€ 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[;R&   S[;R&   # )	r   NÚlossÚlogits_per_imageÚlogits_per_textr:   r   Útext_model_outputÚvision_model_output)r$   r%   r   )r'   r(   s   "€r)   r*   rA   P   s—   ø‡ ‚ ñ, ×
Ñ
˜dÕ
"Ñ)ñ- ñ. ×'Ñ'¨$Õ.Ñ5ñ/ ñ0 ×&Ñ&¨Õ-Ñ4ñ1 ñ2 ×"Ñ" TÕ)Ñ0ñ3 ñ4 ×#Ñ# dÕ*Ñ1ñ5 ñ6 2Ñ8ñ7 ñ8 4Ñ:ò9 r,   r-   )r.   r/   r0   r1   r2   rP   rQ   rR   r:   r   rS   rT   rF   r3   r4   r5   r6   s   @r)   r=   r=   P   sE   ø‡ € ñð& &*€DØ15ÐØ04€OØ,0€KØ-1€LØ48ÐØ6:Ð÷_ð _÷= ƒ r,   r=   c                   ól   a a€ ] tR t^rt oV3R lV 3R llt]V3R lR l4       tV3R lR ltRtVt	V ;t
# )ÚSiglip2VisionEmbeddingsc                ó    <€ V ^8„  d   QhRS[ /# ©r   Úconfig©r   )r'   r(   s   "€r)   r*   Ú$Siglip2VisionEmbeddings.__annotate__s   s   ø€ ÷ Qñ QÑ2ñ Qr,   c                óÞ  <€ \         SV `  4        Wn        VP                  V n        VP
                  V n        \        P                  ! VP                  V P
                  ,          V P
                  ,          V P                  R 7      V n	        VP                  V n
        \        V P                  R,          4      V n        \        P                  ! V P                  V P                  4      V n        R# ))Úin_featuresÚout_featuresg      à?N)ÚsuperÚ__init__rY   Úhidden_sizeÚ	embed_dimÚ
patch_sizeÚnnÚLinearÚnum_channelsÚpatch_embeddingÚnum_patchesÚintÚposition_embedding_sizeÚ	EmbeddingÚposition_embedding©rM   rY   Ú	__class__s   &&€r)   r`   Ú Siglip2VisionEmbeddings.__init__s   s¥   ø€ Ü‰ÑÔØŒØ×+Ñ+ˆŒØ ×+Ñ+ˆŒä!ŸyšyØ×+Ñ+¨d¯o©oÕ=ÀÇÁÕOØŸ™ô 
ˆÔð
 "×-Ñ-ˆÔÜ'*¨4×+;Ñ+;¸SÕ+@Ó'AˆÔ$Ü"$§,¢,¨t×/?Ñ/?ÀÇÁÓ"PˆÖr,   c                ón   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[ P                  /# )r   Úpositional_embeddingsÚspatial_shapesÚ
max_lengthr@   )r$   ÚTensorÚ
LongTensorri   )r'   r(   s   "€r)   r*   r[   ƒ   s?   ø€ ÷ ;.ñ ;.Ù$Ÿ|™|ð;.á×(Ñ(ð;.ñ ð;.ñ 
�‰ñ	;.r,   c           	     ó  € VP                   ^ ,          pV P                   R,          pV P                  p\        P                  ! W2V3V P                  VR7      pV P                  ^^ ^4      P                  ^ 4      p V P                  P                  R8X  d    V P                  \        P                  4      p \        V4       FÆ  pW,          P                  4       w  r‰\        V	^ 8„  R4       \        V^ 8„  R4       \        W‰,          V8*  R4       \        P                  ! V W‰3RRRR	7      p
V
P                  WHV	,          4      P!                  ^ ^4      p
V
P                  V4      p
W¦VR
W‰,          13&   V
^ ,          WgW‰,          R
13&   KÈ  	  V# )a  
Resize positional embeddings to image-specific size and pad to a fixed size.

Args:
    positional_embeddings (`torch.Tensor`):
        Position embeddings of shape (height, width, embed_dim)
    spatial_shapes (`torch.LongTensor`):
        Spatial shapes of shape (batch_size, 2) to resize the positional embeddings to
    max_length (`int`):
        Maximum length of the positional embeddings to pad resized positional embeddings to

Returns:
    `torch.Tensor`: Embeddings of shape (batch_size, max_length, embed_dim)
©ÚdeviceÚdtypeÚcpuz8Width of resized positional embeddings must be positive.z9Height of resized positional embeddings must be positive.z0Resized positional embeddings exceed max_length.ÚbilinearFT)ÚsizeÚmodeÚalign_cornersÚ	antialiasNéÿÿÿÿ)Úshapery   r$   Úemptyrx   ÚpermuteÚ	unsqueezeÚtypeÚtoÚfloat32ÚrangeÚtolistr   ÚFÚinterpolateÚreshapeÚ	transpose)rq   rr   rs   Ú
batch_sizerb   Úsource_dtypeÚresulted_positional_embeddingsÚiÚheightÚwidthÚresized_embeddingss   &&&        r)   Úresize_positional_embeddingsÚ4Siglip2VisionEmbeddings.resize_positional_embeddings‚   s‚  € ð( $×)Ñ)¨!Õ,ˆ
Ø)×/Ñ/°Õ3ˆ	Ø,×2Ñ2ˆä).¯ªØ YÐ/Ø(×/Ñ/Øô*
Ð&ð !6× =Ñ =¸aÀÀAÓ F× PÑ PÐQRÓ SÐð !×'Ñ'×,Ñ,°Ô5Ø$9×$<Ñ$<¼U¿]¹]Ó$KÐ!ä�zÖ"ˆAà*Õ-×4Ñ4Ó6‰MˆFÜ" E¨A¡IÐ0jÔkÜ" F¨Q¡JÐ1lÔmÜ" F¥N°zÑ#AÐCuÔvÜ!"§¢Ø%Ø�_ØØ#Øô"Ðð "4×!;Ñ!;¸IÐPUÅ~Ó!V×!`Ñ!`ÐabÐdeÓ!fÐð "4×!6Ñ!6°|Ó!DÐàBT¨1Ð.>°µÐ.>Ð+>Ñ?ØBTÐUVÕBWÐ*¨f­nÑ.>Ð+>Ó?ñ+ #ð. .Ð-r,   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# )r   Úpixel_valuesrr   r@   )r$   r%   ru   rt   )r'   r(   s   "€r)   r*   r[   À   s5   ø€ ÷ ñ ¡E×$5Ñ$5ð Áu×GWÑGWð Ñ\a×\hÑ\hñ r,   c                óV  € V P                   P                  P                  pV P                  VP                  VR7      4      pV P                  P                  P                  V P                  V P                  R4      pV P                  WRVP                  ^,          R7      pWF,           pV# )a  
Args:
    pixel_values (`torch.FloatTensor`):
        Pixel values of shape (batch_size, max_num_patches, num_channels * patch_size * patch_size)
    spatial_shapes (`list[tuple[int, int]]`):
        Spatial shapes of shape (batch_size, 2) to resize the positional embeddings to
)ry   )rs   r€   )	rg   Úweightry   r†   rl   rŒ   rj   r•   r�   )rM   r˜   rr   Útarget_dtypeÚpatch_embedsrq   Úresized_positional_embeddingsÚ
embeddingss   &&&     r)   ÚforwardÚSiglip2VisionEmbeddings.forwardÀ   s¢   € ð ×+Ñ+×2Ñ2×8Ñ8ˆØ×+Ñ+¨L¯O©OÀ,¨OÓ,OÓPˆð !%× 7Ñ 7× >Ñ >× FÑ FØ×(Ñ(¨$×*FÑ*FÈó!
Ðð )-×(IÑ(IØ!¸l×>PÑ>PÐQRÕ>Sð )Jó )
Ð%ð
 "ÕAˆ
ØÐr,   )rY   rb   rh   rg   rc   rl   rj   )r.   r/   r0   r1   r`   Ústaticmethodr•   rŸ   r4   r5   Ú__classcell__©rn   r(   s   @@r)   rV   rV   r   s5   ù‡ € ÷Qó Qð ÷;.ó ð;.÷z÷ ð r,   rV   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# )ÚSiglip2TextEmbeddingsc                ó    <€ V ^8„  d   QhRS[ /# rX   ©r   )r'   r(   s   "€r)   r*   Ú"Siglip2TextEmbeddings.__annotate__Û   s   ø€ ÷ vñ vÑ0ñ vr,   c                óh  <€ \         SV `  4        VP                  p\        P                  ! VP
                  V4      V n        \        P                  ! VP                  V4      V n        \        P                  ! \        P                  ! VP                  4      P                  R4      RR7      V n        R# )é   F)Ú
persistentN©rª   r€   )r_   r`   ra   rd   rk   Ú
vocab_sizeÚtoken_embeddingÚmax_position_embeddingsrl   ÚBufferr$   ÚarangeÚexpandÚposition_ids©rM   rY   rb   rn   s   && €r)   r`   ÚSiglip2TextEmbeddings.__init__Û   s|   ø€ Ü‰ÑÔØ×&Ñ&ˆ	ä!Ÿ|š|¨F×,=Ñ,=¸yÓIˆÔÜ"$§,¢,¨v×/MÑ/MÈyÓ"YˆÔô ŸIšI¤e§l¢l°6×3QÑ3QÓ&R×&YÑ&YÐZaÓ&bÐotÔuˆÖr,   c                ó¬   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  /# )r   Ú	input_idsNr³   Úinputs_embedsr@   )r$   ru   r%   rt   )r'   r(   s   "€r)   r*   r¨   å   sX   ø€ ÷ ñ á×#Ñ# dÕ*ðñ ×&Ñ&¨Õ-ðñ ×(Ñ(¨4Õ/ð	ñ
 
�‰ñr,   c                óh  € Ve   VP                   R,          MVP                   R,          pV P                  P                  P                   ^ ,          pWE8”  d   \        RV RV 24      hVf   V P                  RR V13,          pVf   V P                  V4      pV P                  V4      pW6,           pV# )NzRSequence length must be less than max_position_embeddings (got `sequence length`: z and max_position_embeddings: ºNNNr€   éþÿÿÿ)r�   rl   rš   Ú
ValueErrorr³   r®   )rM   r·   r³   r¸   Ú
seq_lengthÚmax_position_embeddingÚposition_embeddingsrž   s   &&&&    r)   rŸ   ÚSiglip2TextEmbeddings.forwardå   sÁ   € ð -6Ò,A�Y—_‘_ RÖ(À}×GZÑGZÐ[]ÕG^ˆ
Ø!%×!8Ñ!8×!?Ñ!?×!EÑ!EÀaÕ!HÐàÔ.ÜØdØ�,Ð<Ð=SÐ<TðVóð ð
 ÒØ×,Ñ,¨Q°°°¨^Õ<ˆLàÒ Ø ×0Ñ0°Ó;ˆMà"×5Ñ5°lÓCÐØ"Õ8ˆ
àÐr,   )rl   r³   r®   ©NNN©	r.   r/   r0   r1   r`   rŸ   r4   r5   r¢   r£   s   @@r)   r¥   r¥   Ú   s    ù‡ € ÷vó v÷÷ ò r,   r¥   c                óÞ   € V ^8„  d   QhR\         P                  R\        P                  R\        P                  R\        P                  R\        P                  R,          R\        R\        /# )	r   ÚmoduleÚqueryÚkeyÚvalueÚattention_maskNÚscalingÚdropout)rd   ÚModuler$   rt   Úfloat)r'   s   "r)   r*   r*      sg   € ÷ %ñ %Ü�I‰Ið%ä�<‰<ð%ô 
�‰ð%ô �<‰<ð	%ô
 —L‘L 4Õ'ð%ô ð%ô ñ%r,   c                 óÎ  € \         P                  ! WP                  RR4      4      V,          pVe	   W„,           p\        P                  P                  VR\         P                  R7      P                  VP                  4      p\        P                  P                  W†V P                  R7      p\         P                  ! Wƒ4      p	V	P                  ^^4      P                  4       p	W˜3# )rª   )Údimry   )ÚpÚtrainingr€   r»   )r$   Úmatmulr�   rd   Ú
functionalÚsoftmaxr‡   r†   ry   rÊ   rÐ   Ú
contiguous)
rÄ   rÅ   rÆ   rÇ   rÈ   rÉ   rÊ   ÚkwargsÚattn_weightsÚattn_outputs
   &&&&&&&,  r)   Úeager_attention_forwardrØ      s°   € ô —<’< §}¡}°R¸Ó'<Ó=ÀÕG€LØÒ!Ø#Õ4ˆä—=‘=×(Ñ(¨¸2ÄUÇ]Á]Ð(ÓS×VÑVÐW\×WbÑWbÓc€LÜ—=‘=×(Ñ(¨È6Ï?É?Ð(Ó[€Lä—,’,˜|Ó3€KØ×'Ñ'¨¨1Ó-×8Ñ8Ó:€KàÐ$Ð$r,   c                   óL   a a€ ] tR tRt oRtV 3R ltRV3R lR lltRtVtV ;t	# )ÚSiglip2Attentioni  z=Multi-headed attention from 'Attention Is All You Need' paperc                ó<  <€ \         SV `  4        Wn        VP                  V n        VP
                  V n        V P                  V P                  ,          V n        V P                  V P                  ,          V P                  8w  d'   \        R V P                   RV P                   R24      hV P                  R,          V n	        VP                  V n        R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                  V P                  4      V n        R# )z;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).FNç      à¿)r_   r`   rY   ra   rb   Únum_attention_headsÚ	num_headsÚhead_dimr¼   ÚscaleÚattention_dropoutrÊ   Ú	is_causalrd   re   Úk_projÚv_projÚq_projÚout_projrm   s   &&€r)   r`   ÚSiglip2Attention.__init__  s  ø€ Ü‰ÑÔØŒØ×+Ñ+ˆŒØ×3Ñ3ˆŒØŸ™¨$¯.©.Õ8ˆŒØ�=‰=˜4Ÿ>™>Õ)¨T¯^©^Ô;ÜØMÈdÏnÉnÐM]ð ^Ø—N‘NÐ# 2ð'óð ð —]‘] DÕ(ˆŒ
Ø×/Ñ/ˆŒØˆŒä—i’i §¡°·±Ó?ˆŒÜ—i’i §¡°·±Ó?ˆŒÜ—i’i §¡°·±Ó?ˆŒÜŸ	š	 $§.¡.°$·.±.ÓAˆŽr,   c          	      ó®   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[ P                  S[ P                  R,          3,          /# )r   r!   rÈ   Nr@   )r$   rt   r&   )r'   r(   s   "€r)   r*   ÚSiglip2Attention.__annotate__.  sM   ø€ ÷ !)ñ !)á—|‘|ð!)ñ Ÿ™ tÕ+ð!)ñ
 
‰u�|‰|™UŸ\™\¨DÕ0Ð0Õ	1ñ!)r,   c                óº  € VP                   RR p. VORNV P                  N5pV P                  V4      P                  V4      P	                  ^^4      pV P                  V4      P                  V4      P	                  ^^4      pV P                  V4      P                  V4      P	                  ^^4      p\        P                  ! V P                  P                  \        4      p	T	! T TTTTV P                  V P                  V P                  '       g   RMV P                  R7      w  r«V
P                   ! . VORN5!  P#                  4       p
V P%                  V
4      p
W«3# )z#Input shape: Batch x Time x ChannelNç        )râ   rÉ   rÊ   r€   )r�   rß   rå   Úviewr�   rã   rä   r   Úget_interfacerY   Ú_attn_implementationrØ   râ   rà   rÐ   rÊ   rŒ   rÔ   ræ   )rM   r!   rÈ   rÕ   Úinput_shapeÚhidden_shapeÚqueriesÚkeysrK   Úattention_interfacer×   rÖ   s   &&&,        r)   rŸ   ÚSiglip2Attention.forward.  s8  € ð $×)Ñ)¨#¨2Ð.ˆà8˜Ð8 bÐ8¨$¯-©-Ñ8ˆØ—+‘+˜mÓ,×1Ñ1°,Ó?×IÑIÈ!ÈQÓOˆØ�{‰{˜=Ó)×.Ñ.¨|Ó<×FÑFÀqÈ!ÓLˆØ—‘˜]Ó+×0Ñ0°Ó>×HÑHÈÈAÓNˆä(?×(MÒ(MØ�K‰K×,Ñ,Ô.Eó)
Ðñ %8ØØØØØØ—n‘nØ—J‘JØ#Ÿ}Ÿ}˜}‘C°$·,±,ô	%
Ñ!ˆð "×)Ò)Ð;¨;Ð;¸Ó;×FÑFÓHˆØ—m‘m KÓ0ˆàÐ(Ð(r,   )rY   rÊ   rb   rß   râ   rã   rÞ   ræ   rå   rà   rä   rD   ©
r.   r/   r0   r1   r2   r`   rŸ   r4   r5   r¢   r£   s   @@r)   rÚ   rÚ     s   ù‡ € ÙGõB÷(!)÷ !)ò !)r,   rÚ   c                   óD   a a€ ] tR tRt oV 3R ltV3R lR ltRtVtV ;t# )Ú
Siglip2MLPiR  c                ó(  <€ \         SV `  4        Wn        \        VP                  ,          V n        \        P                  ! VP                  VP                  4      V n
        \        P                  ! VP                  VP                  4      V n        R # rD   )r_   r`   rY   r   Ú
hidden_actÚactivation_fnrd   re   ra   Úintermediate_sizeÚfc1Úfc2rm   s   &&€r)   r`   ÚSiglip2MLP.__init__S  sb   ø€ Ü‰ÑÔØŒÜ# F×$5Ñ$5Õ6ˆÔÜ—9’9˜V×/Ñ/°×1IÑ1IÓJˆŒÜ—9’9˜V×5Ñ5°v×7IÑ7IÓJˆŽr,   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   r!   r@   ©r$   rt   )r'   r(   s   "€r)   r*   ÚSiglip2MLP.__annotate__Z  s#   ø€ ÷ ñ ¡U§\¡\ð ±e·l±lñ r,   c                ól   € V P                  V4      pV P                  V4      pV P                  V4      pV# rD   )rü   rú   rý   )rM   r!   s   &&r)   rŸ   ÚSiglip2MLP.forwardZ  s4   € ØŸ™ Ó/ˆØ×*Ñ*¨=Ó9ˆØŸ™ Ó/ˆØÐr,   )rú   rY   rü   rý   rÂ   r£   s   @@r)   r÷   r÷   R  s   ù‡ € õK÷÷ ð r,   r÷   c                   óZ   a a€ ] tR tRt oV3R lV 3R llt]V3R lR l4       tRtVtV ;t	# )ÚSiglip2EncoderLayeria  c                ó0   <€ V ^8„  d   QhRS[ S[,          /# rX   )r   r   )r'   r(   s   "€r)   r*   Ú Siglip2EncoderLayer.__annotate__b  s   ø€ ÷ &ñ &Ñ2Ñ5FÕFñ &r,   c                óJ  <€ \         SV `  4        VP                  V n        \        P
                  ! V P                  VP                  R 7      V n        \        V4      V n	        \        P
                  ! V P                  VP                  R 7      V n
        \        V4      V n        R# ©©ÚepsN)r_   r`   ra   rb   rd   Ú	LayerNormÚlayer_norm_epsÚlayer_norm1rÚ   Ú	self_attnÚlayer_norm2r÷   Úmlprm   s   &&€r)   r`   ÚSiglip2EncoderLayer.__init__b  sm   ø€ Ü‰ÑÔØ×+Ñ+ˆŒÜŸ<š<¨¯©¸F×<QÑ<QÔRˆÔÜ)¨&Ó1ˆŒÜŸ<š<¨¯©¸F×<QÑ<QÔRˆÔÜ˜fÓ%ˆŽr,   c                ó~   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[,          RS[ P                  /# )r   r!   rÈ   rÕ   r@   )r$   rt   r   r   r%   )r'   r(   s   "€r)   r*   r  k  sG   ø€ ÷ ñ á—|‘|ðñ Ÿ™ðñ Ñ+Õ,ð	ñ
 
×	Ñ	ñr,   c                óÄ   € TpV P                  V4      pV P                  ! RR VRV/VB w  rWA,           pTpV P                  V4      pV P                  V4      pWA,           pV# )r!   rÈ   r-   )r  r  r  r  )rM   r!   rÈ   rÕ   ÚresidualÚ_s   &&&,  r)   rŸ   ÚSiglip2EncoderLayer.forwardj  s   € ð !ˆà×(Ñ(¨Ó7ˆØŸ>š>ñ 
Ø'ð
à)ð
ð ñ
Ñˆð
 !Õ0ˆà ˆØ×(Ñ(¨Ó7ˆØŸ™ Ó/ˆØ Õ0ˆàÐr,   )rb   r  r  r  r  )
r.   r/   r0   r1   r`   r   rŸ   r4   r5   r¢   r£   s   @@r)   r  r  a  s(   ù‡ € ÷&ó &ð ÷ó ÷ð r,   r  c                   ó–   a a€ ] tR tRt oRtR
tRt. ROtRtRt	Rt
RtR]R]/t]P                   ! 4       V 3R l4       tV3R ltR	tVtV ;t# )ÚSiglip2PreTrainedModeliƒ  Úsiglip2TFr!   r"   c                ó  <€ \         SV `  V4       \        V\        4      '       Ed   \        V P                  \
        4      '       d!   V P                  P                  P                  MV P                  P                  p\        P                  ! VP                  P                  ^\        P                  ! V4      ,          R7       \        VR4      '       db   \        P                  ! VP                   \"        P$                  ! VP                   P&                  R,          4      P)                  R4      4       R# R# \        V\*        P,                  4      '       d#   \        P.                  ! VP                  4       R# \        V\0        4      '       EdS   \        P2                  ! VP4                  P                  4       \        P2                  ! VP6                  P                  4       \        P2                  ! VP8                  P                  4       \        P2                  ! VP:                  P                  4       \        P<                  ! VP4                  P>                  4       \        P<                  ! VP6                  P>                  4       \        P<                  ! VP8                  P>                  4       \        P<                  ! VP:                  P>                  4       R# \        V\@        4      '       d¯   \        P2                  ! VPB                  P                  4       \        P2                  ! VPD                  P                  4       \        P                  ! VPB                  P>                  RR7       \        P                  ! VPD                  P>                  RR7       R# \        V\F        4      '       dw   \        P2                  ! VPH                  4       \        P2                  ! VPJ                  PL                  4       \        P<                  ! VPJ                  PN                  4       R# \        V\P        4      '       dC   \        P<                  ! VPR                  4       \        P<                  ! VPT                  4       R# \        V\V        4      '       do   \        P                  ! VPX                  P                  V P                  P                  P                  R,          V P                  PZ                  ,          R7       R# \        V\*        P\                  \*        P^                  34      '       dS   \        P`                  ! VP                  4       VP>                  e#   \        P<                  ! VP>                  4       R# R# \        V\b        4      '       db   \        P                  ! VP                   \"        P$                  ! VP                   P&                  R,          4      P)                  R4      4       R# R# )zInitialize the weights)Ústdr³   g�íµ ÷Æ°>Nr€   r¬   rÜ   )2r_   Ú_init_weightsrE   rV   rY   r   Úvision_configra   ÚinitÚnormal_rl   rš   ÚnpÚsqrtÚhasattrÚcopy_r³   r$   r±   r�   r²   rd   rk   Údefault_flax_embed_init_rÚ   Úxavier_uniform_rå   rã   rä   ræ   Úzeros_Úbiasr÷   rü   rý   Ú$Siglip2MultiheadAttentionPoolingHeadÚprobeÚ	attentionÚin_proj_weightÚin_proj_biasÚSiglip2ModelÚlogit_scaleÚ
logit_biasÚSiglip2ForImageClassificationÚ
classifierÚinitializer_factorre   ÚConv2dÚlecun_normal_r¥   )rM   rÄ   r“   rn   s   && €r)   r  Ú$Siglip2PreTrainedModel._init_weights›  s�  ø€ ô 	‰Ñ˜fÔ%Ü�fÔ5×6Ó6ô ˜dŸk™k¬=×9Ò9ð —‘×)Ñ)×5Ò5à—[‘[×,Ñ,ð ô
 �LŠL˜×2Ñ2×9Ñ9¸qÄ2Ç7Â7È5Ã>Õ?QÕRÜ�v˜~×.Ò.Ü—
’
˜6×.Ñ.´·²¸V×=PÑ=P×=VÑ=VÐWYÕ=ZÓ0[×0bÑ0bÐcjÓ0kÖlñ /ä˜¤§¡×-Ò-Ü×)Ò)¨&¯-©-Ö8Ü˜Ô 0×1Ó1Ü× Ò  §¡×!5Ñ!5Ô6Ü× Ò  §¡×!5Ñ!5Ô6Ü× Ò  §¡×!5Ñ!5Ô6Ü× Ò  §¡×!7Ñ!7Ô8Ü�KŠK˜Ÿ™×*Ñ*Ô+Ü�KŠK˜Ÿ™×*Ñ*Ô+Ü�KŠK˜Ÿ™×*Ñ*Ô+Ü�KŠK˜Ÿ™×,Ñ,Ö-Ü˜¤
×+Ò+Ü× Ò  §¡×!2Ñ!2Ô3Ü× Ò  §¡×!2Ñ!2Ô3Ü�LŠL˜Ÿ™Ÿ™¨dÕ3Ü�LŠL˜Ÿ™Ÿ™¨d×3Ü˜Ô D×EÒEÜ× Ò  §¡Ô.Ü× Ò  ×!1Ñ!1×!@Ñ!@ÔAÜ�KŠK˜×(Ñ(×5Ñ5Ö6Ü˜¤×-Ò-Ü�KŠK˜×*Ñ*Ô+Ü�KŠK˜×)Ñ)Ö*Ü˜Ô =×>Ò>Ü�LŠLØ×!Ñ!×(Ñ(Ø—K‘K×-Ñ-×9Ñ9¸4Õ?À$Ç+Á+×B`ÑB`Õ`÷ô ˜¤§¡¬B¯I©IÐ 6×7Ò7Ü×Ò˜vŸ}™}Ô-Ø�{‰{Ò&Ü—’˜FŸK™KÖ(ñ 'ä˜Ô 5×6Ò6Ü�JŠJ�v×*Ñ*¬E¯LªL¸×9LÑ9L×9RÑ9RÐSUÕ9VÓ,W×,^Ñ,^Ð_fÓ,gÖhñ 7r,   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rX   ©r   )r'   r(   s   "€r)   r*   Ú#Siglip2PreTrainedModel.__annotate__ƒ  ó   ø‡ ‚ áÑò r,   r-   )ÚimageÚtext)r¥   rV   r  r)  )r.   r/   r0   r1   Úbase_model_prefixÚinput_modalitiesÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_supports_flash_attnÚ_supports_sdpaÚ_supports_flex_attnÚ_supports_attention_backendr  rÚ   Ú_can_record_outputsr$   Úno_gradr  r3   r4   r5   r¢   r£   s   @@r)   r  r  ƒ  ss   ù‡ € ð "ÐØ(ÐØ&*Ð#òÐð !ÐØ€NàÐØ"&Ðð 	Ð,ØÐ&ðÐð
 ‡]‚]ƒ_ô-ió ð-i÷3 … r,   r  c                   ób   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4       tRtVt	V ;t
# )	ÚSiglip2EncoderiÌ  zŸ
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Siglip2EncoderLayer`].

Args:
    config: Siglip2Config
c                ó    <€ V ^8„  d   QhRS[ /# rX   r8  )r'   r(   s   "€r)   r*   ÚSiglip2Encoder.__annotate__Õ  s   ø€ ÷ ,ñ ,™}ñ ,r,   c                óÖ   <€ \         SV `  4        Wn        \        P                  ! \        VP                  4       Uu. uF  p\        V4      NK  	  up4      V n        R V n	        R# u upi )FN)
r_   r`   rY   rd   Ú
ModuleListrˆ   Únum_hidden_layersr  ÚlayersÚgradient_checkpointing)rM   rY   r  rn   s   && €r)   r`   ÚSiglip2Encoder.__init__Õ  sT   ø€ Ü‰ÑÔØŒÜ—m’mÌ%ÐPV×PhÑPhÔJiÓ$jÑJiÀQÔ%8¸Ö%@ÑJiÑ$jÓkˆŒØ&+ˆÖ#ùò %ks   ½A&c                ó^   <€ V ^8„  d   QhRS[ P                  R,          RS[S[,          RS[/# )r   rÈ   NrÕ   r@   )r$   rt   r   r   r
   )r'   r(   s   "€r)   r*   rJ  Ý  s?   ø€ ÷ @ñ @ñ Ÿ™ tÕ+ð@ñ Ñ+Õ,ð	@ñ
 
ñ@r,   c                óX   € TpV P                    F  pV! VV3/ VB pK  	  \        VR 7      # ))r    )rN  r
   )rM   r¸   rÈ   rÕ   r!   Úencoder_layers   &&&,  r)   rŸ   ÚSiglip2Encoder.forwardÜ  s>   € ð &ˆØ!Ÿ[œ[ˆMÙ)ØØñð ñŠMñ )ô °Ô?Ð?r,   )rY   rO  rN  rD   )r.   r/   r0   r1   r2   r`   r   rŸ   r4   r5   r¢   r£   s   @@r)   rH  rH  Ì  s6   ù‡ € ñ÷,ó ,ð ÷@ñ @ó ÷@ð @r,   rH  zN
    The vision model from Siglip2 without any head or projection on top.
    c                   ó˜   a a€ ] tR tRt oRtRtRtRtV3R lV 3R llt]	]
! RR7      ]V3R	 lR
 l4       4       4       tV3R ltRtVtV ;t# )ÚSiglip2VisionModeliî  r˜   Úvision_modelrg   c                ó    <€ V ^8„  d   QhRS[ /# rX   rZ   )r'   r(   s   "€r)   r*   ÚSiglip2VisionModel.__annotate__ú  s   ø€ ÷ ñ Ñ2ñ r,   c                ó„  <€ \         SV `  V4       Wn        VP                  p\	        V4      V n        \        V4      V n        \        P                  ! W!P                  R 7      V n        \        VR4      '       g   RMVP                  V n        V P                  '       d   \        V4      V n        V P#                  4        R# )r
  Úvision_use_headTN)r_   r`   rY   ra   rV   rž   rH  Úencoderrd   r  r  Úpost_layernormr#  r[  Úuse_headr)  ÚheadÚ	post_initr´   s   && €r)   r`   ÚSiglip2VisionModel.__init__ú  sŠ   ø€ Ü‰Ñ˜Ô ØŒØ×&Ñ&ˆ	ä1°&Ó9ˆŒÜ% fÓ-ˆŒÜ Ÿlšl¨9×:OÑ:OÔPˆÔÜ$+¨FÐ4E×$FÒ$F™ÈF×LbÑLbˆŒØ�=�=ˆ=Ü<¸VÓDˆDŒIØ�‰Ör,   F©Útie_last_hidden_statesc          
      ó„   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[S[,          RS[/# )r   r˜   Úpixel_attention_maskrr   rÕ   r@   )r$   r%   rt   ru   r   r   r   )r'   r(   s   "€r)   r*   rY  
  sS   ø€ ÷ 9
ñ 9
á×'Ñ'ð9
ñ $Ÿl™lð9
ñ ×(Ñ(ð	9
ñ
 Ñ+Õ,ð9
ñ 
$ñ9
r,   c                ó  € V P                  W4      p\        V P                  VVR7      pV P                  ! RRVRV/VB pVP                  pV P                  V4      pV P                  '       d   V P                  W‚4      MRp	\        VV	R7      # )aë  
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
    Mask to avoid performing attention on padding pixel indices.
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
    Tensor containing the spatial dimensions (height, width) of the input images.

Examples:

```python
>>> import httpx
>>> from io import BytesIO
>>> from PIL import Image
>>> from transformers import AutoProcessor, Siglip2VisionModel

>>> model = Siglip2VisionModel.from_pretrained("google/siglip2-base-patch16-224")
>>> processor = AutoProcessor.from_pretrained("google/siglip2-base-patch16-224")

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))

>>> inputs = processor(images=image, return_tensors="pt")

>>> outputs = model(**inputs)
>>> last_hidden_state = outputs.last_hidden_state
>>> pooled_output = outputs.pooler_output  # pooled features
```
©rY   r¸   rÈ   r¸   rÈ   N©r    Úpooler_outputr-   )	rž   r   rY   r\  r    r]  r^  r_  r   )
rM   r˜   re  rr   rÕ   r!   Úencoder_attention_maskÚencoder_outputsr    ri  s
   &&&&,     r)   rŸ   ÚSiglip2VisionModel.forward  s¢   € ðL Ÿ™¨ÓEˆä!:Ø—;‘;Ø'Ø/ô"
Ðð ,0¯<ª<ñ ,
Ø'ð,
à1ð,
ð ñ,
ˆð ,×=Ñ=ÐØ ×/Ñ/Ð0AÓBÐàNRÏmÏmÈm˜Ÿ	™	Ð"3ÔJÐaeˆä)Ø/Ø'ô
ð 	
r,   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rX   rZ   )r'   r(   s   "€r)   r*   rY  î  s   ø‡ ‚ ñ  Ñò r,   )rY   rž   r\  r_  r]  r^  ©r;  )r.   r/   r0   r1   Úmain_input_namer>  r=  Ú_input_embed_layerr`   r   r   r   rŸ   r3   r4   r5   r¢   r£   s   @@r)   rV  rV  î  sX   ù‡ € ð %€OØ!ÐØ&ÐØ*Ð÷ó ð  Ù¨EÔ2Ø÷9
ó ó 3ó  ð9
÷9 … r,   rV  zL
    The text model from Siglip2 without any head or projection on top.
    c                   ó˜   a a€ ] tR tRt oRtRtRtV3R lV 3R llt]]	! RR7      ]
RV3R lR	 ll4       4       4       tV3R
 ltRtVtV ;t# )ÚSiglip2TextModeliF  Ú
text_modelr®   c                ó    <€ V ^8„  d   QhRS[ /# rX   r§   )r'   r(   s   "€r)   r*   ÚSiglip2TextModel.__annotate__Q  s   ø€ ÷ 	ñ 	Ñ0ñ 	r,   c                ó@  <€ \         SV `  V4       Wn        VP                  p\	        V4      V n        \        V4      V n        \        P                  ! W!P                  R 7      V n        \        P                  ! W!P                  4      V n        V P                  4        R# r	  )r_   r`   rY   ra   r¥   rž   rH  r\  rd   r  r  Úfinal_layer_normre   Úprojection_sizer_  r`  r´   s   && €r)   r`   ÚSiglip2TextModel.__init__Q  so   ø€ Ü‰Ñ˜Ô ØŒØ×&Ñ&ˆ	Ü/°Ó7ˆŒÜ% fÓ-ˆŒÜ "§¢¨Y×<QÑ<QÔ RˆÔä—I’I˜i×)?Ñ)?Ó@ˆŒ	Ø�‰Ör,   Frb  c          
      ó®   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r   r·   NrÈ   r³   rÕ   r@   )r$   rt   r   r   r   )r'   r(   s   "€r)   r*   ru  _  s^   ø€ ÷ 6
ñ 6
á—<‘< $Õ&ð6
ñ Ÿ™ tÕ+ð6
ñ —l‘l TÕ)ð	6
ñ
 Ñ+Õ,ð6
ñ 
$ñ6
r,   c                óz  € Vf   \        R4      hVP                  4       pVP                  RVR,          4      pV P                  WR7      p\	        V P
                  VVR7      pV P                  ! RRVRV/VB pVP                  pV P                  V4      pVR	,          p	V P                  V	4      p	\        VV	R7      # )
aX  
Examples:

```python
>>> from transformers import AutoTokenizer, Siglip2TextModel

>>> model = Siglip2TextModel.from_pretrained("google/siglip2-base-patch16-224")
>>> tokenizer = AutoTokenizer.from_pretrained("google/siglip2-base-patch16-224")

>>> # important: make sure to set padding="max_length" as that's how the model was trained
>>> inputs = tokenizer(["a photo of a cat", "a photo of a dog"], padding="max_length", return_tensors="pt")

>>> outputs = model(**inputs)
>>> last_hidden_state = outputs.last_hidden_state
>>> pooled_output = outputs.pooler_output  # pooled (EOS token) states
```zYou have to specify input_ids)r·   r³   rg  r¸   rÈ   rh  r€   r-   )rº   r€   rº   )r¼   r|   rì   rž   r   rY   r\  r    rw  r_  r   )
rM   r·   rÈ   r³   rÕ   rï   r!   rk  r    Úpooled_outputs
   &&&&,     r)   rŸ   ÚSiglip2TextModel.forward\  sÖ   € ð4 ÒÜÐ<Ó=Ð=à—n‘nÓ&ˆØ—N‘N 2 {°2¥Ó7ˆ	àŸ™°)˜ÓWˆô 3Ø—;‘;Ø'Ø)ô
ˆð ,0¯<ª<ñ ,
Ø'ð,
à)ð,
ð ñ,
ˆð ,×=Ñ=ÐØ ×1Ñ1Ð2CÓDÐð *¨(Õ3ˆØŸ	™	 -Ó0ˆä)Ø/Ø'ô
ð 	
r,   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rX   r§   )r'   r(   s   "€r)   r*   ru  F  s   ø‡ ‚ ñ Ñò r,   )rY   rž   r\  rw  r_  )r<  rÁ   )r.   r/   r0   r1   r>  r=  rp  r`   r   r   r   rŸ   r3   r4   r5   r¢   r£   s   @@r)   rr  rr  F  sX   ù‡ € ð !ÐØ$ÐØ*Ð÷	ó 	ð  Ù¨EÔ2Ø÷6
ñ 6
ó ó 3ó  ð6
÷3 … r,   rr  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tVtV ;t	# )	r)  i˜  zMultihead Attention Pooling.c                ó    <€ V ^8„  d   QhRS[ /# rX   rZ   )r'   r(   s   "€r)   r*   Ú1Siglip2MultiheadAttentionPoolingHead.__annotate__›  s   ø€ ÷ 	4ñ 	4Ñ2ñ 	4r,   c                óÀ  <€ \         SV `  4        \        P                  ! \        P
                  ! ^^VP                  4      4      V n        \        P                  P                  VP                  VP                  RR7      V n
        \        P                  ! VP                  VP                  R7      V n        \        V4      V n        Wn        VP                  V n        R# )rª   T)Úbatch_firstr
  N)r_   r`   rd   Ú	Parameterr$   Úrandnra   r*  ÚMultiheadAttentionrÝ   r+  r  r  Ú	layernormr÷   r  rY   rÞ   rm   s   &&€r)   r`   Ú-Siglip2MultiheadAttentionPoolingHead.__init__›  s—   ø€ Ü‰ÑÔä—\’\¤%§+¢+¨a°°F×4FÑ4FÓ"GÓHˆŒ
ÜŸ™×4Ñ4°V×5GÑ5GÈ×IcÑIcÐquÐ4ÓvˆŒÜŸš f×&8Ñ&8¸f×>SÑ>SÔTˆŒÜ˜fÓ%ˆŒàŒØ×3Ñ3ˆŽr,   c                óv   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  /# )r   Úhidden_staterÈ   Nr@   r   )r'   r(   s   "€r)   r*   r�  ¦  s7   ø€ ÷ "ñ "¡E§L¡Lð "Á%Ç,Á,ÐQUÕBUð "Ñaf×amÑamñ "r,   c           
     óþ  € VP                   ^ ,          pV P                  P                  V^^4      pVeþ   VP                   ^,          VP                   ^,          re\        V P                  VVVR7      pVe¼   VP                  ^V P
                  V^4      pVP                  RWV4      pVP                  \        P                  8X  dm   \        P                  ! V\        P                  ! RRVP                  VP                  R7      \        P                  ! VP                  4      P                  4      pV P                  WAWR7      ^ ,          pTpV P!                  V4      pWpP#                  V4      ,           pVR,          # )r   )rY   r¸   rÈ   Úencoder_hidden_statesrë   rw   )Ú	attn_maskr€   r-   )rº   r   )r�   r*  Úrepeatr   rY   rÞ   rŒ   ry   r$   ÚboolÚwhereÚfullrx   ÚfinfoÚminr+  r‡  r  )rM   rŠ  rÈ   rŽ   r*  Ú
target_lenÚ
source_lenr  s   &&&     r)   rŸ   Ú,Siglip2MultiheadAttentionPoolingHead.forward¦  s<  € Ø!×'Ñ'¨Õ*ˆ
Ø—
‘
×!Ñ! *¨a°Ó3ˆàÒ%Ø%*§[¡[°¥^°\×5GÑ5GÈÕ5J˜
Ü6Ø—{‘{Ø#Ø-Ø&2ô	ˆNð Ò)Ø!/×!6Ñ!6°q¸$¿.¹.È*ÐVWÓ!X�Ø!/×!7Ñ!7¸¸JÓ!S�ð "×'Ñ'¬5¯:©:Ô5Ü%*§[¢[Ø&ÜŸ
š
 2 s°>×3HÑ3HÐPU×P[ÑP[Ô\ÜŸš E§K¡KÓ0×4Ñ4ó&�Nð —~‘~ e¸<�~ÓbÐcdÕeˆàˆØ—~‘~ lÓ3ˆØ§(¡(¨<Ó"8Õ8ˆà˜DÕ!Ð!r,   )r+  rY   r‡  r  rÞ   r*  rD   rõ   r£   s   @@r)   r)  r)  ˜  s!   ù‡ € Ù&÷	4ó 	4÷"÷ "ò "r,   r)  c                   óì   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V3R lR lt]]RV3R lR	 ll4       4       t	]]RV3R
 lR ll4       4       t
]]RV3R lR ll4       4       tV3R ltRtVtV ;t# )r.  iÇ  c                ó    <€ V ^8„  d   QhRS[ /# rX   r8  )r'   r(   s   "€r)   r*   ÚSiglip2Model.__annotate__Ë  s   ø€ ÷ ñ ™}ñ r,   c                óš  <€ \         SV `  V4       VP                  pVP                  p\        P                  V4      V n        \        P                  V4      V n        \        P                  ! \        P                  ! ^4      4      V n        \        P                  ! \        P                  ! ^4      4      V n        V P                  4        R# )rª   N)r_   r`   Útext_configr  rr  Ú_from_configrs  rV  rW  rd   r„  r$   r…  r/  r0  r`  )rM   rY   r›  r  rn   s   &&  €r)   r`   ÚSiglip2Model.__init__Ë  sŠ   ø€ Ü‰Ñ˜Ô à×(Ñ(ˆØ×,Ñ,ˆô +×7Ñ7¸ÓDˆŒÜ.×;Ñ;¸MÓJˆÔäŸ<š<¬¯ª°A«Ó7ˆÔÜŸ,š,¤u§{¢{°1£~Ó6ˆŒð 	�‰Ör,   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r?   ©rd   rË   )r'   r(   s   "€r)   r*   r™  Û  s   ø€ ÷ :ñ :¡b§i¡iñ :r,   c                óB   € V P                   P                  P                  # rD   ©rs  rž   r®   rL   s   &r)   Úget_input_embeddingsÚ!Siglip2Model.get_input_embeddingsÛ  s   € Ø�‰×)Ñ)×9Ñ9Ð9r,   c                ó4   <€ V ^8„  d   QhRS[ P                  /# ©r   rÇ   rŸ  )r'   r(   s   "€r)   r*   r™  Þ  s   ø€ ÷ ;ñ ;©"¯)©)ñ ;r,   c                ó:   € WP                   P                  n        R # rD   r¡  ©rM   rÇ   s   &&r)   Úset_input_embeddingsÚ!Siglip2Model.set_input_embeddingsÞ  s   € Ø5:�‰×"Ñ"Ö2r,   c                ó°   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[S[,          /# )r   r·   rÈ   Nr³   rÕ   r@   )r$   rt   r   r   r&   r   )r'   r(   s   "€r)   r*   r™  ã  s_   ø€ ÷ 
ñ 
á—<‘<ð
ñ Ÿ™ tÕ+ð
ñ —l‘l TÕ)ð	
ñ
 Ñ+Õ,ð
ñ 
Ñ+Õ	+ñ
r,   c           	     ó2   € V P                   ! RRVRVRV/VB # )a  
Examples:

```python
>>> from transformers import AutoTokenizer, AutoModel
>>> import torch

>>> model = AutoModel.from_pretrained("google/siglip2-base-patch16-224")
>>> tokenizer = AutoTokenizer.from_pretrained("google/siglip2-base-patch16-224")

>>> # important: make sure to set padding="max_length" as that's how the model was trained
>>> inputs = tokenizer(["a photo of a cat", "a photo of a dog"], padding="max_length", return_tensors="pt")
>>> with torch.no_grad():
...     text_features = model.get_text_features(**inputs)
```r·   rÈ   r³   r-   )rs  )rM   r·   rÈ   r³   rÕ   s   &&&&,r)   Úget_text_featuresÚSiglip2Model.get_text_featuresá  s9   € ð0 �Šñ 
Øð
à)ð
ð &ð
ð ñ	
ð 	
r,   c                ó¾   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[S[,          /# )r   r˜   Nre  rr   rÕ   r@   )r$   r%   rt   ru   r   r   r&   r   )r'   r(   s   "€r)   r*   r™    sh   ø€ ÷ %
ñ %
á×'Ñ'¨$Õ.ð%
ñ $Ÿl™l¨TÕ1ð%
ñ ×(Ñ(¨4Õ/ð	%
ñ
 Ñ+Õ,ð%
ñ 
Ñ+Õ	+ñ%
r,   c           	     ó2   € V P                   ! RRVRVRV/VB # )aY  
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
    Mask to avoid performing attention on padding pixel indices.
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
    Tensor containing the spatial dimensions (height, width) of the input images.

Examples:

```python
>>> import torch
>>> from transformers import AutoProcessor, AutoModel
>>> from transformers.image_utils import load_image

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = load_image(url)

>>> model = AutoModel.from_pretrained("google/siglip2-base-patch16-224")
>>> processor = AutoProcessor.from_pretrained("google/siglip2-base-patch16-224")

>>> inputs = processor(images=image, return_tensors="pt")

>>> with torch.no_grad():
...     image_features = model.get_image_features(**inputs)
```
r˜   re  rr   r-   )rW  )rM   r˜   re  rr   rÕ   s   &&&&,r)   Úget_image_featuresÚSiglip2Model.get_image_features   s<   € ðD × Ò ñ 
Ø%ð
à!5ð
ð *ð
ð ñ	
ð 	
r,   c                ó:  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          R	S[S[,          R
S[/	# )r   r·   Nr˜   re  rr   rÈ   r³   Úreturn_lossrÕ   r@   )r$   ru   r%   rt   r�  r   r   r=   )r'   r(   s   "€r)   r*   r™  ,  s¸   ø€ ÷ ^
ñ ^
á×#Ñ# dÕ*ð^
ñ ×'Ñ'¨$Õ.ð^
ñ $Ÿl™l¨TÕ1ð	^
ñ
 ×(Ñ(¨4Õ/ð^
ñ Ÿ™ tÕ+ð^
ñ ×&Ñ&¨Õ-ð^
ñ ˜D•[ð^
ñ Ñ+Õ,ð^
ñ 
ñ^
r,   c           
     óö  € V P                   ! RRVRVRV/VB p	V P                  ! RRVRVRV/VB p
V	P                  pV
P                  pW»P                  ^RRR7      ,          pWÌP                  ^RRR7      ,          p\        P
                  ! WËP                  4       P                  VP                  4      4      pV P                  P                  VP                  4      V P                  P                  VP                  4      rþWÞP                  4       ,          V,           pVP                  4       pR	pV'       d°   \        P                  ! VP                  ^ 4      VP                  R
7      p\        P                  ! V4      ) ^V,          ,           p\        P                  P                   P#                  VV,          4      p\        P$                  ! VRR7      ) pVP'                  4       p\)        VVVVVV
V	R7      # )a}  
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
    Mask to avoid performing attention on padding pixel indices.
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
    Tensor containing the spatial dimensions (height, width) of the input images.
return_loss (`bool`, *optional*):
    Whether or not to return the contrastive loss.

Examples:

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

>>> model = AutoModel.from_pretrained("google/siglip2-base-patch16-224")
>>> processor = AutoProcessor.from_pretrained("google/siglip2-base-patch16-224")

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))

>>> texts = ["a photo of 2 cats", "a photo of 2 dogs"]
>>> # important: we pass `padding=max_length` since the model was trained with this
>>> inputs = processor(text=texts, images=image, padding="max_length", return_tensors="pt")

>>> with torch.no_grad():
...     outputs = model(**inputs)

>>> logits_per_image = outputs.logits_per_image
>>> probs = torch.sigmoid(logits_per_image) # these are the probabilities
>>> print(f"{probs[0][0]:.1%} that image 0 is '{texts[0]}'")
31.9% that image 0 is 'a photo of 2 cats'
```
r˜   re  rr   r·   rÈ   r³   T)rÏ   rÎ   ÚkeepdimN)rx   ©rÎ   )rP   rQ   rR   r:   r   rS   rT   r-   r€   )rW  rs  ri  Únormr$   rÑ   Útr†   rx   r/  r0  ÚexpÚeyer|   Ú	ones_likerd   rÒ   Ú
logsigmoidÚsumÚmeanr=   )rM   r·   r˜   re  rr   rÈ   r³   r³  rÕ   Úvision_outputsÚtext_outputsr   r:   rR   r/  r0  rQ   rP   rº  Úm1_diag1ÚloglikÚnlls   &&&&&&&&,             r)   rŸ   ÚSiglip2Model.forward*  sÜ  € ðd 6:×5FÒ5Fñ 6
Ø%ð6
à!5ð6
ð *ð6
ð ñ	6
ˆð 48·?²?ñ 4
Øð4
à)ð4
ð &ð4
ð ñ	4
ˆð &×3Ñ3ˆØ"×0Ñ0ˆð $×&7Ñ&7¸!ÀÈTÐ&7Ó&RÕRˆØ!×$4Ñ$4°q¸bÈ$Ð$4Ó$OÕOˆô  Ÿ,š, {·N±NÓ4D×4GÑ4GÈ×HZÑHZÓ4[Ó\ˆà"&×"2Ñ"2×"5Ñ"5°k×6HÑ6HÓ"IÈ4Ï?É?×K]ÑK]Ð^i×^pÑ^pÓKq�ZØ)¯O©OÓ,=Õ=À
ÕJˆà*×,Ñ,Ó.Ðàˆßä—)’)˜O×0Ñ0°Ó3¸O×<RÑ<RÔSˆCÜŸš¨Ó8Ð8¸1¸s½7ÕBˆHÜ—X‘X×(Ñ(×3Ñ3°H¸Õ4NÓOˆFÜ—9’9˜V¨Ô,Ð,ˆCØ—8‘8“:ˆDäØØ-Ø+Ø#Ø%Ø*Ø .ô
ð 	
r,   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rX   r8  )r'   r(   s   "€r)   r*   r™  Ç  r:  r,   )r0  r/  rs  rW  )NNrÁ   )NNNNNNN)r.   r/   r0   r1   r`   r¢  r¨  r   r   r¬  r°  rŸ   r3   r4   r5   r¢   r£   s   @@r)   r.  r.  Ç  s’   ù‡ € ÷ó ÷ :ð :÷;ð ;ð Ø÷
ñ 
ó ó ð
ð: Ø÷%
ñ %
ó ó ð%
ðP Ø÷^
ñ ^
ó ó ð^
÷K … r,   r.  z®
    Siglip2 vision encoder with an image classification head on top (a linear layer on top of the pooled final hidden states of
    the patch tokens) e.g. for ImageNet.
    c                   ó”   a a€ ] tR tRt oRtRtV3R lV 3R lltV3R lR ltV3R lR lt]	]
RV3R	 lR
 ll4       4       tRtVtV ;t# )r1  i�  r˜   c                ó$   <€ V ^8„  d   QhRS[ RR/# )r   rY   r@   Nr8  )r'   r(   s   "€r)   r*   Ú*Siglip2ForImageClassification.__annotate__—  s   ø€ ÷ ñ ™}ð °ñ r,   c                óp  <€ \         SV `  V4       VP                  V n        \        P	                  VP
                  4      V n        VP                  ^ 8”  d6   \        P                  ! VP
                  P                  VP                  4      M\        P                  ! 4       V n        V P                  4        R# )r   N)r_   r`   Ú
num_labelsrV  rœ  r  rW  rd   re   ra   ÚIdentityr2  r`  rm   s   &&€r)   r`   Ú&Siglip2ForImageClassification.__init__—  s‡   ø€ Ü‰Ñ˜Ô à ×+Ñ+ˆŒÜ.×;Ñ;¸F×<PÑ<PÓQˆÔð OU×N_ÑN_ÐbcÔNcŒB�IŠI�f×*Ñ*×6Ñ6¸×8IÑ8IÔJÔik×itÒitÓivð 	Œð
 	�‰Ör,   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r?   rŸ  )r'   r(   s   "€r)   r*   rÈ  ¥  s   ø€ ÷ <ñ <¡b§i¡iñ <r,   c                óB   € V P                   P                  P                  # rD   ©rW  rž   rg   rL   s   &r)   r¢  Ú2Siglip2ForImageClassification.get_input_embeddings¥  s   € Ø× Ñ ×+Ñ+×;Ñ;Ð;r,   c                ó4   <€ V ^8„  d   QhRS[ P                  /# r¥  rŸ  )r'   r(   s   "€r)   r*   rÈ  ¨  s   ø€ ÷ =ñ =©"¯)©)ñ =r,   c                ó:   € WP                   P                  n        R # rD   rÏ  r§  s   &&r)   r¨  Ú2Siglip2ForImageClassification.set_input_embeddings¨  s   € Ø7<×Ñ×$Ñ$Ö4r,   c                óÖ   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r   r˜   Nre  rr   ÚlabelsrÕ   r@   )r$   rt   ru   r   r   r   )r'   r(   s   "€r)   r*   rÈ  ­  s{   ø€ ÷ J
ñ J
á—l‘l TÕ)ðJ
ñ $Ÿl™l¨TÕ1ðJ
ñ ×(Ñ(¨4Õ/ð	J
ñ
 —‘˜tÕ#ðJ
ñ Ñ+Õ,ðJ
ñ 
ñJ
r,   c                óè  € V P                   ! V3RVRV/VB pVP                  pVe_   VR,          P                  VP                  4      p\        P
                  ! Wx,          ^R7      \        P
                  ! V^R7      ,          pM\        P                  ! V^R7      pV P                  V4      p	Rp
Ve   V P                  WIV P                  4      p
\        V
V	VP                  VP                  R7      # )aÙ  
pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
    Mask to avoid performing attention on padding pixel indices.
spatial_shapes (`torch.LongTensor` of shape `(batch_size, 2)`):
    Tensor containing the spatial dimensions (height, width) of the input images.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
    config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
    `config.num_labels > 1` a classification loss is computed (Cross-Entropy).

Examples:

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

>>> torch.manual_seed(3)  # doctest: +IGNORE_RESULT
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))

>>> # note: we are loading a `Siglip2Model` from the hub here,
>>> # so the head will be randomly initialized, hence the predictions will be random if seed is not set above.
>>> image_processor = AutoImageProcessor.from_pretrained("google/siglip2-base-patch16-224")
>>> model = Siglip2ForImageClassification.from_pretrained("google/siglip2-base-patch16-224")

>>> inputs = image_processor(images=image, return_tensors="pt")
>>> outputs = model(**inputs)
>>> logits = outputs.logits
>>> # model predicts one of the two classes
>>> predicted_class_idx = logits.argmax(-1).item()
>>> print("Predicted class:", model.config.id2label[predicted_class_idx])
Predicted class: LABEL_1
```
re  rr   Nr¶  )rP   Úlogitsr!   r"   ).N)rW  r    r†   rx   r$   r½  r¾  r2  Úloss_functionrY   r   r!   r"   )rM   r˜   re  rr   rÕ  rÕ   ÚoutputsÚsequence_outputÚ	pool_maskr×  rP   s   &&&&&,     r)   rŸ   Ú%Siglip2ForImageClassification.forward«  sï   € ð` /3×.?Ò.?Øñ/
à!5ð/
ð *ð/
ð ñ	/
ˆð "×3Ñ3ˆð  Ò+Ø,¨YÕ7×:Ñ:¸?×;QÑ;QÓRˆIÜ#Ÿiši¨Õ(CÈÔKÌeÏiÊiÐXaÐghÔNiÕi‰Oä#Ÿjšj¨¸aÔ@ˆOð —‘ Ó1ˆàˆØÒØ×%Ñ% f°d·k±kÓBˆDä$ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r,   )r2  rÊ  rW  rn  )NNNN)r.   r/   r0   r1   ro  r>  r`   r¢  r¨  r   r   rŸ   r4   r5   r¢   r£   s   @@r)   r1  r1  �  sZ   ù‡ € ð %€OØ!Ð÷ó ÷<ð <÷=ð =ð Ø÷J
ñ J
ó ó ÷J
ð J
r,   r1  )rë   )r.  r  rr  rV  r1  )@Úcollections.abcr   Údataclassesr   Útypingr   Únumpyr!  r$   Útorch.nnrd   Útorch.nn.functionalrÒ   rŠ   Ú r   r  Úactivationsr   Úmasking_utilsr   Úmodeling_layersr	   Úmodeling_outputsr
   r   r   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr   r   r   r   Úutils.genericr   r   Úutils.output_capturingr   Úconfiguration_siglip2r   r   r   r   r8   r=   rË   rV   r¥   rØ   rÚ   r÷   r  r  rH  rV  rr  r)  r.  r1  Ú__all__r-   r,   r)   Ú<module>rï     s  ðõ, %Ý !Ý ã Û Ý ß Ð å &Ý !Ý 6Ý 9ß bÑ bß FÝ &ß \Ó \ß IÝ 5ß XÑ Xñ ðôð
 ô	<˜+ó 	<ó óð	<ñ ðôð
 ô	<˜ó 	<ó óð	<ð Ø
ô_�Kó _ó ó ð_ô@e˜bŸi™iô eôP#˜BŸI™Iô #÷L%ô.8)�r—y‘yô 8)ôv�—‘ô ôÐ4ô ðD ôEi˜_ó Eió ðEiôP@�R—Y‘Yô @ñD ðôô
P
Ð/ó P
óð
P
ñf ðôô
J
Ð-ó J
óð
J
ôZ,"¨2¯9©9ô ,"ð^ ôB
Ð)ó B
ó ðB
ñJ ðôôd
Ð$:ó d
óðd
òN‚r,   