+
    œ°³jZ  ã                   óš  € ^ 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HtHt ^ RIHtHtHtHtHtHtHtHtHtHtHt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 R]4      t*]#! RR7      ] ! R R]4      4       4       t+]#! RR7      ] ! R R]4      4       4       t,]#! RR7      ] ! R R]4      4       4       t- ! R R]4      t. ! R R]4      t/ ! R R]4      t0 ! R R]Pb                  4      t2 ! R R]4      t3 ! R  R!]4      t4 ! R" R#]4      t5 ! R$ R%]4      t6 ! R& R']4      t7 ! R( R)]4      t8. R*Ot9R# )+é    N)Ústrict)Únormalizers)ÚGemmaTokenizer)ÚSiglipConfigÚSiglipTextConfigÚSiglipVisionConfig)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚImageClassifierOutputÚSiglipForImageClassificationÚSiglipModelÚ#SiglipMultiheadAttentionPoolingHeadÚSiglipOutputÚSiglipPreTrainedModelÚSiglipTextModelÚSiglipTextModelOutputÚSiglipVisionModelÚSiglipVisionModelOutput)Úcreate_bidirectional_mask)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚtorch_compilable_check)Úcan_return_tupleÚmerge_with_config_defaults)Úcapture_outputsc                   óF   a a€ ] tR t^2t oRtRV3R lV 3R llltRtVtV ;t# )ÚSiglip2TokenizerzF
Gemma tokenizer + SigLIP2 training default: lowercase normalization.
c                ó¦   <€ V ^8„  d   QhRS[ S[S[ S[3,          ,          R,          RS[ S[S[ ,          ,          R,          RS[ RS[ RS[ RS[ RS[ /# )	é   ÚvocabNÚmergesÚ	unk_tokenÚ	bos_tokenÚ	eos_tokenÚ	pad_tokenÚ
mask_token)ÚstrÚdictÚintÚlist)ÚformatÚ__classdict__s   "€Úl/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/siglip2/modular_siglip2.pyÚ__annotate__ÚSiglip2Tokenizer.__annotate__7   sy   ø€ ÷ eñ eá‘T™#™s˜(•^Õ# dÕ*ðeñ ‘d™3•i• $Õ&ðeñ ð	eñ
 ðeñ ðeñ ðeñ ñeó    c                óÂ  <€ \         S
V `  ! RR VRVRVRVRVRVRV/VB  \        V R4      '       dQ   \        V P                  \
        4      '       d1   V P                  P                  RV P                  P                  4       \        V R	R
4      p	V	eM   V	P                  e=   \        P                  ! \        P                  ! 4       V	P                  .4      V	n
        R
# R
# R
# )r!   r"   r#   r$   r%   r&   r'   Úinit_kwargsÚtokenizer_classÚ
_tokenizerN© )ÚsuperÚ__init__ÚhasattrÚ
isinstancer3   r)   Ú
setdefaultÚ	__class__Ú__name__ÚgetattrÚ
normalizerr   ÚSequenceÚ	Lowercase)Úselfr!   r"   r#   r$   r%   r&   r'   ÚkwargsÚbackendr<   s   &&&&&&&&, €r.   r8   ÚSiglip2Tokenizer.__init__7   sð   ø€ ô 	‰Òñ 		
Øð		
àð		
ð  ð		
ð  ð			
ð
  ð		
ð  ð		
ð "ð		
ð ò		
ô �4˜×'Ò'¬J°t×7GÑ7GÌ×,NÒ,NØ×Ñ×'Ñ'Ð(9¸4¿>¹>×;RÑ;RÔSä˜$ ¨dÓ3ˆØÒ 7×#5Ñ#5Ò#AÜ!,×!5Ò!5´{×7LÒ7LÓ7NÐPW×PbÑPbÐ6cÓ!dˆGÖñ $BÑr1   r6   )NNz<unk>z<bos>z<eos>z<pad>z<mask>)	r=   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r8   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r<   r-   s   @@r.   r   r   2   s   ù‡ € ñ÷e÷ eõ er1   r   z"google/siglip2-base-patch16-naflex)Ú
checkpointc                   ó   € ] tR t^VtRtR# )ÚSiglip2TextConfigr6   N©r=   rF   rG   rH   rJ   r6   r1   r.   rP   rP   V   ó   † ó 	r1   rP   c                   óB   a € ] tR t^\t o RtRt]! 4       tV 3R ltRt	V t
R# )ÚSiglip2VisionConfiga6  
num_patches (`int`, *optional*, defaults to 256):
    The number of patches in the image with the size of (`patch_size`, `patch_size`).
    The image is resized to fill maximum of this number of patches, and to preserve
    the aspect ratio. In case the resulted number of patches is lower, the image is
    padded in "patch" dimension.

Example:

```python
>>> from transformers import Siglip2VisionConfig, Siglip2VisionModel

>>> # Initializing a Siglip2VisionConfig with google/siglip2-base-patch16-naflex style configuration
>>> configuration = Siglip2VisionConfig()

>>> # Initializing a Siglip2VisionModel (with random weights) from the google/siglip2-base-patch16-naflex style configuration
>>> model = Siglip2VisionModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```é   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # )r    Únum_patches)r*   )r,   r-   s   "€r.   r/   Ú Siglip2VisionConfig.__annotate__\   s   ø‡ ‚ ñ2 Ñò3 r1   r6   N)r=   rF   rG   rH   rI   rW   ÚAttributeErrorÚ
image_sizeÚ__annotate_func__rJ   rK   ©r-   s   @r.   rT   rT   \   s    ø‡ € ñð, €KÙÓ!€J÷5 ƒ r1   rT   c                   ó   € ] tR t^ytRtR# )ÚSiglip2Configr6   NrQ   r6   r1   r.   r^   r^   y   rR   r1   r^   c                   ó   € ] tR t^tRtR# )ÚSiglip2VisionOutputr6   NrQ   r6   r1   r.   r`   r`      ó   † Ûr1   r`   c                   ó   € ] tR t^ƒtRtR# )ÚSiglip2TextOutputr6   NrQ   r6   r1   r.   rc   rc   ƒ   ra   r1   rc   c                   ó   € ] tR t^‡tRtR# )ÚSiglip2Outputr6   NrQ   r6   r1   r.   re   re   ‡   ra   r1   re   c                   ól   a a€ ] tR t^‹t 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©rT   )r,   r-   s   "€r.   r/   Ú$Siglip2VisionEmbeddings.__annotate__Œ   s   ø€ ÷ Qñ QÑ2ñ Qr1   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)r7   r8   rj   Úhidden_sizeÚ	embed_dimÚ
patch_sizeÚnnÚLinearÚnum_channelsÚpatch_embeddingrW   r*   Úposition_embedding_sizeÚ	EmbeddingÚposition_embedding©rB   rj   r<   s   &&€r.   r8   Ú Siglip2VisionEmbeddings.__init__Œ   s¥   ø€ Ü‰ÑÔØŒØ×+Ñ+ˆŒØ ×+Ñ+ˆŒä!ŸyšyØ×+Ñ+¨d¯o©oÕ=ÀÇÁÕOØŸ™ô 
ˆÔð
 "×-Ñ-ˆÔÜ'*¨4×+;Ñ+;¸SÕ+@Ó'AˆÔ$Ü"$§,¢,¨t×/?Ñ/?ÀÇÁÓ"PˆÖr1   c                ón   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[ P                  /# )r    Úpositional_embeddingsÚspatial_shapesÚ
max_lengthÚreturn)ÚtorchÚTensorÚ
LongTensorr*   )r,   r-   s   "€r.   r/   rl   œ   s?   ø€ ÷ ;.ñ ;.Ù$Ÿ|™|ð;.á×(Ñ(ð;.ñ ð;.ñ 
�‰ñ	;.r1   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éÿÿÿÿ)Úshaper‡   r�   Úemptyr†   ÚpermuteÚ	unsqueezeÚtypeÚtoÚfloat32ÚrangeÚtolistr   ÚFÚinterpolateÚreshapeÚ	transpose)r}   r~   r   Ú
batch_sizerq   Ú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Ñ.>Ð+>Ó?ñ+ #ð. .Ð-r1   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# )r    Úpixel_valuesr~   r€   )r�   ÚFloatTensorrƒ   r‚   )r,   r-   s   "€r.   r/   rl   Ù   s5   ø€ ÷ ñ ¡E×$5Ñ$5ð Áu×GWÑGWð Ñ\a×\hÑ\hñ r1   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
)r‡   )r   rŽ   )	rv   Úweightr‡   r”   ry   rš   rw   r£   r�   )rB   r¦   r~   Útarget_dtypeÚpatch_embedsr}   Ú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ˆ
ØÐr1   )rj   rq   rW   rv   rr   ry   rw   )r=   rF   rG   rH   r8   Ústaticmethodr£   r®   rJ   rK   rL   rM   s   @@r.   rg   rg   ‹   s5   ù‡ € ÷Qó Qð ÷;.ó ð;.÷z÷ ð r1   rg   c                   ó   € ] tR t^ótRtRtRtR# )ÚSiglip2PreTrainedModelFr6   N)r=   rF   rG   rH   Ú_supports_flex_attnÚ_supports_flash_attnrJ   r6   r1   r.   r²   r²   ó   s   † àÐØ Ôr1   r²   c                   ó|   a a€ ] tR t^ùt oV3R lV 3R llt]]! RR7      ]V3R lR l4       4       4       tRt	Vt
V ;t# )ÚSiglip2VisionModelc                ó    <€ V ^8„  d   QhRS[ /# ri   rk   )r,   r-   s   "€r.   r/   ÚSiglip2VisionModel.__annotate__ú   s   ø€ ÷ !ñ !Ñ2ñ !r1   c                ó&   <€ \         SV `  V4       R # ©N)r7   r8   rz   s   &&€r.   r8   ÚSiglip2VisionModel.__init__ú   s   ø€ Ü‰Ñ˜Ö r1   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_maskr~   rC   r€   )r�   r§   r‚   rƒ   r   r   r
   )r,   r-   s   "€r.   r/   r¸      sS   ø€ ÷ 9
ñ 9
á×'Ñ'ð9
ñ $Ÿl™lð9
ñ ×(Ñ(ð	9
ñ
 Ñ+Õ,ð9
ñ 
$ñ9
r1   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
```
)rj   Úinputs_embedsÚattention_maskrÀ   rÁ   N)Úlast_hidden_stateÚpooler_outputr6   )	r­   r   rj   ÚencoderrÂ   Úpost_layernormÚuse_headÚheadr
   )
rB   r¦   r¾   r~   rC   Úhidden_statesÚencoder_attention_maskÚencoder_outputsrÂ   rÃ   s
   &&&&,     r.   r®   ÚSiglip2VisionModel.forwardý   s¢   € ðL Ÿ™¨ÓEˆä!:Ø—;‘;Ø'Ø/ô"
Ðð ,0¯<ª<ñ ,
Ø'ð,
à1ð,
ð ñ,
ˆð ,×=Ñ=ÐØ ×/Ñ/Ð0AÓBÐàNRÏmÏmÈm˜Ÿ	™	Ð"3ÔJÐaeˆä)Ø/Ø'ô
ð 	
r1   r6   )r=   rF   rG   rH   r8   r   r   r   r®   rJ   rK   rL   rM   s   @@r.   r¶   r¶   ù   s=   ù‡ € ÷!ó !ð  Ù¨EÔ2Ø÷9
ó ó 3ó  ÷9
ð 9
r1   r¶   c                   ó   € ] tR tRtRtR# )ÚSiglip2TextModeli<  r6   NrQ   r6   r1   r.   rÍ   rÍ   <  ra   r1   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# )Ú$Siglip2MultiheadAttentionPoolingHeadi@  c                ó    <€ V ^8„  d   QhRS[ /# ri   rk   )r,   r-   s   "€r.   r/   Ú1Siglip2MultiheadAttentionPoolingHead.__annotate__A  s   ø€ ÷ 4ñ 4Ñ2ñ 4r1   c                óT   <€ \         SV `  V4       Wn        VP                  V n        R # rº   )r7   r8   rj   Únum_attention_headsÚ	num_headsrz   s   &&€r.   r8   Ú-Siglip2MultiheadAttentionPoolingHead.__init__A  s"   ø€ Ü‰Ñ˜Ô àŒØ×3Ñ3ˆŽr1   c                óv   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  /# )r    Úhidden_staterÁ   Nr€   )r�   r‚   )r,   r-   s   "€r.   r/   rÑ   G  s7   ø€ ÷ "ñ "¡E§L¡Lð "Á%Ç,Á,ÐQUÕBUð "Ñaf×amÑamñ "r1   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   )rj   rÀ   rÁ   Úencoder_hidden_statesg        r…   )Ú	attn_maskrŽ   r6   ):NNNr   )r�   ÚprobeÚrepeatr   rj   rÔ   rš   r‡   r�   ÚboolÚwhereÚfullr†   ÚfinfoÚminÚ	attentionÚ	layernormÚmlp)rB   r×   rÁ   rœ   rÛ   Ú
target_lenÚ
source_lenÚresiduals   &&&     r.   r®   Ú,Siglip2MultiheadAttentionPoolingHead.forwardG  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Õ!Ð!r1   )rj   rÔ   rº   )	r=   rF   rG   rH   r8   r®   rJ   rK   rL   rM   s   @@r.   rÏ   rÏ   @  s   ù‡ € ÷4ó 4÷"÷ "ò "r1   rÏ   c                   ót   a € ] tR tRt o ]]RV 3R lR ll4       4       t]]R	V 3R lR ll4       4       tRtV t	R# )
ÚSiglip2Modelih  Nc                ó¾   <€ 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¦   Nr¾   r~   rC   r€   )r�   r§   r‚   rƒ   r   r   Útupler
   )r,   r-   s   "€r.   r/   ÚSiglip2Model.__annotate__l  sh   ø€ ÷ %
ñ %
á×'Ñ'¨$Õ.ð%
ñ $Ÿl™l¨TÕ1ð%
ñ ×(Ñ(¨4Õ/ð	%
ñ
 Ñ+Õ,ð%
ñ 
Ñ+Õ	+ñ%
r1   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¦   r¾   r~   r6   )Úvision_model)rB   r¦   r¾   r~   rC   s   &&&&,r.   Úget_image_featuresÚSiglip2Model.get_image_featuresj  s<   € ðD × Ò ñ 
Ø%ð
à!5ð
ð *ð
ð ñ	
ð 	
r1   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    Ú	input_idsNr¦   r¾   r~   rÁ   Úposition_idsÚreturn_lossrC   r€   )r�   rƒ   r§   r‚   rÝ   r   r   re   )r,   r-   s   "€r.   r/   rí   –  s¸   ø€ ÷ ^
ñ ^
á×#Ñ# dÕ*ð^
ñ ×'Ñ'¨$Õ.ð^
ñ $Ÿl™l¨TÕ1ð	^
ñ
 ×(Ñ(¨4Õ/ð^
ñ Ÿ™ tÕ+ð^
ñ ×&Ñ&¨Õ-ð^
ñ ˜D•[ð^
ñ Ñ+Õ,ð^
ñ 
ñ^
r1   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¦   r¾   r~   ró   rÁ   rô   T)ÚpÚdimÚkeepdimN)r†   ©rø   )ÚlossÚlogits_per_imageÚlogits_per_textÚtext_embedsÚimage_embedsÚtext_model_outputÚvision_model_outputr6   rŽ   )rï   Ú
text_modelrÃ   Únormr�   ÚmatmulÚtr”   r†   Úlogit_scaleÚ
logit_biasÚexpÚeyerŠ   Ú	ones_likers   Ú
functionalÚ
logsigmoidÚsumÚmeanre   )rB   ró   r¦   r¾   r~   rÁ   rô   rõ   rC   Úvision_outputsÚtext_outputsrÿ   rþ   rý   r  r  rü   rû   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äØØ-Ø+Ø#Ø%Ø*Ø .ô
ð 	
r1   r6   )NNN)NNNNNNN)
r=   rF   rG   rH   r   r   rð   r®   rJ   rK   r\   s   @r.   rê   rê   h  sI   ø‡ € àØ÷%
ñ %
ó ó ð%
ðP Ø÷^
ñ ^
ó ó ö^
r1   rê   c                   óJ   a € ] tR tRt o ]]RV 3R lR ll4       4       tRtV tR# )ÚSiglip2ForImageClassificationi÷  Nc                óÖ   <€ 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¦   Nr¾   r~   ÚlabelsrC   r€   )r�   r‚   rƒ   r   r   r   )r,   r-   s   "€r.   r/   Ú*Siglip2ForImageClassification.__annotate__û  s{   ø€ ÷ J
ñ J
á—l‘l TÕ)ðJ
ñ $Ÿl™l¨TÕ1ðJ
ñ ×(Ñ(¨4Õ/ð	J
ñ
 —‘˜tÕ#ðJ
ñ Ñ+Õ,ðJ
ñ 
ñJ
r1   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
```
r¾   r~   Nrú   )rû   ÚlogitsrÈ   Ú
attentions).N)rï   rÂ   r”   r†   r�   r  r  Ú
classifierÚloss_functionrj   r   rÈ   r  )rB   r¦   r¾   r~   r  rC   ÚoutputsÚsequence_outputÚ	pool_maskr  rû   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ä$ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r1   r6   )NNNN)	r=   rF   rG   rH   r   r   r®   rJ   rK   r\   s   @r.   r  r  ÷  s'   ø‡ € àØ÷J
ñ J
ó ó öJ
r1   r  )	r^   rP   rT   rê   r²   rÍ   r¶   r  r   ):r�   Útorch.nnrs   Útorch.nn.functionalr  r˜   Úhuggingface_hub.dataclassesr   Ú
tokenizersr   Ú,transformers.models.gemma.tokenization_gemmar   Ú/transformers.models.siglip.configuration_siglipr   r   r   Ú*transformers.models.siglip.modeling_siglipr	   r
   r   r   r   r   r   r   r   r   r   r   Úmasking_utilsr   Úprocessing_utilsr   Úutilsr   r   r   Úutils.genericr   r   Úutils.output_capturingr   r   rP   rT   r^   r`   rc   re   ÚModulerg   r²   r¶   rÍ   rÏ   rê   r  Ú__all__r6   r1   r.   Ú<module>r1     sv  ðó  Ý ß Ð Ý .Ý "å Gß nÑ n÷÷ ÷ ó õ 7Ý &÷ñ ÷
 JÝ 5ô!e�~ô !eñH Ð?Ô@Øô	Ð(ó 	ó ó Að	ñ Ð?Ô@Øô"Ð,ó "ó ó Að"ñ6 Ð?Ô@Øô	�Ló 	ó ó Að	ô	Ð1ô 	ô	Ð-ô 	ô	�Lô 	ôe˜bŸi™iô eôP!Ð2ô !ô@
Ð*ô @
ôF	�ô 	ô%"Ð+Nô %"ôPL
�;ô L
ô^N
Ð$@ô N
òb
‚r1   