+
    œ°³j9Ò  ã                   óH  € R t ^ RI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 ^R	IHtHtHtHtHtHt ^R
IHt ^RIHtHt ^RIH t  ]PB                  ! ]"4      t#]! RR7      ] ! R R]4      4       4       t$ ! R R]PJ                  4      t& ! R R]PJ                  4      t' ! R R]PJ                  4      t( ! R R]PJ                  4      t) ! R R]PJ                  4      t* ! R R]PJ                  4      t+ ! R R]PJ                  4      t, ! R R ]PJ                  4      t- ! R! R"]4      t. ! R# R$]PJ                  4      t/] ! R% R&]4      4       t0] ! R' R(]04      4       t1 ! R) R*]PJ                  4      t2]! R+R7       ! R, R-]04      4       t3 ! R. R/]PJ                  4      t4 ! R0 R1]PJ                  4      t5]! R2R7       ! R3 R4]04      4       t6]! R5R7       ! R6 R7]04      4       t7]! R8R7       ! R9 R:]04      4       t8] ! R; R<]04      4       t9. R=Ot:R# )>zPyTorch ViLT model.N)Ú	dataclass)Únn)ÚCrossEntropyLoss)Úinitialization)ÚACT2FN)Úcreate_bidirectional_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚMaskedLMOutputÚModelOutputÚSequenceClassifierOutputÚTokenClassifierOutput)ÚPreTrainedModel)Úauto_docstringÚlogging©Ú
ViltConfigzF
    Class for outputs of [`ViltForImagesAndTextClassification`].
    )Ú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# )Ú(ViltForImagesAndTextClassificationOutputa  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Classification (or regression if config.num_labels==1) loss.
logits (`torch.FloatTensor` of shape `(batch_size, config.num_labels)`):
    Classification (or regression if config.num_labels==1) scores (before SoftMax).
hidden_states (`list[tuple(torch.FloatTensor)]`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    List of tuples of `torch.FloatTensor` (one for each image-text pair, each tuple containing the output of
    the embeddings + one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
    Hidden-states of the model at the output of each layer plus the initial embedding outputs.
Nc                ó  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[S[S[ P                  ,          ,          R,          ;R&   S[S[S[ P                  ,          ,          R,          ;R&   # )é   NÚlossÚlogitsÚhidden_statesÚ
attentions)ÚtorchÚFloatTensorÚlistÚtuple)ÚformatÚ__classdict__s   "€Úg/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/vilt/modeling_vilt.pyÚ__annotate__Ú5ViltForImagesAndTextClassificationOutput.__annotate__,   sy   ø‡ ‚ ñ$ ×
Ñ
˜dÕ
"Ñ)ñ% ñ& ×Ñ Õ$Ñ+ñ' ñ( ™™e×/Ñ/Õ0Õ1°DÕ8Ñ?ñ) ñ* ‘U™5×,Ñ,Õ-Õ.°Õ5Ñ<ò+ ó    © )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r"   s   @r#   r   r   ,   s'   ø‡ € ñ	ð &*€DØ'+€FØ;?€MØ8<€J÷+ ƒ r&   r   c                   óJ   a a€ ] tR t^Dt oRtV 3R ltRR ltRR ltRtVt	V ;t
# )ÚViltEmbeddingsz’
Construct the text and patch embeddings.

Text embeddings are equivalent to BERT embeddings.

Patch embeddings are equivalent to ViT embeddings.
c                ó@  <€ \         SV `  4        \        V4      V n        \        P
                  ! \        P                  ! ^^VP                  4      4      V n	        \        V4      V n        V P                  P                  p\        P
                  ! \        P                  ! ^V^,           VP                  4      4      V n        \        P                  ! VP                  VP                  4      V n        \        P"                  ! VP$                  4      V n        Wn        R# ©é   N)ÚsuperÚ__init__ÚTextEmbeddingsÚtext_embeddingsr   Ú	Parameterr   ÚzerosÚhidden_sizeÚ	cls_tokenÚViltPatchEmbeddingsÚpatch_embeddingsÚnum_patchesÚposition_embeddingsÚ	EmbeddingÚmodality_type_vocab_sizeÚtoken_type_embeddingsÚDropoutÚhidden_dropout_probÚdropoutÚconfig)ÚselfrG   r?   Ú	__class__s   && €r#   r6   ÚViltEmbeddings.__init__M   sÂ   ø€ Ü‰ÑÔô  .¨fÓ5ˆÔäŸš¤e§k¢k°!°Q¸×8JÑ8JÓ&KÓLˆŒÜ 3°FÓ ;ˆÔØ×+Ñ+×7Ñ7ˆÜ#%§<¢<´·²¸A¸{ÈQ½ÐPV×PbÑPbÓ0cÓ#dˆÔ ä%'§\¢\°&×2QÑ2QÐSY×SeÑSeÓ%fˆÔ"Ü—z’z &×"<Ñ"<Ó=ˆŒØŽr&   c                ó@  € V P                   P                  P                  P                  w   rEpV P                  V4      pVR,          P	                  4       p\
        P                  P                  W‡P                  ^,          VP                  ^,          3R7      P                  4       pVR,          P                  ^R7      R,          p	VR,          P                  ^R7      R,          p
VP                  w  r¼rÞV P                  P                  V P                  P                  ,          pV P                  R,          P                  ^^4      P                  ^WÏV4      p\         P"                  ! \%        Wš4       UUu. uF[  w  pp\
        P                  P'                  \
        P                  P                  VVV3RRR7      ^ VV,
          ^ VV,
          34      NK]  	  upp^ R7      pVP)                  ^4      P                  ^^4      pVP)                  ^4      P                  ^^4      p\         P*                  ! \         P,                  ! \         P.                  ! VP                  R,          4      \         P.                  ! VP                  R,          4      RR7      RR7      P1                  VP2                  R7      pVR,          pVP5                  VP                  ^ ,          VP                  ^,          RRR4      pVP)                  ^^4      pVP)                  ^4      pV^ 8  g   Ve   \7        V\8        4      '       g   Wš,          pVP;                  4       pM"Wš,          p\=        VP;                  4       V4      pVP?                  R	R
7      p^V,
          P?                  R	R
7      pVR,          PA                  4       pV Uu. uF  pVVR,          V8H  ,          NK  	  ppV Uu. uF  pVVR,          V8H  ,          NK  	  ppV Uu. uF  pVPC                  ^ 4      NK  	  ppV Uu. uF  pVPC                  ^ 4      NK  	  ppV Uu. uF  pVV,
          NK  	  pp. p \E        \%        VVV4      4       Fä  w  p!w  pp"p#V#^ 8:  d[   \         PF                  ! \         PH                  ! V4      P	                  4       V4      p$V PK                  VV!,          V$,          4       Kk  \         PF                  ! \         PH                  ! V"4      P	                  4       V#RR7      p%V PK                  \         P"                  ! VV!,          VV!,          V%,          .^ R7      4       Kæ  	  \         P"                  ! V ^ R7      p VV R,          V R,          3,          P                  VRV4      pVV R,          V R,          3,          P                  VR4      pVV R,          V R,          3,          P                  VR^4      pVV R,          V R,          3,          P                  VRV4      pV PL                  P5                  VRR4      p&\         P"                  ! V&V3^R7      p\         P"                  ! V P                  R,          R,          P5                  VRR4      V3^R7      pVV,           pV PO                  V4      p\         P"                  ! \         PH                  ! VP                  ^ ,          ^4      P1                  V4      V.^R7      pWxVWÞ333# u uppi u upi u upi u upi u upi u upi )ºNNN)Úsize©ÚdimÚbilinearT)rM   ÚmodeÚalign_cornersÚij)Úindexing©ÚdeviceF)Úas_tuple)Úreplacement)rL   NrL   rL   ©rL   é    )rL   ºr4   NNrL   éþÿÿÿéÿÿÿÿ)NNrL   rL   rL   )rL   r4   )rL   rZ   rL   )rL   NrL   )(r>   Ú
projectionÚweightÚshapeÚfloatr   Ú
functionalÚinterpolateÚlongÚsumrG   Ú
image_sizeÚ
patch_sizer@   Ú	transposeÚviewr   ÚcatÚzipÚpadÚflattenÚstackÚmeshgridÚarangeÚtorV   ÚexpandÚ
isinstanceÚintÚmaxÚminÚnonzeroÚuniquerM   Ú	enumerateÚmultinomialÚonesÚappendr<   rF   )'rH   Úpixel_valuesÚ
pixel_maskÚmax_image_lengthÚ_ÚphÚpwÚxÚx_maskÚx_hÚx_wÚ
batch_sizeÚnum_channelsÚheightÚwidthÚ	patch_dimÚspatial_posÚhÚwÚ	pos_embedÚpatch_indexÚeffective_resolutionÚ	valid_idxÚnon_valid_idxÚunique_rowsÚuÚvalid_row_idxÚnon_valid_row_idxÚvÚ
valid_numsÚnon_valid_numsÚpad_numsÚselectÚiÚnvÚpÚvalid_choiceÚ
pad_choiceÚ
cls_tokenss'   &&&&                                   r#   Úvisual_embedÚViltEmbeddings.visual_embed\   sô  € Ø×,Ñ,×7Ñ7×>Ñ>×DÑD‰ˆˆ1�"à×!Ñ! ,Ó/ˆØ˜MÕ*×0Ñ0Ó2ˆÜ—‘×*Ñ*¨6¿¹À½ÀQÇWÁWÈQÅZÐ8PÐ*ÓQ×VÑVÓXˆØ�T�l×Ñ 1ÐÓ% dÕ+ˆØ�T�l×Ñ 1ÐÓ% dÕ+ˆà23·'±'Ñ/ˆ
 &Ø—K‘K×*Ñ*¨d¯k©k×.DÑ.DÕDˆ	Ø×.Ñ.¨xÕ8×BÑBÀ1ÀaÓH×MÑMÈaÐQ]ÐjsÓtˆÜ—I’Iô   œMôñ *‘D�A�qô —‘×!Ñ!Ü—M‘M×-Ñ-Ø#Ø ˜VØ'Ø&*ð	 .ó ð ˜ �	 1 f¨q¥jÐ1öñ *òð ô
ˆ	ð  ×%Ñ% aÓ(×2Ñ2°1°aÓ8ˆ	Ø�I‰I�a‹L×"Ñ" 1 aÓ(ˆä—k’kÜ�NŠNœ5Ÿ<š<¨¯©°RÕ(8Ó9¼5¿<º<ÈÏÉÐUWÕHXÓ;YÐdhÔiÐoqô
ç
‰"�F—M‘Mˆ"Ó
"ð 	ð "Ð"5Õ6ˆØ!×(Ñ(¨¯©°a­¸&¿,¹,Àq½/È2ÈrÐSUÓVˆØ!×)Ñ)¨!¨QÓ/ˆØ—‘ Ó"ˆà˜aÔÐ#3Ò#;Ä:ÐN^Ô`c×CdÒCdð
 $'¥9Ð Ø3×7Ñ7Ó9Ñà#&¥9Ð Ü"Ð#7×#;Ñ#;Ó#=Ð?OÓPÐà—N‘N¨E�NÓ2ˆ	Ø˜V�×,Ñ,°eÐ,Ó<ˆØ •o×,Ñ,Ó.ˆÙBMÓNÁ+¸Q˜ 9¨T¥?°aÑ#7×8Ð8Á+ˆÐNÙNYÓZÉkÈ˜]¨=¸Õ+>À!Ñ+C×DÐDÉkÐÐZá)6Ó7© A�a—f‘f˜Q–i©ˆ
Ð7Ù->Ó?Ñ->¨˜!Ÿ&™& ž)Ñ->ˆÐ?Ù2<Ó=±*¨QÐ$ q×(Ð(±*ˆÐ=àˆÜ&¤s¨:°~ÀxÓ'PÖQ‰MˆA‰z��2�qØ�AŒvÜ$×0Ò0´·²¸A³×1DÑ1DÓ1FÐHXÓY�Ø—‘˜m¨AÕ.¨|Õ<Ö=ä"×.Ò.¬u¯zªz¸"«~×/CÑ/CÓ/EÀqÐVZÔ[�
Ø—‘œeŸiši¨°qÕ)9Ð;LÈQÕ;OÐPZÕ;[Ð(\ÐbcÔdÖeñ Rô —’˜6 qÔ)ˆØˆf�T�l˜F 4�LÐ(Õ)×.Ñ.¨z¸2¸|ÓLˆØ˜˜t� f¨T¥lÐ2Õ3×8Ñ8¸ÀRÓHˆà! &¨¥,°°tµÐ"<Õ=×BÑBÀ:ÈrÐSTÓUˆØ˜f T�l¨F°4­LÐ8Õ9×>Ñ>¸zÈ2È|Ó\ˆ	à—^‘^×*Ñ*¨:°r¸2Ó>ˆ
Ü�IŠI�z 1�o¨1Ô-ˆÜ—I’IØ×%Ñ% gÕ.¨zÕ:×AÑAÀ*ÈbÐRTÓUÐW`ÐaÐghô
ˆ	ð �	�MˆØ�L‰L˜‹Oˆä—’œEŸJšJ v§|¡|°A¥¸Ó:×=Ñ=¸fÓEÀvÐNÐTUÔVˆà˜;¨¨Ð8Ð8Ð8ùóSùòP OùÚZùâ7ùÚ?ùÚ=s%   Å;A!\
Ï \Ï"\Ð\Ð$\Ñ\c	           
     ó6  € V P                  WVR 7      p	Vf,   V P                  WEV P                  P                  R7      w  rzpMVP	                  ^4      p
Vf   ^pW�P                  \        P                  ! V\        P                  V	P                  R7      4      ,           p	WpP                  \        P                  ! W¨\        P                  V	P                  R7      4      ,           p\        P                  ! W—.^R7      p\        P                  ! W*.^R7      pWÍ3# ))Ú	input_idsÚtoken_type_idsÚinputs_embeds)r   ©ÚdtyperV   rN   )r8   r£   rG   r   rm   rC   r   Ú
zeros_likerd   rV   Ú	full_likerj   )rH   r¦   Úattention_maskr§   r}   r~   r¨   Úimage_embedsÚimage_token_type_idxÚtext_embedsÚimage_masksr�   Ú
embeddingsÚmaskss   &&&&&&&&&     r#   ÚforwardÚViltEmbeddings.forward´   s  € ð ×*Ñ*ØÈmð +ó 
ˆð
 ÒØ59×5FÑ5FØ¸4¿;¹;×;WÑ;Wð 6Gó 6Ñ2ˆL¡{ð %×,Ñ,¨QÓ/ˆKð  Ò'Ø#$Ð Ø!×$>Ñ$>Ü×Ò˜^´5·:±:Àk×FXÑFXÔYó%
õ 
ˆð $×&@Ñ&@Ü�OŠO˜KÄUÇZÁZÐXc×XjÑXjÔkó'
õ 
ˆô
 —Y’Y Ð:ÀÔBˆ
Ü—	’	˜>Ð7¸QÔ?ˆàÐ Ð r&   )r<   rG   rF   r>   r@   r8   rC   )éÈ   )r4   )r(   r)   r*   r+   r,   r6   r£   r´   r.   r/   Ú__classcell__©rI   r"   s   @@r#   r1   r1   D   s    ù‡ € ñõôV9÷p'!ô '!r&   r1   c                   ó@   a a€ ] tR t^Þt oRtV 3R ltRR ltRtVtV ;t	# )r7   zGConstruct the embeddings from word, position and token_type embeddings.c                óN  <€ \         SV `  4        \        P                  ! VP                  VP
                  VP                  R 7      V n        \        P                  ! VP                  VP
                  4      V n	        \        P                  ! VP                  VP
                  4      V n        \        P                  ! VP
                  VP                  R7      V n        \        P                  ! VP                  4      V n        \        P"                  ! \$        P&                  ! VP                  4      P)                  R4      RR7      V n        \        P"                  ! \$        P,                  ! V P*                  P/                  4       \$        P0                  R7      RR7      V n        R# ))Úpadding_idx©ÚepsF)Ú
persistent©rª   N©r4   r]   )r5   r6   r   rA   Ú
vocab_sizer;   Úpad_token_idÚword_embeddingsÚmax_position_embeddingsr@   Útype_vocab_sizerC   Ú	LayerNormÚlayer_norm_epsrD   rE   rF   ÚBufferr   rp   rr   Úposition_idsr:   rM   rd   r§   ©rH   rG   rI   s   &&€r#   r6   ÚTextEmbeddings.__init__á   s  ø€ Ü‰ÑÔÜ!Ÿ|š|¨F×,=Ñ,=¸v×?QÑ?QÐ_e×_rÑ_rÔsˆÔÜ#%§<¢<°×0NÑ0NÐPV×PbÑPbÓ#cˆÔ Ü%'§\¢\°&×2HÑ2HÈ&×J\ÑJ\Ó%]ˆÔ"äŸš f×&8Ñ&8¸f×>SÑ>SÔTˆŒÜ—z’z &×"<Ñ"<Ó=ˆŒäŸIšI¤e§l¢l°6×3QÑ3QÓ&R×&YÑ&YÐZaÓ&bÐotÔuˆÔÜ Ÿiši¬¯ª°D×4EÑ4E×4JÑ4JÓ4LÔTY×T^ÑT^Ô(_ÐlqÔrˆÖr&   c                óx  € Ve   VP                  4       pMVP                  4       R R pV^,          pVf   V P                  RR V13,          pVf�   \        V R4      '       d4   V P                  RR V13,          pVP	                  V^ ,          V4      pTpM;\
        P                  ! V\
        P                  V P                  P                  R7      pVf   V P                  V4      pV P                  V4      p	WI,           p
V P                  V4      pW«,          p
V P                  V
4      p
V P                  V
4      p
V
# )NrL   r§   r©   r]   )rM   rÉ   Úhasattrr§   rr   r   r:   rd   rV   rÃ   rC   r@   rÆ   rF   )rH   r¦   r§   rÉ   r¨   Úinput_shapeÚ
seq_lengthÚbuffered_token_type_idsÚ buffered_token_type_ids_expandedrC   r²   r@   s   &&&&&       r#   r´   ÚTextEmbeddings.forwardí   s,  € ØÒ Ø#Ÿ.™.Ó*‰Kà'×,Ñ,Ó.¨s°Ð3ˆKà  •^ˆ
àÒØ×,Ñ,¨Q°°°¨^Õ<ˆLð
 Ò!Ü�tÐ-×.Ò.Ø*.×*=Ñ*=¸aÀÀ*À¸nÕ*MÐ'Ø3J×3QÑ3QÐR]Ð^_ÕR`ÐblÓ3mÐ0Ø!A‘ä!&§¢¨[ÄÇ
Á
ÐSW×SdÑSd×SkÑSkÔ!l�àÒ Ø ×0Ñ0°Ó;ˆMØ $× :Ñ :¸>Ó JÐØ"Õ:ˆ
à"×6Ñ6°|ÓDÐØÕ)ˆ
à—^‘^ JÓ/ˆ
Ø—\‘\ *Ó-ˆ
ØÐr&   )rÆ   rF   r@   rÉ   rC   r§   rÃ   )NNNN©
r(   r)   r*   r+   r,   r6   r´   r.   r/   r·   r¸   s   @@r#   r7   r7   Þ   s   ù‡ € ÙQõ
s÷ ô  r&   r7   c                   ó<   a a€ ] tR tRt oRtV 3R ltR tRtVtV ;t	# )r=   i  z
Image to Patch Embedding.
c                ó  <€ \         SV `  4        VP                  VP                  r2VP                  VP
                  rT\        V\        P                  P                  4      '       d   TMW"3p\        V\        P                  P                  4      '       d   TMW33pV^,          V^,          ,          V^ ,          V^ ,          ,          ,          pW n        W0n        W@n        W`n
        \        P                  ! WEW3R7      V n        R# )r4   )Úkernel_sizeÚstrideN)r5   r6   rf   rg   rˆ   r;   rs   ÚcollectionsÚabcÚIterabler?   r   ÚConv2dr^   )rH   rG   rf   rg   rˆ   r;   r?   rI   s   &&     €r#   r6   ÚViltPatchEmbeddings.__init__  sÃ   ø€ Ü‰ÑÔØ!'×!2Ñ!2°F×4EÑ4E�JØ$*×$7Ñ$7¸×9KÑ9K�kä#-¨j¼+¿/¹/×:RÑ:R×#SÒ#S‘ZÐZdÐYqˆ
Ü#-¨j¼+¿/¹/×:RÑ:R×#SÒ#S‘ZÐZdÐYqˆ
Ø! !•}¨
°1­Õ5¸*ÀQ½-È:ÐVWÍ=Õ:XÕYˆØ$ŒØ$ŒØ(ÔØ&ÔäŸ)š) LÈ:ÔiˆŽr&   c                óÜ   € VP                   w  r#rEW0P                  8w  d   \        R 4      hV P                  P                  P
                  pV P                  VP                  VR7      4      pV# )zeMake sure that the channel dimension of the pixel values match with the one set in the configuration.r¿   )r`   rˆ   Ú
ValueErrorr^   r_   rª   rq   )rH   r}   r‡   rˆ   r‰   rŠ   Útarget_dtyperƒ   s   &&      r#   r´   ÚViltPatchEmbeddings.forward$  sc   € Ø2>×2DÑ2DÑ/ˆ
 &Ø×,Ñ,Ô,ÜØwóð ð —‘×-Ñ-×3Ñ3ˆØ�O‰O˜LŸO™O°,˜OÓ?Ó@ˆØˆr&   )rf   rˆ   r?   rg   r^   rÓ   r¸   s   @@r#   r=   r=     s   ù‡ € ñõj÷ò r&   r=   c                   ó<   a a€ ] tR tRt oV 3R ltRR ltRtVtV ;t# )ÚViltSelfAttentioni/  c                óF  <€ \         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                  VP                  R7      V n        \        P                  ! VP                  V P                  VP                  R7      V n        \        P                  ! VP                  V P                  VP                  R7      V n        \        P                  ! VP                   4      V n        R# )rZ   Úembedding_sizezThe hidden size z4 is not a multiple of the number of attention heads Ú.)ÚbiasN)r5   r6   r;   Únum_attention_headsrÍ   rÞ   rt   Úattention_head_sizeÚall_head_sizer   ÚLinearÚqkv_biasÚqueryÚkeyÚvaluerD   Úattention_probs_dropout_probrF   rÊ   s   &&€r#   r6   ÚViltSelfAttention.__init__0  s1  ø€ Ü‰ÑÔØ×Ñ × :Ñ :Õ:¸aÔ?ÌÐPVÐXh×HiÒHiÜØ" 6×#5Ñ#5Ð"6ð 7Ø×3Ñ3Ð4°Að7óð ð
 $*×#=Ñ#=ˆÔ Ü#& v×'9Ñ'9¸F×<VÑ<VÕ'VÓ#WˆÔ Ø!×5Ñ5¸×8PÑ8PÕPˆÔä—Y’Y˜v×1Ñ1°4×3EÑ3EÈFÏOÉOÔ\ˆŒ
Ü—9’9˜V×/Ñ/°×1CÑ1CÈ&Ï/É/ÔZˆŒÜ—Y’Y˜v×1Ñ1°4×3EÑ3EÈFÏOÉOÔ\ˆŒ
ä—z’z &×"EÑ"EÓFˆŽr&   c                ór  € 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                  ! WgP	                  RR4      4      p	V	\        P                  ! V P                  4      ,          p	Ve	   W’,           p	\        P                  ! RR7      ! V	4      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!  pV'       d   Wº3pV# V3pV# )NrN   r]   r\   )r`   rè   rì   ri   rh   rí   rî   r   ÚmatmulÚmathÚsqrtr   ÚSoftmaxrF   ÚpermuteÚ
contiguousrM   ré   )rH   r   r­   Úoutput_attentionsrÎ   Úhidden_shapeÚquery_layerÚ	key_layerÚvalue_layerÚattention_scoresÚattention_probsÚcontext_layerÚnew_context_layer_shapeÚoutputss   &&&&          r#   r´   ÚViltSelfAttention.forwardB  s‘  € Ø#×)Ñ)¨#¨2Ð.ˆØC˜ÐC bÐC¨$×*BÑ*BÑCˆØ—j‘j Ó/×4Ñ4°\ÓB×LÑLÈQÐPQÓRˆØ—H‘H˜]Ó+×0Ñ0°Ó>×HÑHÈÈAÓNˆ	Ø—j‘j Ó/×4Ñ4°\ÓB×LÑLÈQÐPQÓRˆô !Ÿ<š<¨×5HÑ5HÈÈRÓ5PÓQÐØ+¬d¯iªi¸×8PÑ8PÓ.QÕQÐØÒ%à/Õ@Ðô Ÿ*š*¨Õ,Ð-=Ó>ˆð Ÿ,™, Ó7ˆäŸš _ÓBˆà%×-Ñ-¨a°°A°qÓ9×DÑDÓFˆØ"/×"4Ñ"4Ó"6°s¸Ð";¸t×?QÑ?QÐ>SÕ"SÐØ%×*Ò*Ð,CÑDˆç6G�=Ð2ˆàˆð O\ÐM]ˆàˆr&   )ré   rè   rF   rí   rç   rì   rî   ©NF©	r(   r)   r*   r+   r6   r´   r.   r/   r·   r¸   s   @@r#   râ   râ   /  s   ù‡ € õG÷$ô r&   râ   c                   óT   a a€ ] tR tRt oRtV3R lV 3R lltV3R lR ltRtVtV ;t	# )ÚViltSelfOutputic  z•
The residual connection is defined in ViltLayer instead of here (as is the case with other models), due to the
layernorm applied before each block.
c                ó    <€ V ^8„  d   QhRS[ /# ©r   rG   r   )r!   r"   s   "€r#   r$   ÚViltSelfOutput.__annotate__i  ó   ø€ ÷ >ñ >™zñ >r&   c                óÎ   <€ \         SV `  4        \        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  4      V n        R # ©N)	r5   r6   r   rê   r;   ÚdenserD   rE   rF   rÊ   s   &&€r#   r6   ÚViltSelfOutput.__init__i  sB   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
Ü—z’z &×"<Ñ"<Ó=ˆŽr&   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# ©r   r   Úinput_tensorÚreturn©r   ÚTensor)r!   r"   s   "€r#   r$   r	  n  s1   ø€ ÷ ñ ¡U§\¡\ð ÁÇÁð ÑRW×R^ÑR^ñ r&   c                óJ   € V P                  V4      pV P                  V4      pV# r  ©r  rF   ©rH   r   r  s   &&&r#   r´   ÚViltSelfOutput.forwardn  s$   € ØŸ
™
 =Ó1ˆØŸ™ ]Ó3ˆØÐr&   r  rÓ   r¸   s   @@r#   r  r  c  s#   ù‡ € ñ÷
>ó >÷
÷ ð r&   r  c                   ó<   a a€ ] tR tRt oV 3R ltRR ltRtVtV ;t# )ÚViltAttentionit  c                ód   <€ \         SV `  4        \        V4      V n        \	        V4      V n        R # r  )r5   r6   râ   Ú	attentionr  ÚoutputrÊ   s   &&€r#   r6   ÚViltAttention.__init__u  s&   ø€ Ü‰ÑÔÜ*¨6Ó2ˆŒÜ$ VÓ,ˆŽr&   c                ó~   € V P                  WV4      pV P                  V^ ,          V4      pV3VR,          ,           pV# )rZ   r[   ©r  r  )rH   r   r­   rø   Úself_outputsÚattention_outputr  s   &&&&   r#   r´   ÚViltAttention.forwardz  s?   € Ø—~‘~ mÐEVÓWˆàŸ;™; |°A¥¸ÓFÐà#Ð%¨°RÕ(8Õ8ˆØˆr&   r   r  r  r¸   s   @@r#   r  r  t  s   ù‡ € õ-÷
ô 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# )ÚViltIntermediatei„  c                ó    <€ V ^8„  d   QhRS[ /# r  r   )r!   r"   s   "€r#   r$   ÚViltIntermediate.__annotate__…  s   ø€ ÷ 9ñ 9™zñ 9r&   c                ó"  <€ \         SV `  4        \        P                  ! VP                  VP
                  4      V n        \        VP                  \        4      '       d   \        VP                  ,          V n        R # VP                  V n        R # r  )r5   r6   r   rê   r;   Úintermediate_sizer  rs   Ú
hidden_actÚstrr   Úintermediate_act_fnrÊ   s   &&€r#   r6   ÚViltIntermediate.__init__…  s`   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3KÑ3KÓLˆŒ
Ü�f×'Ñ'¬×-Ò-Ü'-¨f×.?Ñ.?Õ'@ˆDÖ$à'-×'8Ñ'8ˆDÖ$r&   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r   r   r  r  )r!   r"   s   "€r#   r$   r'  �  s#   ø€ ÷ ñ ¡U§\¡\ð ±e·l±lñ r&   c                óJ   € V P                  V4      pV P                  V4      pV# r  ©r  r,  ©rH   r   s   &&r#   r´   ÚViltIntermediate.forward�  s&   € ØŸ
™
 =Ó1ˆØ×0Ñ0°Ó?ˆØÐr&   r0  r  r¸   s   @@r#   r%  r%  „  s   ù‡ € ÷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# )Ú
ViltOutputi”  c                ó    <€ V ^8„  d   QhRS[ /# r  r   )r!   r"   s   "€r#   r$   ÚViltOutput.__annotate__•  r
  r&   c                óÎ   <€ \         SV `  4        \        P                  ! VP                  VP
                  4      V n        \        P                  ! VP                  4      V n	        R # r  )
r5   r6   r   rê   r)  r;   r  rD   rE   rF   rÊ   s   &&€r#   r6   ÚViltOutput.__init__•  sB   ø€ Ü‰ÑÔÜ—Y’Y˜v×7Ñ7¸×9KÑ9KÓLˆŒ
Ü—z’z &×"<Ñ"<Ó=ˆŽr&   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# r  r  )r!   r"   s   "€r#   r$   r6  š  s1   ø€ ÷ ñ ¡U§\¡\ð ÁÇÁð ÑRW×R^ÑR^ñ r&   c                óZ   € V P                  V4      pV P                  V4      pW,           pV# r  r  r  s   &&&r#   r´   ÚViltOutput.forwardš  s,   € ØŸ
™
 =Ó1ˆØŸ™ ]Ó3ˆØ%Õ4ˆØÐr&   r  r  r¸   s   @@r#   r4  r4  ”  s   ù‡ € ÷>ó >÷
÷ ð r&   r4  c                   ó@   a a€ ] tR tRt oRtV 3R ltRR ltRtVtV ;t	# )Ú	ViltLayeri¡  z?This corresponds to the Block class in the timm implementation.c                óx  <€ \         SV `  4        VP                  V n        ^V n        \	        V4      V n        \        V4      V n        \        V4      V n	        \        P                  ! VP                  VP                  R7      V n        \        P                  ! VP                  VP                  R7      V n        R# )r4   r¼   N)r5   r6   Úchunk_size_feed_forwardÚseq_len_dimr  r  r%  Úintermediater4  r  r   rÆ   r;   rÇ   Úlayernorm_beforeÚlayernorm_afterrÊ   s   &&€r#   r6   ÚViltLayer.__init__¤  s‡   ø€ Ü‰ÑÔØ'-×'EÑ'EˆÔ$ØˆÔÜ& vÓ.ˆŒÜ,¨VÓ4ˆÔÜ  Ó(ˆŒÜ "§¢¨V×-?Ñ-?ÀV×EZÑEZÔ [ˆÔÜ!Ÿ|š|¨F×,>Ñ,>ÀF×DYÑDYÔZˆÖr&   c                ó,  € V P                  V P                  V4      VVR 7      pV^ ,          pVR,          pWQP                  VP                  4      ,           pV P	                  V4      pV P                  V4      pV P                  Wq4      pV3V,           pV# ))rø   r[   )r  rB  rq   rV   rC  rA  r  )rH   r   r­   rø   Úself_attention_outputsr"  r  Úlayer_outputs   &&&&    r#   r´   ÚViltLayer.forward®  s    € Ø!%§¡Ø×!Ñ! -Ó0ØØ/ð "0ó "
Ðð
 2°!Õ4ÐØ(¨Õ,ˆð )×+;Ñ+;Ð<L×<SÑ<SÓ+TÕTˆð ×+Ñ+¨MÓ:ˆØ×(Ñ(¨Ó6ˆð —{‘{ <Ó?ˆà�/ GÕ+ˆàˆr&   )r  r?  rA  rC  rB  r  r@  r  rÓ   r¸   s   @@r#   r=  r=  ¡  s   ù‡ € ÙIõ[÷ô r&   r=  c                   ó<   a a€ ] tR tRt oV 3R ltRR ltRtVtV ;t# )ÚViltEncoderiÆ  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)
r5   r6   rG   r   Ú
ModuleListÚrangeÚnum_hidden_layersr=  ÚlayerÚgradient_checkpointing)rH   rG   r€   rI   s   && €r#   r6   ÚViltEncoder.__init__Ç  sR   ø€ Ü‰ÑÔØŒÜ—]’]¼uÀV×E]ÑE]Ô?^Ó#_Ñ?^¸!¤I¨fÖ$5Ñ?^Ñ#_Ó`ˆŒ
Ø&+ˆÖ#ùò $`s   ½A&c                ó–  € V'       d   RMR pV'       d   RMR p\        V P                  4       FB  w  r‰V'       d
   Wa3,           pV	! WV4      p
V
^ ,          pV'       g   K2  Wz^,          3,           pKD  	  V'       d
   Wa3,           pV'       g1   \        ;QJ d    . R WV3 4       F  NK  	  5# ! R WV3 4       4      # \        VVVR7      # )Nc              3   ó0   "  € T F  qf   K  Vx € K  	  R # 5ir  r'   )Ú.0r˜   s   & r#   Ú	<genexpr>Ú&ViltEncoder.forward.<locals>.<genexpr>ç  s   é € ÐmÑ$[˜qŸšÓ$[ùs   ‚Œ
)Úlast_hidden_stater   r   r'   )ry   rO  r    r	   )rH   r   r­   rø   Úoutput_hidden_statesÚreturn_dictÚall_hidden_statesÚall_self_attentionsr�   Úlayer_moduleÚlayer_outputss   &&&&&&     r#   r´   ÚViltEncoder.forwardÍ  sÂ   € ÷ #7™B¸DÐß$5™b¸4Ðä(¨¯©Ö4‰OˆAß#Ø$5Ð8HÕ$HÐ!á(¨ÐHYÓZˆMà)¨!Õ,ˆMç Ñ Ø&9È1Õ=MÐ<OÕ&OÒ#ñ  5÷  Ø 1Ð4DÕ DÐçß”5Ñm ]ÐGZÑ$[Óm—5Ðm�5Ñm ]ÐGZÑ$[ÓmÓmÐmÜØ+Ø+Ø*ô
ð 	
r&   )rG   rP  rO  )NFFTr  r¸   s   @@r#   rJ  rJ  Æ  s   ù‡ € õ,÷
ô 
r&   rJ  c                   óR   a a€ ] tR tRt oRtR	tRtRR.tV 3R ltV3R lt	Rt
VtV ;t# )
ÚViltPreTrainedModeliï  ÚviltTr1   râ   c                óT  <€ \         SV `  V4       \        V\        4      '       d‚   \        P
                  ! VP                  \        P                  ! VP                  P                  R,          4      P                  R4      4       \        P                  ! VP                  4       R# R# )r4   Nr]   rÀ   )r5   Ú_init_weightsrs   r7   ÚinitÚcopy_rÉ   r   rp   r`   rr   Úzeros_r§   )rH   ÚmodulerI   s   &&€r#   rc  Ú!ViltPreTrainedModel._init_weights÷  so   ø€ Ü‰Ñ˜fÔ%Ü�fœn×-Ò-Ü�JŠJ�v×*Ñ*¬E¯LªL¸×9LÑ9L×9RÑ9RÐSUÕ9VÓ,W×,^Ñ,^Ð_fÓ,gÔhÜ�KŠK˜×-Ñ-Ö.ñ .r&   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # r  r   )r!   r"   s   "€r#   r$   Ú ViltPreTrainedModel.__annotate__ï  s   ø‡ ‚ áÑò r&   r'   )ÚimageÚtext)r(   r)   r*   r+   Úbase_model_prefixÚinput_modalitiesÚsupports_gradient_checkpointingÚ_no_split_modulesrc  r-   r.   r/   r·   r¸   s   @@r#   r`  r`  ï  s1   ù‡ € ð ÐØ(ÐØ&*Ð#Ø)Ð+>Ð?Ðõ/÷ … r&   r`  c                   ób   a a€ ] tR tRt oRV 3R lltR tR t]R	V3R lR ll4       tRt	Vt
V ;t# )
Ú	ViltModeliþ  c                ó(  <€ \         SV `  V4       Wn        \        V4      V n        \        V4      V n        \        P                  ! VP                  VP                  R7      V n        V'       d   \        V4      MRV n        V P                  4        R# )z^
add_pooling_layer (bool, *optional*, defaults to `True`):
    Whether to add a pooling layer
r¼   N)r5   r6   rG   r1   r²   rJ  Úencoderr   rÆ   r;   rÇ   Ú	layernormÚ
ViltPoolerÚpoolerÚ	post_init)rH   rG   Úadd_pooling_layerrI   s   &&&€r#   r6   ÚViltModel.__init__   si   ø€ ô
 	‰Ñ˜Ô ØŒä(¨Ó0ˆŒÜ" 6Ó*ˆŒäŸš f×&8Ñ&8¸f×>SÑ>SÔTˆŒß,=”j Ô(À4ˆŒð 	�‰Ör&   c                óB   € V P                   P                  P                  # r  ©r²   r8   rÃ   ©rH   s   &r#   Úget_input_embeddingsÚViltModel.get_input_embeddings  s   € Ø�‰×.Ñ.×>Ñ>Ð>r&   c                ó:   € WP                   P                  n        R # r  r|  )rH   rî   s   &&r#   Úset_input_embeddingsÚViltModel.set_input_embeddings  s   € Ø:?�‰×'Ñ'Ö7r&   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[ P                  R,          R	S[R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# )r   r¦   Nr­   r§   r}   r~   r¨   r®   r¯   rø   rX  rY  r  )r   Ú
LongTensorr   rt   Úboolr
   r    )r!   r"   s   "€r#   r$   ÚViltModel.__annotate__  sþ   ø€ ÷ p
ñ p
á×#Ñ# dÕ*ðp
ñ ×)Ñ)¨DÕ0ðp
ñ ×(Ñ(¨4Õ/ð	p
ñ
 ×'Ñ'¨$Õ.ðp
ñ ×$Ñ$ tÕ+ðp
ñ ×(Ñ(¨4Õ/ðp
ñ ×'Ñ'¨$Õ.ðp
ñ " D�jðp
ñ   $�;ðp
ñ # T�kðp
ñ ˜D•[ðp
ñ 
$¡e©E×,=Ñ,=Õ&>Õ	>ñp
r&   c                ó²  € 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e   Ve   \	        R4      hVe#   V P                  W4       VP                  4       pM#Ve   VP                  4       RR pM\	        R4      hVw  rïVe   VP                  MVP                  pVf   \        P                  ! Wï3VR7      pVe   Ve   \	        R4      hVf   Vf   \	        R4      hVe   VP                  ^ ,          MVP                  ^ ,          pVV8w  d   \	        R4      hVfD   \        P                  ! VV P                   P                  V P                   P                  3VR7      pV P                  VVVVVVVVR7      w  pp\        V P                   VVR	7      pV P                  VVV	V
VR
7      pV^ ,          pV P                  V4      pV P                   e   V P!                  V4      MRpV'       g   VV3VR,          ,           # \#        VVVP$                  VP&                  R7      # )a  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
image_token_type_idx (`int`, *optional*):
    - The token type ids for images.

Examples:

```python
>>> from transformers import ViltProcessor, ViltModel
>>> from PIL import Image
>>> import httpx
>>> from io import BytesIO

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

>>> processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-mlm")
>>> model = ViltModel.from_pretrained("dandelin/vilt-b32-mlm")

>>> inputs = processor(image, text, return_tensors="pt")
>>> outputs = model(**inputs)
>>> last_hidden_states = outputs.last_hidden_state
```NzDYou cannot specify both input_ids and inputs_embeds at the same timez5You have to specify either input_ids or inputs_embedsrU   zFYou cannot specify both pixel_values and image_embeds at the same timez7You have to specify either pixel_values or image_embedszAThe text inputs and image inputs need to have the same batch size)r¯   )rG   r¨   r­   )r­   rø   rX  rY  r[   )rW  Úpooler_outputr   r   r]   )rG   rø   rX  rY  rÞ   Ú%warn_if_padding_and_no_attention_maskrM   rV   r   r{   r`   rf   r²   r   rt  ru  rw  r
   r   r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r¯   rø   rX  rY  ÚkwargsrÎ   Útext_batch_sizerÏ   rV   Úimage_batch_sizeÚembedding_outputÚencoder_outputsÚsequence_outputÚpooled_outputs   &&&&&&&&&&&&,         r#   r´   ÚViltModel.forward  sd  € ðX 2CÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒ  ]Ò%>ÜÐcÓdÐdØÒ"Ø×6Ñ6°yÔQØ#Ÿ.™.Ó*‰KØÒ&Ø'×,Ñ,Ó.¨s°Ð3‰KäÐTÓUÐUà&1Ñ#ˆØ%.Ò%:�×!Ò!À×@TÑ@TˆàÒ!Ü"ŸZšZ¨/Ð)FÐPVÔWˆNàÒ#¨Ò(@ÜÐeÓfÐfØÒ! lÒ&:ÜÐVÓWÐWà4@Ò4L˜<×-Ñ-¨aÖ0ÐR^×RdÑRdÐefÕRgÐØ˜Ô.ÜÐ`ÓaÐaØÒÜŸšÐ%5°t·{±{×7MÑ7MÈtÏ{É{×OeÑOeÐ$fÐouÔvˆJà+/¯?©?ØØØØØØØØ!5ð ,;ó 	,
Ñ(Ð˜.ô 3Ø—;‘;Ø*Ø)ô
ˆð Ÿ,™,ØØ)Ø/Ø!5Ø#ð 'ó 
ˆð *¨!Õ,ˆØŸ.™.¨Ó9ˆØ8<¿¹Ò8O˜Ÿ™ OÔ4ÐUYˆçØ# ]Ð3°oÀbÕ6IÕIÐIä)Ø-Ø'Ø)×7Ñ7Ø&×1Ñ1ô	
ð 	
r&   )rG   r²   rt  ru  rw  )T©NNNNNNNNNNN)r(   r)   r*   r+   r6   r~  r�  r   r´   r.   r/   r·   r¸   s   @@r#   rr  rr  þ  s7   ù‡ € ÷ò"?ò@ð ÷p
ñ p
ó ÷p
ð p
r&   rr  c                   ó8   a a€ ] tR tRt oV 3R ltR tRtVtV ;t# )rv  i‹  c                ó¸   <€ \         SV `  4        \        P                  ! VP                  VP                  4      V n        \        P                  ! 4       V n        R # r  )r5   r6   r   rê   r;   r  ÚTanhÚ
activationrÊ   s   &&€r#   r6   ÚViltPooler.__init__Œ  s9   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
ÜŸ'š'›)ˆŽr&   c                ó\   € VR,          pV P                  V4      pV P                  V4      pV# )rL   rY   )r  r–  )rH   r   Úfirst_token_tensorr�  s   &&  r#   r´   ÚViltPooler.forward‘  s2   € ð +¨4Õ0ÐØŸ
™
Ð#5Ó6ˆØŸ™¨Ó6ˆØÐr&   )r–  r  r  r¸   s   @@r#   rv  rv  ‹  s   ù‡ € õ$÷
ò r&   rv  zU
    ViLT Model with a language modeling head on top as done during pretraining.
    c                   óf   a a€ ] tR tRt oRR/tV 3R ltR tR t]R
V3R lR ll4       t	R	t
VtV ;t# )ÚViltForMaskedLMiš  zmlm_score.decoder.weightz6vilt.embeddings.text_embeddings.word_embeddings.weightc                ó†   <€ \         SV `  V4       \        V4      V n        \	        V4      V n        V P                  4        R # r  )r5   r6   rr  ra  ÚViltMLMHeadÚ	mlm_scorerx  rÊ   s   &&€r#   r6   ÚViltForMaskedLM.__init__¤  s4   ø€ Ü‰Ñ˜Ô ä˜fÓ%ˆŒ	Ü$ VÓ,ˆŒð 	�‰Ör&   c                ó.   € V P                   P                  # r  )rŸ  Údecoderr}  s   &r#   Úget_output_embeddingsÚ%ViltForMaskedLM.get_output_embeddings­  s   € Ø�~‰~×%Ñ%Ð%r&   c                ó\   € WP                   n        VP                  V P                   n        R # r  )rŸ  r¢  ræ   )rH   Únew_embeddingss   &&r#   Úset_output_embeddingsÚ%ViltForMaskedLM.set_output_embeddings°  s   € Ø!/�‰ÔØ,×1Ñ1ˆ�‰Ö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[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# ©r   r¦   Nr­   r§   r}   r~   r¨   r®   Úlabelsrø   rX  rY  r  )r   r„  r   r…  r   r    )r!   r"   s   "€r#   r$   ÚViltForMaskedLM.__annotate__µ  s  ø€ ÷ p
ñ p
á×#Ñ# dÕ*ðp
ñ ×)Ñ)¨DÕ0ðp
ñ ×(Ñ(¨4Õ/ð	p
ñ
 ×'Ñ'¨$Õ.ðp
ñ ×$Ñ$ tÕ+ðp
ñ ×(Ñ(¨4Õ/ðp
ñ ×'Ñ'¨$Õ.ðp
ñ × Ñ  4Õ'ðp
ñ   $�;ðp
ñ # T�kðp
ñ ˜D•[ðp
ñ 
™%¡× 1Ñ 1Õ2Õ	2ñp
r&   c                ó–  € Ve   TMV P                   P                  pV P                  VVVVVVVV	V
VR7
      pVR,          w  rïVe   VP                  ^,          MVP                  ^,          pVRRV13,          VRVR13,          ppV P	                  V4      pRpVeb   \        4       pVP                  VP                  4      pV! VP                  RV P                   P                  4      VP                  R4      4      pV'       g"   V3VR,          ,           pVe   V3V,           # T# \        VVVP                  VP                  R7      # )aø	  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
labels (*torch.LongTensor* of shape *(batch_size, sequence_length)*, *optional*):
    Labels for computing the masked language modeling loss. Indices should be in *[-100, 0, ...,
    config.vocab_size]* (see *input_ids* docstring) Tokens with indices set to *-100* are ignored (masked), the
    loss is only computed for the tokens with labels in *[0, ..., config.vocab_size]*

Examples:

```python
>>> from transformers import ViltProcessor, ViltForMaskedLM
>>> import httpx
>>> from io import BytesIO
>>> from PIL import Image
>>> import re
>>> import torch

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))
>>> text = "a bunch of [MASK] laying on a [MASK]."

>>> processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-mlm")
>>> model = ViltForMaskedLM.from_pretrained("dandelin/vilt-b32-mlm")

>>> # prepare inputs
>>> encoding = processor(image, text, return_tensors="pt")

>>> # forward pass
>>> outputs = model(**encoding)

>>> tl = len(re.findall("\[MASK\]", text))
>>> inferred_token = [text]

>>> # gradually fill in the MASK tokens, one by one
>>> with torch.no_grad():
...     for i in range(tl):
...         encoded = processor.tokenizer(inferred_token)
...         input_ids = torch.tensor(encoded.input_ids)
...         encoded = encoded["input_ids"][0][1:-1]
...         outputs = model(input_ids=input_ids, pixel_values=encoding.pixel_values)
...         mlm_logits = outputs.logits[0]  # shape (seq_len, vocab_size)
...         # only take into account text features (minus CLS and SEP token)
...         mlm_logits = mlm_logits[1 : input_ids.shape[1] - 1, :]
...         mlm_values, mlm_ids = mlm_logits.softmax(dim=-1).max(dim=-1)
...         # only take into account text
...         mlm_values[torch.tensor(encoded) != 103] = 0
...         select = mlm_values.argmax().item()
...         encoded[select] = mlm_ids[select].item()
...         inferred_token = [processor.decode(encoded)]

>>> selected_token = ""
>>> encoded = processor.tokenizer(inferred_token)
>>> output = processor.decode(encoded.input_ids[0], skip_special_tokens=True)
>>> print(output)
a bunch of cats laying on a couch.
```N©	r­   r§   r}   r~   r¨   r®   rø   rX  rY  :Nr   NrL   ºr   NN©r   r   r   r   r]   )rG   rY  ra  r`   rŸ  r   rq   rV   ri   rÁ   r   r   r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r«  rø   rX  rY  rŠ  r  r�  r�  Útext_seq_lenÚtext_featuresr€   Ú
mlm_logitsÚmasked_lm_lossÚloss_fctr  s   &&&&&&&&&&&&,          r#   r´   ÚViltForMaskedLM.forward´  sT  € ðV &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆà—)‘)ØØ)Ø)Ø%Ø!Ø'Ø%Ø/Ø!5Ø#ð ó 
ˆð *1°­Ñ&ˆà-6Ò-B�y—‘ qÖ)È×H[ÑH[Ð\]ÕH^ˆØ+¨A¨}°¨}Ð,<Õ=¸ÈqÐR^ÑR_ÐO_Õ?`�qˆà—^‘^ MÓ2ˆ
àˆØÒÜ'Ó)ˆHà—Y‘Y˜z×0Ñ0Ó1ˆFÙ% j§o¡o°b¸$¿+¹+×:PÑ:PÓ&QÐSY×S^ÑS^Ð_aÓSbÓcˆNçØ �] W¨R¥[Õ0ˆFØ3AÒ3M�^Ð%¨Õ.ÐYÐSYÐYäØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r&   )rŸ  ra  r’  )r(   r)   r*   r+   Ú_tied_weights_keysr6   r£  r§  r   r´   r.   r/   r·   r¸   s   @@r#   rœ  rœ  š  sF   ù‡ € ð 	#Ð$\ðÐõò&ò2ð ÷p
ñ p
ó ÷p
ð p
r&   rœ  c                   ó8   a a€ ] tR tRt oV 3R ltR tRtVtV ;t# )ÚViltPredictionHeadTransformi(  c                ó‚  <€ \         SV `  4        \        P                  ! VP                  VP                  4      V n        \        VP                  \        4      '       d   \        VP                  ,          V n
        MVP                  V n
        \        P                  ! VP                  VP                  R 7      V n        R# )r¼   N)r5   r6   r   rê   r;   r  rs   r*  r+  r   Útransform_act_fnrÆ   rÇ   rÊ   s   &&€r#   r6   Ú$ViltPredictionHeadTransform.__init__)  s~   ø€ Ü‰ÑÔÜ—Y’Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
Ü�f×'Ñ'¬×-Ò-Ü$*¨6×+<Ñ+<Õ$=ˆDÕ!à$*×$5Ñ$5ˆDÔ!ÜŸš f×&8Ñ&8¸f×>SÑ>SÔTˆŽr&   c                ól   € V P                  V4      pV P                  V4      pV P                  V4      pV# r  )r  r»  rÆ   r1  s   &&r#   r´   Ú#ViltPredictionHeadTransform.forward2  s4   € ØŸ
™
 =Ó1ˆØ×-Ñ-¨mÓ<ˆØŸ™ }Ó5ˆØÐr&   )rÆ   r  r»  r  r¸   s   @@r#   r¹  r¹  (  s   ù‡ € õU÷ò r&   r¹  c                   ó8   a a€ ] tR tRt oV 3R ltR tRtVtV ;t# )rž  i9  c                ó°   <€ \         SV `  4        Wn        \        V4      V n        \
        P                  ! VP                  VP                  4      V n	        R # r  )
r5   r6   rG   r¹  Ú	transformr   rê   r;   rÁ   r¢  rÊ   s   &&€r#   r6   ÚViltMLMHead.__init__:  s=   ø€ Ü‰ÑÔØŒÜ4°VÓ<ˆŒÜ—y’y ×!3Ñ!3°V×5FÑ5FÓGˆŽr&   c                óJ   € V P                  V4      pV P                  V4      pV# r  )rÁ  r¢  )rH   rƒ   s   &&r#   r´   ÚViltMLMHead.forward@  s"   € Ø�N‰N˜1ÓˆØ�L‰L˜‹OˆØˆr&   )rG   r¢  rÁ  r  r¸   s   @@r#   rž  rž  9  s   ù‡ € õH÷ò r&   rž  z¶
    Vilt Model transformer with a classifier head on top (a linear layer on top of the final hidden state of the [CLS]
    token) for visual question answering, e.g. for VQAv2.
    c                   óR   a a€ ] tR tRt oV 3R lt]RV3R lR ll4       tRtVtV ;t	# )ÚViltForQuestionAnsweringiF  c           	     óô  <€ \         SV `  V4       VP                  V n        \        V4      V n        \
        P                  ! \
        P                  ! VP                  VP                  ^,          4      \
        P                  ! VP                  ^,          4      \
        P                  ! 4       \
        P                  ! VP                  ^,          VP                  4      4      V n        V P                  4        R# )r   N)r5   r6   Ú
num_labelsrr  ra  r   Ú
Sequentialrê   r;   rÆ   ÚGELUÚ
classifierrx  rÊ   s   &&€r#   r6   Ú!ViltForQuestionAnswering.__init__M  s¥   ø€ Ü‰Ñ˜Ô à ×+Ñ+ˆŒÜ˜fÓ%ˆŒ	ô Ÿ-š-Ü�IŠI�f×(Ñ(¨&×*<Ñ*<¸qÕ*@ÓAÜ�LŠL˜×+Ñ+¨aÕ/Ó0Ü�GŠG‹IÜ�IŠI�f×(Ñ(¨1Õ,¨f×.?Ñ.?Ó@ó	
ˆŒð 	�‰Ö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[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# rª  ©r   r„  r   r…  r   r    )r!   r"   s   "€r#   r$   Ú%ViltForQuestionAnswering.__annotate___  s  ø€ ÷ U
ñ U
á×#Ñ# dÕ*ðU
ñ ×)Ñ)¨DÕ0ðU
ñ ×(Ñ(¨4Õ/ð	U
ñ
 ×'Ñ'¨$Õ.ðU
ñ ×$Ñ$ tÕ+ðU
ñ ×(Ñ(¨4Õ/ðU
ñ ×'Ñ'¨$Õ.ðU
ñ × Ñ  4Õ'ðU
ñ   $�;ðU
ñ # T�kðU
ñ ˜D•[ðU
ñ 
"¡E©%×*;Ñ*;Õ$<Õ	<ñU
r&   c                ó  € Ve   TMV P                   P                  pV P                  VVVVVVVV	V
VR7
      pV'       d   VP                  MV^,          pV P	                  V4      pRpVeS   VP                  VP                  4      p\        P                  P                  Wø4      VP                  ^,          ,          pV'       g"   V3VR,          ,           pVe   V3V,           # T# \        VVVP                  VP                  R7      # )aÉ  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
labels (`torch.FloatTensor` of shape `(batch_size, num_labels)`, *optional*):
    Labels for computing the visual question answering loss. This tensor must be either a one-hot encoding of
    all answers that are applicable for a given example in the batch, or a soft encoding indicating which
    answers are applicable, where 1.0 is the highest score.

Examples:

```python
>>> from transformers import ViltProcessor, ViltForQuestionAnswering
>>> import httpx
>>> from io import BytesIO
>>> from PIL import Image

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

>>> processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
>>> model = ViltForQuestionAnswering.from_pretrained("dandelin/vilt-b32-finetuned-vqa")

>>> # prepare inputs
>>> encoding = processor(image, text, return_tensors="pt")

>>> # forward pass
>>> outputs = model(**encoding)
>>> logits = outputs.logits
>>> idx = logits.argmax(-1).item()
>>> print("Predicted answer:", model.config.id2label[idx])
Predicted answer: 2
```Nr®  r¯  r°  )rG   rY  ra  rˆ  rË  rq   rV   r   rb   Ú binary_cross_entropy_with_logitsr`   r   r   r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r«  rø   rX  rY  rŠ  r  rˆ  r   r   r  s   &&&&&&&&&&&&,     r#   r´   Ú ViltForQuestionAnswering.forward^  s  € ðf &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆà—)‘)ØØ)Ø)Ø%Ø!Ø'Ø%Ø/Ø!5Ø#ð ó 
ˆ÷ 2=˜×-Ò-À'È!Å*ˆà—‘ Ó/ˆàˆØÒà—Y‘Y˜vŸ}™}Ó-ˆFÜ—=‘=×AÑAÀ&ÓQÐTZ×T`ÑT`ÐabÕTcÕcˆD÷ Ø�Y ¨¥Õ,ˆFØ)-Ò)9�T�G˜fÕ$ÐE¸vÐEä'ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r&   ©rË  rÈ  ra  r’  ©
r(   r)   r*   r+   r6   r   r´   r.   r/   r·   r¸   s   @@r#   rÆ  rÆ  F  s,   ù‡ € õð" ÷U
ñ U
ó ÷U
ð U
r&   rÆ  zË
    Vilt Model transformer with a classifier head on top (a linear layer on top of the final hidden state of the [CLS]
    token) for image-to-text or text-to-image retrieval, e.g. MSCOCO and F30K.
    c                   óR   a a€ ] tR tRt oV 3R lt]RV3R lR ll4       tRtVtV ;t	# )ÚViltForImageAndTextRetrievali·  c                ó²   <€ \         SV `  V4       \        V4      V n        \        P
                  ! VP                  ^4      V n        V P                  4        R# r3   )	r5   r6   rr  ra  r   rê   r;   Úrank_outputrx  rÊ   s   &&€r#   r6   Ú%ViltForImageAndTextRetrieval.__init__¾  sC   ø€ Ü‰Ñ˜Ô ä˜fÓ%ˆŒ	ô Ÿ9š9 V×%7Ñ%7¸Ó;ˆÔð 	�‰Ö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[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# rª  rÎ  )r!   r"   s   "€r#   r$   Ú)ViltForImageAndTextRetrieval.__annotate__Ê  s  ø€ ÷ N
ñ N
á×#Ñ# dÕ*ðN
ñ ×)Ñ)¨DÕ0ðN
ñ ×(Ñ(¨4Õ/ð	N
ñ
 ×'Ñ'¨$Õ.ðN
ñ ×$Ñ$ tÕ+ðN
ñ ×(Ñ(¨4Õ/ðN
ñ ×'Ñ'¨$Õ.ðN
ñ × Ñ  4Õ'ðN
ñ   $�;ðN
ñ # T�kðN
ñ ˜D•[ðN
ñ 
"¡E©%×*;Ñ*;Õ$<Õ	<ñN
r&   c                ó†  € Ve   TMV P                   P                  pRpVe   \        R4      hV P                  VVVVVVVV	V
VR7
      pV'       d   VP                  MV^,          pV P                  V4      pV'       g"   V3VR,          ,           pVe   V3V,           # T# \        VVVP                  VP                  R7      # )aí  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels are currently not supported.

Examples:

```python
>>> from transformers import ViltProcessor, ViltForImageAndTextRetrieval
>>> import httpx
>>> from io import BytesIO
>>> from PIL import Image

>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> with httpx.stream("GET", url) as response:
...     image = Image.open(BytesIO(response.read()))
>>> texts = ["An image of two cats chilling on a couch", "A football player scoring a goal"]

>>> processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-coco")
>>> model = ViltForImageAndTextRetrieval.from_pretrained("dandelin/vilt-b32-finetuned-coco")

>>> # forward pass
>>> scores = dict()
>>> for text in texts:
...     # prepare inputs
...     encoding = processor(image, text, return_tensors="pt")
...     outputs = model(**encoding)
...     scores[text] = outputs.logits[0, :].item()
```NzTraining is not yet supported.r®  r¯  r°  )	rG   rY  ÚNotImplementedErrorra  rˆ  rØ  r   r   r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r«  rø   rX  rY  rŠ  r   r  rˆ  r   r  s   &&&&&&&&&&&&,     r#   r´   Ú$ViltForImageAndTextRetrieval.forwardÉ  s×   € ð^ &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàˆØÒÜ%Ð&FÓGÐGà—)‘)ØØ)Ø)Ø%Ø!Ø'Ø%Ø/Ø!5Ø#ð ó 
ˆ÷ 2=˜×-Ò-À'È!Å*ˆà×!Ñ! -Ó0ˆçØ�Y ¨¥Õ,ˆFØ)-Ò)9�T�G˜fÕ$ÐE¸vÐEä'ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r&   )rØ  ra  r’  rÔ  r¸   s   @@r#   rÖ  rÖ  ·  s,   ù‡ € õ	ð ÷N
ñ N
ó ÷N
ð N
r&   rÖ  zq
    Vilt Model transformer with a classifier head on top for natural language visual reasoning, e.g. NLVR2.
    c                   óR   a a€ ] tR tRt oV 3R lt]RV3R lR ll4       tRtVtV ;t	# )Ú"ViltForImagesAndTextClassificationi  c           	     ó  <€ \         SV `  V4       VP                  V n        \        V4      V n        VP
                  p\        P                  ! \        P                  ! VP                  V,          VP                  V,          4      \        P                  ! VP                  V,          4      \        P                  ! 4       \        P                  ! VP                  V,          VP                  4      4      V n        V P                  4        R # r  )r5   r6   rÈ  rr  ra  Ú
num_imagesr   rÉ  rê   r;   rÆ   rÊ  rË  rx  )rH   rG   râ  rI   s   && €r#   r6   Ú+ViltForImagesAndTextClassification.__init__!  sµ   ø€ Ü‰Ñ˜Ô à ×+Ñ+ˆŒÜ˜fÓ%ˆŒ	ð ×&Ñ&ˆ
ÜŸ-š-Ü�IŠI�f×(Ñ(¨:Õ5°v×7IÑ7IÈJÕ7VÓWÜ�LŠL˜×+Ñ+¨jÕ8Ó9Ü�GŠG‹IÜ�IŠI�f×(Ñ(¨:Õ5°v×7HÑ7HÓIó	
ˆŒð 	�‰Ö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[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# rª  )r   r„  r   r…  r   r    )r!   r"   s   "€r#   r$   Ú/ViltForImagesAndTextClassification.__annotate__4  s  ø€ ÷ v
ñ v
á×#Ñ# dÕ*ðv
ñ ×)Ñ)¨DÕ0ðv
ñ ×(Ñ(¨4Õ/ð	v
ñ
 ×'Ñ'¨$Õ.ðv
ñ ×$Ñ$ tÕ+ðv
ñ ×(Ñ(¨4Õ/ðv
ñ ×'Ñ'¨$Õ.ðv
ñ × Ñ  4Õ'ðv
ñ   $�;ðv
ñ # T�kðv
ñ ˜D•[ðv
ñ 
2±E¹%×:KÑ:KÕ4LÕ	Lñv
r&   c                óN  € 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e#   VP                  ^8X  d   VP                  ^4      pVe#   VP                  ^8X  d   VP                  ^4      pVe   VP                  ^,          MRpVf   Ve   VP                  ^,          MRpWÐP                   P                  8w  d   \        R4      h. pV
'       d   . MRpV	'       d   . MRp\        V4       FÐ  pT P                  TTTVe   VRVRRR3,          MRVe   VRVRR3,          MRTVe   VRVRR3,          MRV^,           V	V
VR7      pV'       d   VP                  MV^,          pVP                  V4       V
'       d   VP                  VP                  4       V	'       g   Kµ  VP                  VP                  4       KÒ  	  \        P                   ! VRR7      pV P#                  V4      pRpVeX   \%        4       pVP'                  VP(                  4      pV! VP+                  RV P,                  4      VP+                  R4      4      pV'       g   VVV3pVe   V3V,           # T# \/        VVVVR7      # )a  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Binary classification labels.

Examples:

```python
>>> from transformers import ViltProcessor, ViltForImagesAndTextClassification
>>> import httpx
>>> from io import BytesIO
>>> from PIL import Image

>>> url_1 = "https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg"
>>> with httpx.stream("GET", url_1) as response:
...     image_1 = Image.open(BytesIO(response.read()))

>>> url_2 = "https://lil.nlp.cornell.edu/nlvr/exs/ex0_1.jpg"
>>> with httpx.stream("GET", url_2) as response:
...     image_2 = Image.open(BytesIO(response.read()))

>>> text = "The left image contains twice the number of dogs as the right image."

>>> processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-nlvr2")
>>> model = ViltForImagesAndTextClassification.from_pretrained("dandelin/vilt-b32-finetuned-nlvr2")

>>> # prepare inputs
>>> encoding = processor([image_1, image_2], text, return_tensors="pt")

>>> # forward pass
>>> outputs = model(input_ids=encoding.input_ids, pixel_values=encoding.pixel_values.unsqueeze(0))
>>> logits = outputs.logits
>>> idx = logits.argmax(-1).item()
>>> print("Predicted answer:", model.config.id2label[idx])
Predicted answer: True
```Nz\Make sure to match the number of images in the model with the number of images in the input.rL   )
r­   r§   r}   r~   r¨   r®   r¯   rø   rX  rY  rN   r°  r]   )rG   rø   rX  rY  ÚndimÚ	unsqueezer`   râ  rÞ   rM  ra  rˆ  r|   r   r   r   rj   rË  r   rq   rV   ri   rÈ  r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r«  rø   rX  rY  rŠ  râ  Úpooler_outputsr   r   r�   r  rˆ  r�  r   r   rµ  r  s   &&&&&&&&&&&&,            r#   r´   Ú*ViltForImagesAndTextClassification.forward3  s‹  € ðl 2CÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒ#¨×(9Ñ(9¸QÔ(>à'×1Ñ1°!Ó4ˆLàÒ#¨×(9Ñ(9¸QÔ(>à'×1Ñ1°!Ó4ˆLà.:Ò.F�\×'Ñ'¨Ö*ÈDˆ
ØÒØ2>Ò2J˜×+Ñ+¨AÖ.ÐPTˆJØŸ™×/Ñ/Ô/ÜØnóð ð ˆß2™¸ˆß,‘R°$ˆ
Ü�zÖ"ˆAà—i‘iØØ-Ø-Ø<HÒ<T˜\¨!¨Q°°1°a¨-Ö8ÐZ^Ø5?Ò5K˜: a¨¨A¨q jÖ1ÐQUØ+Ø9EÒ9Q˜\¨!¨Q°°1¨*Ö5ÐW[Ø%&¨¥UØ"3Ø%9Ø'ð  ó ˆG÷ 6A˜G×1Ò1ÀgÈaÅjˆMØ×!Ñ! -Ô0ß#Ø×$Ñ$ W×%:Ñ%:Ô;ß Ñ Ø×!Ñ! '×"4Ñ"4Ö5ñ) #ô, Ÿ	š	 .°bÔ9ˆØ—‘ Ó/ˆàˆØÒÜ'Ó)ˆHà—Y‘Y˜vŸ}™}Ó-ˆFÙ˜FŸK™K¨¨D¯O©OÓ<¸f¿k¹kÈ"»oÓNˆDçØ˜m¨ZÐ8ˆFØ)-Ò)9�T�G˜fÕ$ÐE¸vÐEä7ØØØ'Ø!ô	
ð 	
r&   rÓ  r’  rÔ  r¸   s   @@r#   rà  rà    s,   ù‡ € õð$ ÷v
ñ v
ó ÷v
ð v
r&   rà  c                   óR   a a€ ] tR tRt oV 3R lt]RV3R lR ll4       tRtVtV ;t	# )ÚViltForTokenClassificationi­  c                ó6  <€ \         SV `  V4       VP                  V n        \        VR R7      V n        \
        P                  ! VP                  4      V n        \
        P                  ! VP                  VP                  4      V n        V P                  4        R# )F)ry  N)r5   r6   rÈ  rr  ra  r   rD   rE   rF   rê   r;   rË  rx  rÊ   s   &&€r#   r6   Ú#ViltForTokenClassification.__init__¯  sk   ø€ Ü‰Ñ˜Ô à ×+Ñ+ˆŒÜ˜f¸Ô>ˆŒ	ä—z’z &×"<Ñ"<Ó=ˆŒÜŸ)š) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Ö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[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[S[S[ P                  ,          ,          /# rª  )r   r„  r   r…  r   r    )r!   r"   s   "€r#   r$   Ú'ViltForTokenClassification.__annotate__¼  s÷   ø€ ÷ =
ñ =
á×#Ñ# dÕ*ð=
ñ ×)Ñ)¨DÕ0ð=
ñ ×(Ñ(¨4Õ/ð	=
ñ
 ×'Ñ'¨$Õ.ð=
ñ ×$Ñ$ tÕ+ð=
ñ ×(Ñ(¨4Õ/ð=
ñ ×'Ñ'¨$Õ.ð=
ñ × Ñ  4Õ'ð=
ñ   $�;ð=
ñ # T�kð=
ñ ˜D•[ð=
ñ 
¡¡u×'8Ñ'8Õ!9Õ	9ñ=
r&   c                ó‚  € Ve   TMV P                   P                  pV P                  VVVVVVVV	V
VR7
      pV^ ,          pVe   VP                  ^,          MVP                  ^,          pV P	                  V4      pV P                  VRRV13,          4      pRpVeX   \        4       pVP                  VP                  4      pV! VP                  RV P                  4      VP                  R4      4      pV'       g"   V3VR,          ,           pVe   V3V,           # T# \        VVVP                  VP                  R7      # )aÿ  
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*):
    Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation.
    This is useful if you want more control over how to convert `pixel_values` into patch embeddings.
labels (`torch.LongTensor` of shape `(batch_size, text_sequence_length)`, *optional*):
    Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
Nr®  rL   r¯  r°  r]   )rG   rY  ra  r`   rF   rË  r   rq   rV   ri   rÈ  r   r   r   )rH   r¦   r­   r§   r}   r~   r¨   r®   r«  rø   rX  rY  rŠ  r  r�  Útext_input_sizer   r   rµ  r  s   &&&&&&&&&&&&,       r#   r´   Ú"ViltForTokenClassification.forward»  s:  € ð0 &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆà—)‘)ØØ)Ø)Ø%Ø!Ø'Ø%Ø/Ø!5Ø#ð ó 
ˆð " !�*ˆà09Ò0E˜)Ÿ/™/¨!Ö,È=×K^ÑK^Ð_`ÕKaˆàŸ,™, Ó7ˆØ—‘ °Ð4D°_Ð4DÐ1DÕ!EÓFˆàˆØÒÜ'Ó)ˆHà—Y‘Y˜vŸ}™}Ó-ˆFÙ˜FŸK™K¨¨D¯O©OÓ<¸f¿k¹kÈ"»oÓNˆDçØ�Y ¨¥Õ,ˆFØ)-Ò)9�T�G˜fÕ$ÐE¸vÐEä$ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r&   )rË  rF   rÈ  ra  r’  rÔ  r¸   s   @@r#   rì  rì  ­  s(   ù‡ € õ
ð ÷=
ñ =
ó ÷=
ð =
r&   rì  )rÖ  rà  rì  rœ  rÆ  r=  rr  r`  );r,   Úcollections.abcrØ   ró   Údataclassesr   r   r   Útorch.nnr   Ú r   rd  Úactivationsr   Úmasking_utilsr   Úmodeling_layersr   Úmodeling_outputsr	   r
   r   r   r   r   Úmodeling_utilsr   Úutilsr   r   Úconfiguration_viltr   Ú
get_loggerr(   Úloggerr   ÚModuler1   r7   r=   râ   r  r  r%  r4  r=  rJ  r`  rr  rv  rœ  r¹  rž  rÆ  rÖ  rà  rì  Ú__all__r'   r&   r#   Ú<module>r     s\  ðñ ã Û Ý !ã Ý Ý %å &Ý !Ý 6Ý 9÷÷ õ .ß ,Ý *ð 
×	Ò	˜HÓ	%€ñ ðôð
 ô=¨{ó =ó óð=ô$W!�R—Y‘Yô W!ôt/�R—Y‘Yô /ôd˜"Ÿ)™)ô ô>0˜Ÿ	™	ô 0ôh�R—Y‘Yô ô"�B—I‘Iô ô �r—y‘yô ô 
�—‘ô 
ô"Ð*ô "ôJ&
�"—)‘)ô &
ðR ô/˜/ó /ó ð/ð ôI
Ð#ó I
ó ðI
ôX�—‘ô ñ ðôô
F
Ð)ó F
óð
F
ôR "§)¡)ô ô"
�"—)‘)ô 
ñ ðôôh
Ð2ó h
óðh
ñV ðôô[
Ð#6ó [
óð[
ñ| ðôô
J
Ð)<ó J
óð
J
ðZ ôK
Ð!4ó K
ó ðK
ò\	‚r&   