+
    œ°³jo ã                   óä  € R t ^ RIt^ RIt^ RIHt ^ RIt^ RIHt ^ RI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 ^R	IHtHt ^R
IHt ^RIHtHtHtHtH t H!t!H"t" ^RI#H$t$H%t% ^RI&H't' ^RI(H)t)H*t*H+t+H,t,H-t-H.t. ^RI/H0t0H1t1 ^RI2H3t3H4t4 ^RI5H6t6 ]-Pn                  ! ]84      t9R9R R llt: ! R R]Pv                  4      t< ! R R]Pv                  4      t= ! R R]Pv                  4      t> ! R R]Pv                  4      t? ! R R]Pv                  4      t@ ! R R]Pv                  4      tA ! R  R!]Pv                  4      tB ! R" R#]4      tC ! R$ R%]Pv                  4      tD], ! R& R']%4      4       tE ! R( R)]E4      tF], ! R* R+]E4      4       tG],! R,R-7       ! R. R/]E]4      4       tH], ! R0 R1]E4      4       tI],! R2R-7       ! R3 R4]E4      4       tJ], ! R5 R6]E4      4       tK], ! R7 R8]E4      4       tL. R:OtMR# );zPyTorch mT5 model.N)ÚCallable)Únn)ÚBCEWithLogitsLossÚCrossEntropyLossÚMSELoss)Úinitialization)ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)ÚGenerationMixin)Úcreate_bidirectional_maskÚcreate_causal_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚ)BaseModelOutputWithPastAndCrossAttentionsÚSeq2SeqLMOutputÚSeq2SeqModelOutputÚ#Seq2SeqQuestionAnsweringModelOutputÚSeq2SeqSequenceClassifierOutputÚTokenClassifierOutput)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)ÚDUMMY_INPUTSÚ
DUMMY_MASKÚTransformersKwargsÚauto_docstringÚloggingÚtorch_compilable_check)Úcan_return_tupleÚmerge_with_config_defaults)ÚOutputRecorderÚcapture_outputs©Ú	MT5Configc                ó<  € V ^8„  d   QhR\         P                  R\        P                  R\        P                  R\        P                  R\        P                  R,          R\        R,          R\        R	\        P                  R,          R
\
        \        ,          /	# )é   ÚmoduleÚqueryÚkeyÚvalueÚattention_maskNÚscalingÚdropoutÚposition_biasÚkwargs)r   ÚModuleÚtorchÚTensorÚfloatr   r   )Úformats   "Úe/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/mt5/modeling_mt5.pyÚ__annotate__r7   3   sŽ   € ÷ %ñ %Ü�I‰Ið%ä�<‰<ð%ô 
�‰ð%ô �<‰<ð	%ô
 —L‘L 4Õ'ð%ô �T�\ð%ô ð%ô —<‘< $Õ&ð%ô Ô'Õ(ñ%ó    c                 óÎ  € Vf   VP                  R4      R,          p\        P                  ! WP                  ^^4      4      V,          p	Ve	   W—,           p	Ve	   W”,           p	\        P
                  P                  V	RR7      p	\        P
                  P                  W–V P                  R7      p	\        P                  ! W“4      p
V
P                  ^^4      P                  4       p
W©3# )N©Údim)ÚpÚtrainingéÿÿÿÿç      à¿)
Úsizer2   ÚmatmulÚ	transposer   Ú
functionalÚsoftmaxr.   r=   Ú
contiguous)r(   r)   r*   r+   r,   r-   r.   r/   r0   Úattn_weightsÚattn_outputs   &&&&&&&&,  r6   Úeager_attention_forwardrH   3   s¿   € ð ‚Ø—*‘*˜R“. DÕ(ˆô —<’< §}¡}°Q¸Ó':Ó;¸gÕE€LàÒ Ø#Õ3ˆàÒ!Ø#Õ4ˆä—=‘=×(Ñ(¨¸2Ð(Ó>€LÜ—=‘=×(Ñ(¨È6Ï?É?Ð(Ó[€Lä—,’,˜|Ó3€KØ×'Ñ'¨¨1Ó-×8Ñ8Ó:€KàÐ$Ð$r8   c                   ó<   a a€ ] tR t^Tt oRV 3R lltR tRtVtV ;t# )ÚMT5LayerNormc                óŽ   <€ \         SV `  4        \        P                  ! \        P
                  ! V4      4      V n        W n        R# )zT
Construct a layernorm module in the MT5 style. No bias and no subtraction of mean.
N)ÚsuperÚ__init__r   Ú	Parameterr2   ÚonesÚweightÚvariance_epsilon)ÚselfÚhidden_sizeÚepsÚ	__class__s   &&&€r6   rM   ÚMT5LayerNorm.__init__U   s/   ø€ ô 	‰ÑÔÜ—l’l¤5§:¢:¨kÓ#:Ó;ˆŒØ #Ör8   c                ó¼  € VP                  \        P                  4      P                  ^4      P	                  RRR7      pV\        P
                  ! W P                  ,           4      ,          pV P                  P                  \        P                  \        P                  39   d&   VP                  V P                  P                  4      pV P                  V,          # )r'   T)Úkeepdimr>   )Útor2   Úfloat32ÚpowÚmeanÚrsqrtrQ   rP   ÚdtypeÚfloat16Úbfloat16)rR   Úhidden_statesÚvariances   && r6   ÚforwardÚMT5LayerNorm.forward]   s™   € ð !×#Ñ#¤E§M¡MÓ2×6Ñ6°qÓ9×>Ñ>¸rÈ4Ð>ÓPˆØ%¬¯ª°H×?TÑ?TÕ4TÓ(UÕUˆð �;‰;×Ñ¤§¡´·±Ð ?Ô?Ø)×,Ñ,¨T¯[©[×->Ñ->Ó?ˆMà�{‰{˜]Õ*Ð*r8   )rQ   rP   )g�íµ ÷Æ°>©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__rM   rc   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©rU   Ú__classdict__s   @@r6   rJ   rJ   T   s   ù‡ € ÷$÷+ò +r8   rJ   c                   óD   a a€ ] tR t^nt oV3R lV 3R lltR tRtVtV ;t# )ÚMT5DenseActDensec                ó    <€ V ^8„  d   QhRS[ /# ©r'   Úconfigr$   )r5   rn   s   "€r6   r7   ÚMT5DenseActDense.__annotate__o   s   ø€ ÷ /ñ /™yñ /r8   c                ón  <€ \         SV `  4        \        P                  ! VP                  VP
                  R R7      V n        \        P                  ! VP
                  VP                  R R7      V n        \        P                  ! VP                  4      V n
        \        VP                  ,          V n        R# ©F©ÚbiasN)rL   rM   r   ÚLinearÚd_modelÚd_ffÚwiÚwoÚDropoutÚdropout_rater.   r   Údense_act_fnÚact©rR   rs   rU   s   &&€r6   rM   ÚMT5DenseActDense.__init__o   sn   ø€ Ü‰ÑÔÜ—)’)˜FŸN™N¨F¯K©K¸eÔDˆŒÜ—)’)˜FŸK™K¨¯©¸eÔDˆŒÜ—z’z &×"5Ñ"5Ó6ˆŒÜ˜&×-Ñ-Õ.ˆŽr8   c                ó  € V P                  V4      pV P                  V4      pV P                  V4      p\        V P                  P
                  \        P                  4      '       d’   VP                  V P                  P
                  P                  8w  dc   V P                  P
                  P                  \        P                  8w  d0   VP                  V P                  P
                  P                  4      pV P	                  V4      pV# ©N)r|   r�   r.   Ú
isinstancer}   rP   r2   r3   r^   Úint8rY   ©rR   ra   s   &&r6   rc   ÚMT5DenseActDense.forwardv   s­   € ØŸ™ Ó.ˆØŸ™ Ó/ˆØŸ™ ]Ó3ˆä�t—w‘w—~‘~¤u§|¡|×4Ò4Ø×#Ñ# t§w¡w§~¡~×';Ñ';Ô;Ø—‘—‘×$Ñ$¬¯
©
Ô2à)×,Ñ,¨T¯W©W¯^©^×-AÑ-AÓBˆMØŸ™ Ó.ˆØÐr8   )r�   r.   r|   r}   re   rm   s   @@r6   rp   rp   n   s   ù‡ € ÷/ó /÷ò r8   rp   c                   óD   a a€ ] tR t^…t oV3R lV 3R lltR tRtVtV ;t# )ÚMT5DenseGatedActDensec                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú"MT5DenseGatedActDense.__annotate__†   s   ø€ ÷ /ñ /™yñ /r8   c                óÒ  <€ \         SV `  4        \        P                  ! VP                  VP
                  R R7      V n        \        P                  ! VP                  VP
                  R R7      V n        \        P                  ! VP
                  VP                  R R7      V n        \        P                  ! VP                  4      V n        \        VP                  ,          V n        R# rv   )rL   rM   r   ry   rz   r{   Úwi_0Úwi_1r}   r~   r   r.   r   r€   r�   r‚   s   &&€r6   rM   ÚMT5DenseGatedActDense.__init__†   sŠ   ø€ Ü‰ÑÔÜ—I’I˜fŸn™n¨f¯k©kÀÔFˆŒ	Ü—I’I˜fŸn™n¨f¯k©kÀÔFˆŒ	Ü—)’)˜FŸK™K¨¯©¸eÔDˆŒÜ—z’z &×"5Ñ"5Ó6ˆŒÜ˜&×-Ñ-Õ.ˆŽr8   c                óF  € V P                  V P                  V4      4      pV P                  V4      pW#,          pV P                  V4      p\	        V P
                  P                  \        P                  4      '       d’   VP                  V P
                  P                  P                  8w  dc   V P
                  P                  P                  \        P                  8w  d0   VP                  V P
                  P                  P                  4      pV P                  V4      pV# r…   )r�   r�   r�   r.   r†   r}   rP   r2   r3   r^   r‡   rY   )rR   ra   Úhidden_geluÚhidden_linears   &&  r6   rc   ÚMT5DenseGatedActDense.forwardŽ   sÀ   € Ø—h‘h˜tŸy™y¨Ó7Ó8ˆØŸ	™	 -Ó0ˆØ#Õ3ˆØŸ™ ]Ó3ˆô �t—w‘w—~‘~¤u§|¡|×4Ò4Ø×#Ñ# t§w¡w§~¡~×';Ñ';Ô;Ø—‘—‘×$Ñ$¬¯
©
Ô2à)×,Ñ,¨T¯W©W¯^©^×-AÑ-AÓBˆMàŸ™ Ó.ˆØÐr8   )r�   r.   r�   r�   r}   re   rm   s   @@r6   r‹   r‹   …   s   ù‡ € ÷/ó /÷ò r8   r‹   c                   óD   a a€ ] tR t^£t oV3R lV 3R lltR tRtVtV ;t# )Ú
MT5LayerFFc                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   ÚMT5LayerFF.__annotate__¤   s   ø€ ÷ 7ñ 7™yñ 7r8   c                ó   <€ \         SV `  4        VP                  '       d   \        V4      V n        M\        V4      V n        \        VP                  VP                  R 7      V n	        \        P                  ! VP                  4      V n        R# )©rT   N)rL   rM   Úis_gated_actr‹   ÚDenseReluDenserp   rJ   rz   Úlayer_norm_epsilonÚ
layer_normr   r~   r   r.   r‚   s   &&€r6   rM   ÚMT5LayerFF.__init__¤   sb   ø€ Ü‰ÑÔØ××ÐÜ"7¸Ó"?ˆDÕä"2°6Ó":ˆDÔä& v§~¡~¸6×;TÑ;TÔUˆŒÜ—z’z &×"5Ñ"5Ó6ˆŽr8   c                óx   € V P                  V4      pV P                  V4      pWP                  V4      ,           pV# r…   )rŸ   r�   r.   )rR   ra   Úforwarded_statess   && r6   rc   ÚMT5LayerFF.forward®   s;   € ØŸ?™?¨=Ó9ÐØ×.Ñ.Ð/?Ó@ÐØ%¯©Ð5EÓ(FÕFˆØÐr8   )r�   r.   rŸ   re   rm   s   @@r6   r—   r—   £   s   ù‡ € ÷7ó 7÷ò r8   r—   c                   óv   a a€ ] tR t^¶t oRV3R lV 3R lllt]R	R l4       tR
R ltRV3R lR lltRt	Vt
V ;t# )ÚMT5Attentionc                ó:   <€ V ^8„  d   QhRS[ RS[R,          RS[/# )r'   rs   Ú	layer_idxNÚ	is_causal)r%   ÚintÚbool)r5   rn   s   "€r6   r7   ÚMT5Attention.__annotate__·   s-   ø€ ÷ %,ñ %,áð%,ñ ˜•:ð	%,ñ
 ñ%,r8   c                ó<  <€ \         SV `  4        Wn        VP                  V n        W@n        W n        VP                  V n        VP                  V n        VP                  V n        VP                  V n
        VP                  V n        VP                  V n        V P                  V P                  ,          V n        R V n        W0n        Vf@   V P                  '       d.   \$        P'                  RV P(                  P*                   R24       \,        P.                  ! V P                  V P                  RR7      V n        \,        P.                  ! V P                  V P                  RR7      V n        \,        P.                  ! V P                  V P                  RR7      V n        \,        P.                  ! V P                  V P                  RR7      V n        V P
                  '       d1   \,        P8                  ! V P                  V P                  4      V n        RV n        R# )ç      ð?NzInstantiating a decoder z³ without passing `layer_idx` is not recommended and will to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` when creating this class.Frw   )rL   rM   rs   Ú
is_decoderr¨   Úhas_relative_attention_biasÚrelative_attention_num_bucketsÚrelative_attention_max_distancerz   Úd_kvÚkey_value_proj_dimÚ	num_headsÚn_headsr   r.   Ú	inner_dimr-   r§   ÚloggerÚwarning_oncerU   rf   r   ry   ÚqÚkÚvÚoÚ	EmbeddingÚrelative_attention_biasÚgradient_checkpointing)rR   rs   r¯   r§   r¨   rU   s   &&&&&€r6   rM   ÚMT5Attention.__init__·   s{  ø€ ô 	‰ÑÔØŒØ ×+Ñ+ˆŒØ"ŒØ+FÔ(Ø.4×.SÑ.SˆÔ+Ø/5×/UÑ/UˆÔ,Ø—~‘~ˆŒØ"(§+¡+ˆÔØ×'Ñ'ˆŒØ×*Ñ*ˆŒØŸ™¨×(?Ñ(?Õ?ˆŒàˆŒØ"ŒØÒ §§ Ü×ÑØ*¨4¯>©>×+BÑ+BÐ*Cð D,ð ,ôô —’˜4Ÿ<™<¨¯©¸eÔDˆŒÜ—’˜4Ÿ<™<¨¯©¸eÔDˆŒÜ—’˜4Ÿ<™<¨¯©¸eÔDˆŒÜ—’˜4Ÿ>™>¨4¯<©<¸eÔDˆŒà×+×+Ð+Ü+-¯<ª<¸×8[Ñ8[Ð]a×]iÑ]iÓ+jˆDÔ(à&+ˆÖ#r8   c                óÄ  € ^ pV'       dP   V^,          pW@^ 8„  P                  \        P                  4      V,          ,          p\        P                  ! V 4      p M,\        P                  ! V \        P
                  ! V 4      4      ) p V^,          pW8  pV\        P                  ! V P                  4       V,          4      \        P                  ! W5,          4      ,          W%,
          ,          P                  \        P                  4      ,           p\        P                  ! V\        P                  ! Wr^,
          4      4      pV\        P                  ! W`V4      ,          pV# )aR  
Adapted from Mesh Tensorflow:
https://github.com/tensorflow/mesh/blob/0cb87fe07da627bf0b7e60475d59f95ed6b5be3d/mesh_tensorflow/transformer/transformer_layers.py#L593

Translate relative position to a bucket number for relative attention. The relative position is defined as
memory_position - query_position, i.e. the distance in tokens from the attending position to the attended-to
position. If bidirectional=False, then positive relative positions are invalid. We use smaller buckets for
small absolute relative_position and larger buckets for larger absolute relative_positions. All relative
positions >=max_distance map to the same bucket. All relative positions <=-max_distance map to the same bucket.
This should allow for more graceful generalization to longer sequences than the model has been trained on

Args:
    relative_position: an int32 Tensor
    bidirectional: a boolean - whether the attention is bidirectional
    num_buckets: an integer
    max_distance: an integer

Returns:
    a Tensor with the same shape as relative_position, containing int32 values in the range [0, num_buckets)
)rY   r2   ÚlongÚabsÚminÚ
zeros_likeÚlogr4   ÚmathÚ	full_likeÚwhere)Úrelative_positionÚbidirectionalÚnum_bucketsÚmax_distanceÚrelative_bucketsÚ	max_exactÚis_smallÚrelative_position_if_larges   &&&&    r6   Ú_relative_position_bucketÚ&MT5Attention._relative_position_bucketÞ   s  € ð, ÐßØ˜AÕˆKØ°QÑ!6× :Ñ :¼5¿:¹:Ó FÈÕ TÕTÐÜ %§	¢	Ð*;Ó <Ñä!&§¢Ð+<¼e×>NÒ>NÐO`Ó>aÓ!bÐ bÐð   1Õ$ˆ	Ø$Ñ0ˆð &/Ü�IŠIÐ'×-Ñ-Ó/°)Õ;Ó<Ü�hŠh�|Õ/Ó0õ1àÕ&õ(÷ ‰"ŒU�Z‰Z‹.õ	&Ð"ô
 &+§Y¢YØ&¬¯ªÐ8RÐbcÕTcÓ(dó&
Ð"ð 	œEŸKšK¨ÐE_Ó`Õ`ÐØÐr8   c                óú  € Vf!   V P                   P                  P                  p\        P                  ! V\        P
                  VR7      R,          V,           p\        P                  ! V\        P
                  VR7      R,          pWe,
          pV P                  VV P                  '       * V P                  V P                  R7      pV P                  V4      p	V	P                  . RO4      P                  ^ 4      p	V	# )z%Compute binned relative position bias)r^   Údevice)rË   rÌ   rÍ   )ºNNNN)NrÖ   )r'   é    é   )r¾   rP   rÕ   r2   ÚarangerÂ   rÒ   r®   r°   r±   ÚpermuteÚ	unsqueeze)
rR   Úquery_lengthÚ
key_lengthrÕ   Úpast_seen_tokensÚcontext_positionÚmemory_positionrÊ   Úrelative_position_bucketÚvaluess
   &&&&&     r6   Úcompute_biasÚMT5Attention.compute_bias  sÍ   € àŠ>Ø×1Ñ1×8Ñ8×?Ñ?ˆFÜ Ÿ<š<¨¼E¿J¹JÈvÔVÐW^Õ_ÐbrÕrÐÜŸ,š, z¼¿¹ÈFÔSÐT[Õ\ˆØ+Õ>ÐØ#'×#AÑ#AØØ#Ÿ™Ô.Ø×;Ñ;Ø×=Ñ=ð	 $Bó $
Ð ð ×-Ñ-Ð.FÓGˆØ—‘¢	Ó*×4Ñ4°QÓ7ˆØˆr8   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ©r'   r0   ©r   r   )r5   rn   s   "€r6   r7   r«     s    ø€ ÷ X8ñ X8ñ Ñ+Õ,ñX8r8   c           	     óp  € VP                   RR
 p. VOR
NV P                  N5pVe   VP                  V P                  4      M^ p	\	        V	\
        P                  4      '       d   V	P                  4       MT	p	VRJp
V P                  V4      P                  V4      P                  ^^4      pRp\	        V\        4      '       dH   VP                  P                  V P                  4      pV
'       d   VP                  pMVP                  pMTpV
'       d   TMTpV
'       d\   VeX   V'       dP   VP                   V P                  ,          P"                  pVP                   V P                  ,          P$                  pMÛ. VP                   RR
 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eX   VP+                  VVV P                  4      w  ppV
'       d0   \	        V\        4      '       d   RVP                  V P                  &   Vfº   VP                   R,          pV P,                  '       go   \
        P.                  ! ^V P0                  V^,          V3VP2                  VP4                  R7      pV P6                  '       d   V P8                  '       d   RVn        M&V P=                  V^,          VVP2                  V	R7      p\>        P@                  ! V PB                  PD                  \F        4      pT! V VVVV3RV P8                  '       g   RMV PH                  RV PJ                  R	V/VB w  ppVPL                  ! . VOR
N5!  PO                  4       pV PQ                  V4      pVVV3# )zp
Self-attention (if key_value_states is None) or attention over source sentence (provided by key_value_states).
NFT)rÕ   r^   )rÕ   rÞ   r.   ç        r-   r/   r>   éþÿÿÿ))Úshaper³   Úget_seq_lengthr§   r†   r2   r3   Úcloner¹   ÚviewrB   r   Ú
is_updatedÚgetÚcross_attention_cacheÚself_attention_cacheÚlayersÚkeysrâ   rº   r»   Úupdater¯   Úzerosrµ   rÕ   r^   r¿   r=   Úrequires_gradrã   r   Úget_interfacers   Ú_attn_implementationrH   r.   r-   ÚreshaperE   r¼   )rR   ra   ÚmaskÚkey_value_statesr/   Úpast_key_valuesr0   Úinput_shapeÚhidden_shaperÞ   Úis_cross_attentionÚquery_statesrï   Úcurr_past_key_valuesÚcurrent_statesÚ
key_statesÚvalue_statesÚkv_shaperÝ   Úattention_interfacerG   rF   s   &&&&&&,               r6   rc   ÚMT5Attention.forward  sY  € ð $×)Ñ)¨#¨2Ð.ˆØB˜ÐB bÐB¨$×*AÑ*AÑBˆØM\ÒMh˜?×9Ñ9¸$¿.¹.ÔIÐnoÐä7AÐBRÔTY×T`ÑT`×7aÒ7aÐ+×1Ñ1Ô3ÐgwÐð .°TÐ9Ðà—v‘v˜mÓ,×1Ñ1°,Ó?×IÑIÈ!ÈQÓOˆð ˆ
Ü�oÔ':×;Ò;Ø(×3Ñ3×7Ñ7¸¿¹ÓGˆJß!à'6×'LÑ'LÑ$à'6×'KÑ'KÑ$à#2Ð ç-?Ñ)À]ˆß /Ò"=Ç*à-×4Ñ4°T·^±^ÕD×IÑIˆJØ/×6Ñ6°t·~±~ÕF×MÑM‰LàP˜×-Ñ-¨c¨rÐ2ÐP°BÐP¸×8OÑ8OÑPˆHØŸ™ Ó/×4Ñ4°XÓ>×HÑHÈÈAÓNˆJØŸ6™6 .Ó1×6Ñ6°xÓ@×JÑJÈ1ÈaÓPˆLàÒ*Ø+?×+FÑ+FÀzÐS_Ðae×aoÑaoÓ+pÑ(�
˜Lç%¬*°_ÔFY×*ZÒ*ZØAE�O×.Ñ.¨t¯~©~Ñ>ð Ò Ø#×)Ñ)¨"Õ-ˆJØ×3×3Ð3Ü %§¢Ø˜Ÿ™ k°!¥n°jÐAØ'×.Ñ.Ø&×,Ñ,ô!�ð
 ×.×.Ð.°4·=·=°=Ø26�MÔ/øà $× 1Ñ 1Ø •N J°|×7JÑ7JÐ]mð !2ó !�ô )@×(MÒ(MØ�K‰K×,Ñ,Ô.Eó)
Ðñ %8ØØØØØñ
%
ð  $Ÿ}Ÿ}˜}‘C°$·,±,ð
%
ð —L‘Lð
%
ð (ð
%
ð ñ
%
Ñ!ˆ�\ð "×)Ò)Ð;¨;Ð;¸Ó;×FÑFÓHˆØ—f‘f˜[Ó)ˆà˜M¨<Ð7Ð7r8   )rs   rz   r.   r¿   r¯   r¶   r¨   r®   rº   r³   r§   rµ   r¼   r¹   r¾   r±   r°   r-   r»   )FNF)Té    é€   )Nr×   ©NNNN)rf   rg   rh   ri   rM   ÚstaticmethodrÒ   rã   rc   rj   rk   rl   rm   s   @@r6   r¥   r¥   ¶   s<   ù‡ € ÷%,õ %,ðN ó- ó ð- ô^÷"X8÷ X8ò X8r8   r¥   c                   óX   a a€ ] tR tRt oRV3R lV 3R llltRV3R lR lltRtVtV ;t# )	ÚMT5LayerSelfAttentioni{  c                ó.   <€ V ^8„  d   QhRS[ R,          /# ©r'   r§   N©r©   )r5   rn   s   "€r6   r7   Ú"MT5LayerSelfAttention.__annotate__|  s   ø€ ÷ 	7ñ 	7ÉSÐSWÍZñ 	7r8   c                óö   <€ \         SV `  4        \        VVVVP                  R 7      V n        \        VP                  VP                  R7      V n        \        P                  ! VP                  4      V n        R# )©r¯   r§   r¨   r›   N)rL   rM   r¥   r®   ÚSelfAttentionrJ   rz   rž   rŸ   r   r~   r   r.   ©rR   rs   r¯   r§   rU   s   &&&&€r6   rM   ÚMT5LayerSelfAttention.__init__|  s]   ø€ Ü‰ÑÔÜ)ØØ(CØØ×'Ñ'ô	
ˆÔô ' v§~¡~¸6×;TÑ;TÔUˆŒÜ—z’z &×"5Ñ"5Ó6ˆŽr8   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ræ   rç   )r5   rn   s   "€r6   r7   r  ‡  s   ø€ ÷ =ñ =ñ Ñ+Õ,ñ=r8   c           	     ó’   € V P                  V4      pV P                  ! V3R VRVRV/VB w  rspWP                  V4      ,           pWsV3# )rû   r/   rý   )rŸ   r  r.   )	rR   ra   r,   r/   rý   r0   Únormed_hidden_statesÚattention_outputrF   s	   &&&&&,   r6   rc   ÚMT5LayerSelfAttention.forward‡  sr   € ð  $Ÿ™¨}Ó=ÐØ8<×8JÒ8JØ ñ9
àð9
ð (ð9
ð ,ð	9
ð
 ñ9
Ñ5Ð¨ð )¯<©<Ð8HÓ+IÕIÐØ°Ð<Ð<r8   )r  r.   rŸ   ©FN©NNNre   rm   s   @@r6   r  r  {  s   ù‡ € ÷	7õ 	7÷=÷ =ò =r8   r  c                   óX   a a€ ] tR tRt oRV3R lV 3R llltRV3R lR lltRtVtV ;t# )	ÚMT5LayerCrossAttentioniœ  c                ó.   <€ V ^8„  d   QhRS[ R,          /# r  r  )r5   rn   s   "€r6   r7   Ú#MT5LayerCrossAttention.__annotate__�  s   ø€ ÷ 7ñ 7©#°­*ñ 7r8   c                óâ   <€ \         SV `  4        \        VR VR R7      V n        \	        VP
                  VP                  R7      V n        \        P                  ! VP                  4      V n        R# )Fr  r›   N)rL   rM   r¥   ÚEncDecAttentionrJ   rz   rž   rŸ   r   r~   r   r.   )rR   rs   r§   rU   s   &&&€r6   rM   ÚMT5LayerCrossAttention.__init__�  sU   ø€ Ü‰ÑÔÜ+Ø°ÀÐV[ô 
ˆÔô ' v§~¡~¸6×;TÑ;TÔUˆŒÜ—z’z &×"5Ñ"5Ó6ˆŽr8   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ræ   rç   )r5   rn   s   "€r6   r7   r"  ¥  s   ø€ ÷ 9ñ 9ñ Ñ+Õ,ñ9r8   c                ó–   € V P                  V4      pV P                  ! V3R VRVRVRV/VB w  r„p	WP                  V4      ,           p
W¤V	3# )rû   rü   r/   rý   )rŸ   r$  r.   )rR   ra   rü   r,   r/   rý   r0   r  r  rF   Úlayer_outputs   &&&&&&,    r6   rc   ÚMT5LayerCrossAttention.forward¥  s{   € ð  $Ÿ™¨}Ó=ÐØ8<×8LÒ8LØ ñ9
àð9
ð .ð9
ð (ð	9
ð
 ,ð9
ð ñ9
Ñ5Ð¨ð %§|¡|Ð4DÓ'EÕEˆØ¨LÐ8Ð8r8   )r$  r.   rŸ   r…   r  re   rm   s   @@r6   r   r   œ  s   ù‡ € ÷7õ 7÷9÷ 9ò 9r8   r   c                   óX   a a€ ] tR tRt oRV3R lV 3R llltRV3R lR lltRtVtV ;t# )	ÚMT5Blocki¼  c                ó.   <€ V ^8„  d   QhRS[ R,          /# r  r  )r5   rn   s   "€r6   r7   ÚMT5Block.__annotate__½  s   ø€ ÷ 
.ñ 
.ÉSÐSWÍZñ 
.r8   c                ó|  <€ \         SV `  4        VP                  V n        \        P                  ! 4       V n        V P
                  P                  \        WVR 7      4       V P                  '       d&   V P
                  P                  \        WR7      4       V P
                  P                  \        V4      4       R# )©r¯   r§   )r§   N)
rL   rM   r®   r   Ú
ModuleListÚlayerÚappendr  r   r—   r  s   &&&&€r6   rM   ÚMT5Block.__init__½  s   ø€ Ü‰ÑÔØ ×+Ñ+ˆŒÜ—]’]“_ˆŒ
Ø�
‰
×ÑÜ! &ÐmvÔwô	
ð �?�?ˆ?Ø�J‰J×ÑÔ4°VÔQÔRà�
‰
×Ñœ* VÓ,Ö-r8   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ræ   rç   )r5   rn   s   "€r6   r7   r-  É  s    ø€ ÷ =Pñ =Pñ Ñ+Õ,ñ=Pr8   c                óÆ  € V P                   ^ ,          ! V3RVRVRV/VB w  rp
VP                  \        P                  8X  d«   \        P                  ! \        P
                  ! V4      P                  4       \        P                  ! VP                  4      P                  R,
          \        P                  ! VP                  4      P                  4      p\        P                  ! W) VR7      pRpV P                  ;'       d    VRJpV'       dï   V P                   ^,          ! V3RVRVRVRV/VB w  rp
VP                  \        P                  8X  d«   \        P                  ! \        P
                  ! V4      P                  4       \        P                  ! VP                  4      P                  R,
          \        P                  ! VP                  4      P                  4      p\        P                  ! W) VR7      pV P                   R,          ! V4      pVP                  \        P                  8X  d«   \        P                  ! \        P
                  ! V4      P                  4       \        P                  ! VP                  4      P                  R,
          \        P                  ! VP                  4      P                  4      p\        P                  ! W) VR7      pWV3# )	r×   r,   r/   rý   iè  )rÄ   ÚmaxNrü   r>   )r1  r^   r2   r_   rÉ   ÚisinfÚanyÚfinfor6  Úclampr®   )rR   ra   r,   r/   Úencoder_hidden_statesÚencoder_attention_maskÚencoder_decoder_position_biasrý   r0   Úself_attn_position_biasÚ_Úclamp_valueÚcross_attn_position_biasÚdo_cross_attentions   &&&&&&&&,     r6   rc   ÚMT5Block.forwardÉ  sP  € ð 59·J±J¸q¶MØñ5
à)ð5
ð (ð5
ð ,ð	5
ð
 ñ5
Ñ1ˆ°ð ×Ñ¤%§-¡-Ô/ÜŸ+š+Ü—’˜MÓ*×.Ñ.Ó0Ü—’˜M×/Ñ/Ó0×4Ñ4°tÕ;Ü—’˜M×/Ñ/Ó0×4Ñ4óˆKô
 "ŸKšK¨¸<È[ÔYˆMà#'Ð Ø!Ÿ_™_×RÐRÐ1FÈdÐ1RÐßØ9=¿¹ÀA¾Øñ:à!6ð:ð  6ð:ð <ð	:ð
 !0ð:ð ñ:Ñ6ˆM°Qð ×"Ñ"¤e§m¡mÔ3Ü#ŸkškÜ—K’K Ó.×2Ñ2Ó4Ü—K’K × 3Ñ 3Ó4×8Ñ8¸4Õ?Ü—K’K × 3Ñ 3Ó4×8Ñ8ó�ô
 !&§¢¨M¸|ÐQ\Ô ]�ð Ÿ
™
 2ž }Ó5ˆð ×Ñ¤%§-¡-Ô/ÜŸ+š+Ü—’˜MÓ*×.Ñ.Ó0Ü—’˜M×/Ñ/Ó0×4Ñ4°tÕ;Ü—’˜M×/Ñ/Ó0×4Ñ4óˆKô
 "ŸKšK¨¸<È[ÔYˆMàÐ7OÐOÐOr8   )r®   r1  r  )NNNNNNre   rm   s   @@r6   r+  r+  ¼  s!   ù‡ € ÷
.õ 
.÷=P÷ =Pò =Pr8   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	# )ÚMT5ClassificationHeadi
  z-Head for sentence-level classification tasks.c                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú"MT5ClassificationHead.__annotate__  s   ø€ ÷ Eñ E™yñ Er8   c                ó0  <€ \         SV `  4        \        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  R 7      V n        \        P                  ! VP                  VP                  4      V n
        R# ))r<   N)rL   rM   r   ry   rz   Údenser~   Úclassifier_dropoutr.   Ú
num_labelsÚout_projr‚   s   &&€r6   rM   ÚMT5ClassificationHead.__init__  sZ   ø€ Ü‰ÑÔÜ—Y’Y˜vŸ~™~¨v¯~©~Ó>ˆŒ
Ü—z’z F×$=Ñ$=Ô>ˆŒÜŸ	š	 &§.¡.°&×2CÑ2CÓDˆŽr8   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r'   ra   Úreturn©r2   r3   )r5   rn   s   "€r6   r7   rG    s#   ø€ ÷ ñ ¡U§\¡\ð ±e·l±lñ r8   c                óº   € V P                  V4      pV P                  V4      p\        P                  ! V4      pV P                  V4      pV P	                  V4      pV# r…   )r.   rI  r2   ÚtanhrL  rˆ   s   &&r6   rc   ÚMT5ClassificationHead.forward  sN   € ØŸ™ ]Ó3ˆØŸ
™
 =Ó1ˆÜŸ
š
 =Ó1ˆØŸ™ ]Ó3ˆØŸ™ mÓ4ˆØÐr8   )rI  r.   rL  )
rf   rg   rh   ri   Ú__doc__rM   rc   rj   rk   rl   rm   s   @@r6   rE  rE  
  s#   ù‡ € Ù7÷Eó E÷÷ ð r8   rE  c            
       óà   a a€ ] tR tRt oRtRtR.tR.tRtRt	Rt
RtR]! ]^ R7      R	]! ]RR7      R
]! ]RR7      /t]R 4       t]P(                  ! 4       V 3R l4       tR tV3R ltRtVtV ;t# )ÚMT5PreTrainedModeli  ÚtransformerTr+  r}   Fra   )ÚindexÚ
attentionsÚcross_attentionsc                ó~   € \         P                  ! \        4      p\         P                  ! \        4      pR VRVRV/pV# )Údecoder_input_idsÚ	input_idsÚdecoder_attention_mask)r2   Útensorr   r   )rR   r]  Ú
input_maskÚdummy_inputss   &   r6   ra  ÚMT5PreTrainedModel.dummy_inputs2  s<   € ä—L’L¤Ó.ˆ	Ü—\’\¤*Ó-ˆ
à Ø˜Ø$ jð
ˆð
 Ðr8   c                óÐ  <€ \         SV `  V4       V P                  P                  p\	        V\
        4      '       d+   \        P                  ! VP                  VR,          4       R# \	        V\        \        \        \        34      '       Ed%   \        P                  ! VP                  P                  RVR,          R7       \        VR4      '       dQ   V P                  P                   '       g5   \        P                  ! VP"                  P                  RVR,          R7       \        VR4      '       d{   \        P                  ! VP$                  P                  RW P                  P&                  R	,          ,          R7       \        P(                  ! VP$                  P*                  4       R# R# \	        V\,        4      '       du   \        VR4      '       da   \        P                  ! VP.                  P                  RVR,          R7       \        P(                  ! VP.                  P*                  4       R# R# \	        V\0        4      '       Ed_   \        P                  ! VP2                  P                  RW P                  P&                  R	,          ,          R7       \        VP2                  R4      '       dC   VP2                  P*                  e+   \        P(                  ! VP2                  P*                  4       \        P                  ! VP4                  P                  RW P                  P&                  R	,          ,          R7       \        VP4                  R4      '       dG   VP4                  P*                  e-   \        P(                  ! VP4                  P*                  4       R# R# R# \	        V\6        4      '       Ed_   \        P                  ! VP8                  P                  RW P                  P&                  R	,          ,          R7       \        VP8                  R4      '       dC   VP8                  P*                  e+   \        P(                  ! VP8                  P*                  4       \        P                  ! VP:                  P                  RW P                  P<                  R	,          ,          R7       \        VP:                  R4      '       dG   VP:                  P*                  e-   \        P(                  ! VP:                  P*                  4       R# R# R# \	        V\>        4      '       Ed   \        P                  ! VP@                  P                  RW P                  P&                  R	,          ,          R7       \        VP@                  R4      '       dC   VP@                  P*                  e+   \        P(                  ! VP@                  P*                  4       \        P                  ! VPB                  P                  RW P                  P&                  R	,          ,          R7       \        VPB                  R4      '       dC   VPB                  P*                  e+   \        P(                  ! VPB                  P*                  4       \        P                  ! VP:                  P                  RW P                  P<                  R	,          ,          R7       \        VP:                  R4      '       dG   VP:                  P*                  e-   \        P(                  ! VP:                  P*                  4       R# R# R# \	        V\D        4      '       Ed‰   V P                  P&                  pV P                  PF                  pV P                  PH                  p\        P                  ! VPJ                  P                  RW#V,          R	,          ,          R7       \        P                  ! VPL                  P                  RW#R	,          ,          R7       \        P                  ! VPN                  P                  RW#R	,          ,          R7       \        P                  ! VPP                  P                  RW%V,          R	,          ,          R7       VPR                  '       d=   \        P                  ! VPT                  P                  RW#R	,          ,          R7       R# R# R# )
zInitialize the weightsr­   ré   )r\   ÚstdÚlm_headÚ
qa_outputsÚ
classifierrx   Nr?   )+rL   Ú_init_weightsrs   Úinitializer_factorr†   rJ   ÚinitÚ	constant_rP   ÚMT5ModelÚMT5ForConditionalGenerationÚMT5EncoderModelÚMT5ForQuestionAnsweringÚnormal_ÚsharedÚhasattrÚtie_word_embeddingsre  rf  rz   Úzeros_rx   ÚMT5ForTokenClassificationrg  rE  rI  rL  rp   r|   r}   r{   r‹   r�   r�   r¥   r²   r´   r¹   rº   r»   r¼   r¯   r¾   )rR   r(   Úfactorrz   r³   rµ   rU   s   &&    €r6   rh  Ú MT5PreTrainedModel._init_weights=  sd  ø€ ô 	‰Ñ˜fÔ%Ø—‘×/Ñ/ˆÜ�fœl×+Ò+Ü�NŠN˜6Ÿ=™=¨&°3­,Ö7ÜØÜÔ2´OÔE\Ð]÷
ó 
ô �LŠL˜Ÿ™×-Ñ-°C¸VÀc½\ÕJÜ�v˜y×)Ò)°$·+±+×2Q×2QÐ2QÜ—’˜VŸ^™^×2Ñ2¸À&È3Å,ÕOÜ�v˜|×,Ò,Ü—’˜V×.Ñ.×5Ñ5¸CÀV×P[ÑP[×PcÑPcÐhlÕOlÕEmÕnÜ—’˜F×-Ñ-×2Ñ2Ö3ñ -ô ˜Ô 9×:Ò:Ü�v˜|×,Ò,Ü—’˜V×.Ñ.×5Ñ5¸CÀVÈcÅ\ÕRÜ—’˜F×-Ñ-×2Ñ2Ö3ñ -ô ˜Ô 5×6Ó6Ü�LŠL˜Ÿ™×,Ñ,°3¸FÇ{Á{×GZÑGZÐ_cÕFcÕ<dÕeÜ�v—|‘| V×,Ò,°·±×1BÑ1BÒ1NÜ—’˜FŸL™L×-Ñ-Ô.Ü�LŠL˜Ÿ™×/Ñ/°c¸vÏ+É+×J]ÑJ]ÐbfÕIfÕ?gÕhÜ�v—‘¨×/Ò/°F·O±O×4HÑ4HÒ4TÜ—’˜FŸO™O×0Ñ0Ö1ñ 5UÑ/ä˜Ô 0×1Ó1Ü�LŠL˜Ÿ™×)Ñ)°¸ÇKÁK×DWÑDWÐ\`ÕC`Õ9aÕbÜ�v—y‘y &×)Ò)¨f¯i©i¯n©nÒ.HÜ—’˜FŸI™IŸN™NÔ+Ü�LŠL˜Ÿ™×)Ñ)°¸ÇKÁK×DTÑDTÐY]ÕC]Õ9^Õ_Ü�v—y‘y &×)Ò)¨f¯i©i¯n©nÒ.HÜ—’˜FŸI™IŸN™NÖ+ñ /IÑ)ä˜Ô 5×6Ó6Ü�LŠL˜Ÿ™×+Ñ+°#¸6ÇkÁk×FYÑFYÐ^bÕEbÕ;cÕdÜ�v—{‘{ F×+Ò+°·±×0@Ñ0@Ò0LÜ—’˜FŸK™K×,Ñ,Ô-Ü�LŠL˜Ÿ™×+Ñ+°#¸6ÇkÁk×FYÑFYÐ^bÕEbÕ;cÕdÜ�v—{‘{ F×+Ò+°·±×0@Ñ0@Ò0LÜ—’˜FŸK™K×,Ñ,Ô-Ü�LŠL˜Ÿ™×)Ñ)°¸ÇKÁK×DTÑDTÐY]ÕC]Õ9^Õ_Ü�v—y‘y &×)Ò)¨f¯i©i¯n©nÒ.HÜ—’˜FŸI™IŸN™NÖ+ñ /IÑ)ä˜¤×-Ó-Ø—k‘k×)Ñ)ˆGØ!%§¡×!1Ñ!1ÐØ—k‘k×+Ñ+ˆGÜ�LŠL˜Ÿ™Ÿ™¨s¸ÐM_ÕC_ÐdhÕBhÕ8iÕjÜ�LŠL˜Ÿ™Ÿ™¨s¸È4Å-Õ8PÕQÜ�LŠL˜Ÿ™Ÿ™¨s¸È4Å-Õ8PÕQÜ�LŠL˜Ÿ™Ÿ™¨s¸ÐM_ÕC_ÐdhÕBhÕ8iÕjØ×1×1Ð1Ü—’˜V×;Ñ;×BÑBÈÐRXÐimÕ\mÕRn×oñ 2ñ .r8   c                ó>  € V P                   P                  pV P                   P                  pVf   \        R4      hVP	                  VP
                  4      pVRR R13,          P                  4       VR&   W$R&   Vf   \        R4      hVP                  VR8H  V4       V# )NzŒself.model.config.decoder_start_token_id has to be defined. In MT5 it is usually set to the pad_token_id. See MT5 docs for more information..z1self.model.config.pad_token_id has to be defined.r>   ).:rØ   NN).r×   éœÿÿÿ)rs   Údecoder_start_token_idÚpad_token_idÚ
ValueErrorÚ	new_zerosrë   rí   Úmasked_fill_)rR   r]  rz  r{  Úshifted_input_idss   &&   r6   Ú_shift_rightÚMT5PreTrainedModel._shift_rightu  s§   € Ø!%§¡×!CÑ!CÐØ—{‘{×/Ñ/ˆà!Ò)Üð5óð ð
 &×/Ñ/°	·±Ó@ÐØ%.¨s°C°R°C¨xÕ%8×%>Ñ%>Ó%@Ð˜'Ñ"Ø$:˜&Ñ!àÒÜÐPÓQÐQà×&Ñ&Ð'8¸DÑ'@À,ÔOà Ð r8   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rr   r$   )r5   rn   s   "€r6   r7   ÚMT5PreTrainedModel.__annotate__  s   ø‡ ‚ ñ Ñò r8   © r>   )rf   rg   rh   ri   Úbase_model_prefixÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_keep_in_fp32_modulesÚ_supports_flash_attnÚ_supports_flex_attnÚ_supports_sdpaÚ_can_compile_fullgraphr"   r+  r  r   Ú_can_record_outputsÚpropertyra  r2   Úno_gradrh  r€  Ú__annotate_func__rj   rk   rl   rm   s   @@r6   rV  rV    sª   ù‡ € ð &ÐØ&*Ð#à#˜ÐØ!˜FÐð !ÐØÐØ€NØ!Ðð 	™¨¸Ô:Ø‘nÐ%:À"ÔEØ™NÐ+AÈÔLðÐð ñó ðð ‡]‚]ƒ_ô5pó ð5pòn!÷s … r8   rV  c                   ól   a a€ ] tR tRt oV 3R ltR t]]]RV3R lR ll4       4       4       t	Rt
VtV ;t# )ÚMT5StackiŒ  c                ó"  <€ \         SV `  V4       \        P                  ! VP                  VP
                  4      V n        VP                  V n        \        P                  ! \        VP                  4       Uu. uF  p\        V\        V^ 8H  4      VR7      NK  	  up4      V n        \        VP
                  VP                  R7      V n        \        P"                  ! VP$                  4      V n        V P)                  4        RV n        R# u upi )r×   r/  r›   FN)rL   rM   r   r½   Ú
vocab_sizerz   Úembed_tokensr®   r0  ÚrangeÚ
num_layersr+  rª   ÚblockrJ   rž   Úfinal_layer_normr~   r   r.   Ú	post_initr¿   )rR   rs   ÚirU   s   && €r6   rM   ÚMT5Stack.__init__�  sÈ   ø€ Ü‰Ñ˜Ô äŸLšL¨×):Ñ):¸F¿N¹NÓKˆÔØ ×+Ñ+ˆŒä—]’]Ü^cÐdj×duÑduÔ^vÓwÑ^vÐYZŒX�f¼$¸qÀA¹v»,ÐRS×TÑ^vÑwó
ˆŒ
ô !-¨V¯^©^À×AZÑAZÔ [ˆÔÜ—z’z &×"5Ñ"5Ó6ˆŒð 	�‰ÔØ&+ˆÖ#ùò xs   Á9#Dc                ó   € Wn         R # r…   )r•  ©rR   Únew_embeddingss   &&r6   Úset_input_embeddingsÚMT5Stack.set_input_embeddings�  s   € Ø*Ör8   c                ó0   <€ V ^8„  d   QhRS[ S[,          /# ræ   rç   )r5   rn   s   "€r6   r7   ÚMT5Stack.__annotate__£  s    ø€ ÷ W
ñ W
ñ Ñ+Õ,ñW
r8   c           	     ó<  € VR J VR J,          '       d   \        R4      hVf   V P                  V4      pVRJ d"   V P                  '       g   \        RV  R24      hV P                  '       du   V'       dl   Vfh   V P                  P                  '       d6   \        \        V P                  R7      \        V P                  R7      4      pM+\        V P                  R7      pMV P                  '       g   R pV P                  P                  '       d=   \        V P                  TT\        V\
        4      '       d   VP                  MTR7      pM\        V P                  VVR7      pR p	V P                  '       d   Ve   \        V P                  VVVR7      p	R p
R pV P                  V4      pV P                   F4  pV! VVV
VV	V3R	V/VB w  rÎpTp
V P                  '       g   K,  Vf   K2  TpK6  	  V P                  V4      pV P                  V4      p\        VVR
7      # )Nz:You must specify exactly one of input_ids or inputs_embedsTz)`use_cache` can only be set to `True` if z is used as a decoder)rs   )rs   Úinputs_embedsr,   rý   )rs   r¥  r,   )rs   r¥  r,   r;  rý   )Úlast_hidden_staterý   )r|  r•  r®   rs   Úis_encoder_decoderr   r
   r   r†   rò   r   r.   r˜  r™  r   )rR   r]  r,   r;  r<  r¥  rý   Ú	use_cacher0   Úencoder_extended_attention_maskr/   r=  ra   Úlayer_moduleÚself_attention_position_biasÚcross_attention_position_biass   &&&&&&&&,       r6   rc   ÚMT5Stack.forward   s  € ð ˜Ð -°tÐ";×<Ô<ÜÐYÓZÐZàÒ Ø ×-Ñ-¨iÓ8ˆMà˜ÓØ—?—?�?Ü Ð#LÈTÈFÐRgÐ!hÓiÐià�?�?ˆ?ß˜_Ò4Ø—;‘;×1×1Ð1Ü&9Ü$¨D¯K©KÔ8¼,ÈdÏkÉkÔ:Zó'‘Oô '3¸$¿+¹+Ô&F�OøØ——�ð #ˆOà�;‰;×!×!Ð!Ü/Ø—{‘{Ø+Ø-ä˜oÔ/B×CÒCð !0× DÒ Dà$ô‰Nô 7Ø—{‘{Ø+Ø-ôˆNð +/Ð'Ø�?�?ˆ?Ð4Ò@Ü.GØ—{‘{Ø+Ø5Ø&;ô	/Ð+ð ˆØ(,Ð%àŸ™ ]Ó3ˆà ŸJœJˆLÙYeØØØØ%Ø/Ø-ñ	Zð !0ð	Zð ñ	ZÑVˆMÐ9Vð 9ˆMØ��ŠÐ#8Ô#DØ0MÒ-ñ 'ð" ×-Ñ-¨mÓ<ˆØŸ™ ]Ó3ˆä8Ø+Ø+ô
ð 	
r8   )r˜  r.   r•  r™  r¿   r®   )NNNNNNN)rf   rg   rh   ri   rM   r   r!   r#   r   rc   rj   rk   rl   rm   s   @@r6   r’  r’  Œ  sA   ù‡ € õ,ò +ð  ØØ÷W
ñ W
ó ó ó  ÷W
ð W
r8   r’  c                   óš   a a€ ] tR tRt oRtRtR.tRRRR/tV3R lV 3R	 lltR
 t	R t
]]RV3R lR ll4       4       tV3R ltRtVtV ;t# )rl  iý  aG  
Examples:

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

>>> model = MT5Model.from_pretrained("google/mt5-small")
>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
>>> summary = "Weiter Verhandlung in Syrien."
>>> inputs = tokenizer(article, return_tensors="pt")
>>> labels = tokenizer(text_target=summary, return_tensors="pt")

>>> outputs = model(input_ids=inputs["input_ids"], decoder_input_ids=labels["input_ids"])
>>> hidden_states = outputs.last_hidden_state
```Úmt5úFdecoder.block.0.layer.1.EncDecAttention.relative_attention_bias.weightúencoder.embed_tokens.weightúshared.weightúdecoder.embed_tokens.weightc                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   ÚMT5Model.__annotate__  s   ø€ ÷ ñ ™yñ r8   c                óŠ  <€ \         SV `  V4       \        P                  ! VP                  VP
                  4      V n        \        P                  ! V4      pR Vn	        R Vn
        \        V4      V n        \        P                  ! V4      pRVn	        VP                  Vn        \        V4      V n        V P!                  4        R# ©FTN)rL   rM   r   r½   r”  rz   rq  ÚcopyÚdeepcopyr®   r¨  r’  ÚencoderÚnum_decoder_layersr—  Údecoderrš  ©rR   rs   Úencoder_configÚdecoder_configrU   s   &&  €r6   rM   ÚMT5Model.__init__  s’   ø€ Ü‰Ñ˜Ô Ü—l’l 6×#4Ñ#4°f·n±nÓEˆŒäŸš vÓ.ˆØ$)ˆÔ!Ø#(ˆÔ Ü Ó/ˆŒäŸš vÓ.ˆØ$(ˆÔ!Ø$*×$=Ñ$=ˆÔ!Ü Ó/ˆŒð 	�‰Ör8   c                ó   € V P                   # r…   ©rq  ©rR   s   &r6   Úget_input_embeddingsÚMT5Model.get_input_embeddings+  ó   € Ø�{‰{Ðr8   c                ó~   € Wn         V P                  P                  V4       V P                  P                  V4       R # r…   ©rq  rº  r   r¼  rž  s   &&r6   r   ÚMT5Model.set_input_embeddings/  ó+   € Ø$ŒØ�‰×)Ñ)¨.Ô9Ø�‰×)Ñ)¨.Ö9r8   c                ó–  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[S[ P                  ,          ,          R,          RS[R,          RS[ P                  R,          R	S[ P                  R,          R
S[R,          RS[S[	,          RS[
/# )r'   r]  Nr,   r\  r^  Úencoder_outputsrý   r¥  Údecoder_inputs_embedsr¨  r0   rO  )r2   Ú
LongTensorÚFloatTensorÚ
BoolTensorÚtupler	   r3   rª   r   r   r   )r5   rn   s   "€r6   r7   rµ  7  sç   ø€ ÷ d
ñ d
á×#Ñ# dÕ*ðd
ñ ×)Ñ)¨DÕ0ðd
ñ !×+Ñ+¨dÕ2ð	d
ñ
 !&× 0Ñ 0°4Õ 7ðd
ñ ™u¡U×%6Ñ%6Õ7Õ8¸4Õ?ðd
ñ  �ðd
ñ —|‘| dÕ*ðd
ñ  %Ÿ|™|¨dÕ2ðd
ñ ˜$•;ðd
ñ Ñ+Õ,ðd
ñ 
ñd
r8   c
                ó  € Vf   V P                   ! RRVRVRV/V
B pM]\        V\        4      '       gH   \        V^ ,          \        V4      ^8”  d
   V^,          MR\        V4      ^8”  d
   V^,          MRR7      pV^ ,          pV P                  ! RRVRVRVRVRVRVR	V	/V
B p\        VP                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  R
7      # )aD	  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. MT5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    [What are input IDs?](../glossary#input-ids)

    To know more on how to prepare `input_ids` for pretraining take a look a [MT5 Training](./mt5#training).
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    MT5 uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If `past_key_values`
    is used, optionally only the last `decoder_input_ids` have to be input (see `past_key_values`).

    To know more on how to prepare `decoder_input_ids` for pretraining take a look at [MT5
    Training](./mt5#training).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.

Example:

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

>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> model = MT5Model.from_pretrained("google/mt5-small")

>>> input_ids = tokenizer(
...     "Studies have been shown that owning a dog is good for you", return_tensors="pt"
... ).input_ids  # Batch size 1
>>> decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids  # Batch size 1

>>> # preprocess: Prepend decoder_input_ids with start token which is pad token for MT5Model.
>>> # This is not needed for torch's MT5ForConditionalGeneration as it does this internally using labels arg.
>>> decoder_input_ids = model._shift_right(decoder_input_ids)

>>> # forward pass
>>> outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
>>> last_hidden_states = outputs.last_hidden_state
```Nr]  r,   r¥  ©r¦  ra   rY  rý   r;  r<  r¨  )r¦  rý   Údecoder_hidden_statesÚdecoder_attentionsrZ  Úencoder_last_hidden_stater;  Úencoder_attentionsr„  )rº  r†   r   Úlenr¼  r   r¦  rý   ra   rY  rZ  )rR   r]  r,   r\  r^  rÌ  rý   r¥  rÍ  r¨  r0   ra   Údecoder_outputss   &&&&&&&&&&,  r6   rc   ÚMT5Model.forward4  sJ  € ðD Ò"Ø"Ÿlšlñ Ø#ðà-ðð ,ðð ñ	‰Oô ˜O¬_×=Ò=Ü-Ø"1°!Õ"4Ü47¸Ó4HÈ1Ô4L˜o¨aÖ0ÐRVÜ14°_Ó1EÈÔ1I˜?¨1Ö-ÈtôˆOð (¨Õ*ˆð Ÿ,š,ñ 	
Ø'ð	
à1ð	
ð 0ð	
ð ,ð		
ð
 #0ð	
ð $2ð	
ð  ð	
ð ñ	
ˆô "Ø-×?Ñ?Ø+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô	
ð 		
r8   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rr   r$   )r5   rn   s   "€r6   r7   rµ  ý  s   ø‡ ‚ ñ( Ñò) r8   )r¼  rº  rq  ©	NNNNNNNNN)rf   rg   rh   ri   rT  Ú
model_typeÚ"_keys_to_ignore_on_load_unexpectedÚ_tied_weights_keysrM   rÄ  r   r    r   rc   r�  rj   rk   rl   rm   s   @@r6   rl  rl  ý  sl   ù‡ € ñð" €Jà*rÐ)sÐ&à% Ø% ðÐ÷ó ò$ò:ð
 Ø÷d
ñ d
ó ó ðd
÷u … r8   rl  z;
    MT5 Model with a `language modeling` head on top.
    )Úcustom_introc                   ó°   a a€ ] tR tRt oRtRtR.tRRRRRR/tV3R	 lV 3R
 lltR t	R t
]]RV3R lR ll4       4       tV3R lR ltV3R ltRtVtV ;t# )rm  iž  aï  
Examples:

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

>>> model = MT5ForConditionalGeneration.from_pretrained("google/mt5-small")
>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
>>> summary = "Weiter Verhandlung in Syrien."
>>> inputs = tokenizer(article, text_target=summary, return_tensors="pt")

>>> outputs = model(**inputs)
>>> loss = outputs.loss
```r¯  r°  r±  r²  r³  zlm_head.weightc                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú(MT5ForConditionalGeneration.__annotate__¾  s   ø€ ÷ ñ ™yñ r8   c                ó  <€ \         SV `  V4       VP                  V n        \        P
                  ! VP                  VP                  4      V n        \        P                  ! V4      pR Vn
        R Vn        \        V4      V n        \        P                  ! V4      pRVn
        VP                  Vn        \        V4      V n        \        P"                  ! VP                  VP                  R R7      V n        V P'                  4        R# )FTrw   N)rL   rM   rz   Ú	model_dimr   r½   r”  rq  r¸  r¹  r®   r¨  r’  rº  r»  r—  r¼  ry   re  rš  r½  s   &&  €r6   rM   Ú$MT5ForConditionalGeneration.__init__¾  s»   ø€ Ü‰Ñ˜Ô ØŸ™ˆŒä—l’l 6×#4Ñ#4°f·n±nÓEˆŒäŸš vÓ.ˆØ$)ˆÔ!Ø#(ˆÔ Ü Ó/ˆŒäŸš vÓ.ˆØ$(ˆÔ!Ø$*×$=Ñ$=ˆÔ!Ü Ó/ˆŒä—y’y §¡°×1BÑ1BÈÔOˆŒð 	�‰Ör8   c                ó   € V P                   # r…   rÂ  rÃ  s   &r6   rÄ  Ú0MT5ForConditionalGeneration.get_input_embeddingsÓ  rÆ  r8   c                ó~   € Wn         V P                  P                  V4       V P                  P                  V4       R # r…   rÈ  rž  s   &&r6   r   Ú0MT5ForConditionalGeneration.set_input_embeddingsÖ  rÊ  r8   c                ó¾  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[S[ P
                  ,          ,          R,          RS[R,          RS[ P                  R,          R	S[ P                  R,          R
S[ P                  R,          RS[R,          RS[S[	,          RS[
/# )r'   r]  Nr,   r\  r^  rÌ  rý   r¥  rÍ  Úlabelsr¨  r0   rO  )r2   rÎ  rÏ  rÐ  rÑ  r3   r	   rª   r   r   r   )r5   rn   s   "€r6   r7   rã  Ý  sÿ   ø€ ÷ }
ñ }
á×#Ñ# dÕ*ð}
ñ ×)Ñ)¨DÕ0ð}
ñ !×+Ñ+¨dÕ2ð	}
ñ
 !&× 0Ñ 0°4Õ 7ð}
ñ ™u¡U§\¡\Õ2Õ3°dÕ:ð}
ñ  �ð}
ñ ×(Ñ(¨4Õ/ð}
ñ  %×0Ñ0°4Õ7ð}
ñ × Ñ  4Õ'ð}
ñ ˜$•;ð}
ñ Ñ+Õ,ð}
ñ 
ñ}
r8   c                ó2  € Vf   V P                   ! RRVRVRV/VB pM]\        V\        4      '       gH   \        V^ ,          \        V4      ^8”  d
   V^,          MR\        V4      ^8”  d
   V^,          MRR7      pV^ ,          pV	e   Vf   Vf   V P	                  V	4      pV P
                  ! RRVRVRVRVRVRVR	V
/VB pV^ ,          pV P                  V4      pRpV	e_   \        RR
7      pV	P                  VP                  4      p	V! VP                  RVP                  R4      4      V	P                  R4      4      p\        VVVP                  VP                  VP                  VP                   VP"                  VP                  VP                  R7	      # )aµ
  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. MT5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    [What are input IDs?](../glossary#input-ids)

    To know more on how to prepare `input_ids` for pretraining take a look a [MT5 Training](./mt5#training).
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    MT5 uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If `past_key_values`
    is used, optionally only the last `decoder_input_ids` have to be input (see `past_key_values`).

    To know more on how to prepare `decoder_input_ids` for pretraining take a look at [MT5
    Training](./mt5#training).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels for computing the sequence classification/regression loss. Indices should be in `[-100, 0, ...,
    config.vocab_size - 1]`. All labels set to `-100` are ignored (masked), the loss is only computed for
    labels in `[0, ..., config.vocab_size]`

Examples:

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

>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> model = MT5ForConditionalGeneration.from_pretrained("google/mt5-small")

>>> # training
>>> input_ids = tokenizer("The <extra_id_0> walks in <extra_id_1> park", return_tensors="pt").input_ids
>>> labels = tokenizer("<extra_id_0> cute dog <extra_id_1> the <extra_id_2>", return_tensors="pt").input_ids
>>> outputs = model(input_ids=input_ids, labels=labels)
>>> loss = outputs.loss
>>> logits = outputs.logits

>>> # inference
>>> input_ids = tokenizer(
...     "summarize: studies have shown that owning a dog is good for you", return_tensors="pt"
... ).input_ids  # Batch size 1
>>> outputs = model.generate(input_ids)
>>> print(tokenizer.decode(outputs[0], skip_special_tokens=True))
>>> # studies have shown that owning a dog is good for you.
```Nr]  r,   r¥  rÓ  rý   r;  r<  r¨  ©Úignore_index©	ÚlossÚlogitsrý   rÔ  rÕ  rZ  rÖ  r;  r×  r„  ry  r>   )rº  r†   r   rØ  r€  r¼  re  r   rY   rÕ   rî   r@   r   rý   ra   rY  rZ  r¦  )rR   r]  r,   r\  r^  rÌ  rý   r¥  rÍ  rì  r¨  r0   ra   rÙ  Úsequence_outputÚ	lm_logitsrñ  Úloss_fcts   &&&&&&&&&&&,      r6   rc   Ú#MT5ForConditionalGeneration.forwardÛ  sÔ  € ðR Ò"à"Ÿlšlñ Ø#ðà-ðð ,ðð ñ	‰Oô ˜O¬_×=Ò=Ü-Ø"1°!Õ"4Ü47¸Ó4HÈ1Ô4L˜o¨aÖ0ÐRVÜ14°_Ó1EÈÔ1I˜?¨1Ö-ÈtôˆOð (¨Õ*ˆàÒÐ"3Ò";Ð@UÒ@]à $× 1Ñ 1°&Ó 9Ðð Ÿ,š,ñ 	
Ø'ð	
à1ð	
ð 0ð	
ð ,ð		
ð
 #0ð	
ð $2ð	
ð  ð	
ð ñ	
ˆð *¨!Õ,ˆà—L‘L Ó1ˆ	àˆØÒÜ'°TÔ:ˆHà—Y‘Y˜y×/Ñ/Ó0ˆFÙ˜IŸN™N¨2¨y¯~©~¸bÓ/AÓBÀFÇKÁKÐPRÃOÓTˆDäØØØ+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô

ð 
	
r8   c                ó4   <€ V ^8„  d   QhRS[ P                  /# )r'   rì  rP  )r5   rn   s   "€r6   r7   rã  ]  s   ø€ ÷ )ñ )¹E¿L¹Lñ )r8   c                ó$   € V P                  V4      # r…   )r€  )rR   rì  s   &&r6   Ú%prepare_decoder_input_ids_from_labelsÚAMT5ForConditionalGeneration.prepare_decoder_input_ids_from_labels]  s   € Ø× Ñ  Ó(Ð(r8   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rr   r$   )r5   rn   s   "€r6   r7   rã  ž  s   ø‡ ‚ ñ. Ñò/ r8   )r¼  rº  re  rå  rq  ©
NNNNNNNNNN)rf   rg   rh   ri   rT  rÝ  rÞ  rß  rM   rÄ  r   r    r   rc   rù  r�  rj   rk   rl   rm   s   @@r6   rm  rm  ž  s|   ù‡ € ñð  €Jà*rÐ)sÐ&à% Ø% Ø˜/ðÐ÷ó ò*ò:ð
 Ø÷}
ñ }
ó ó ð}
÷@)ð )÷ … r8   rm  c                   ó�   a a€ ] tR tRt oRtRtRR/tV3R lV 3R lltR tR	 t	]
]RV3R
 lR ll4       4       tV3R ltRtVtV ;t# )rn  ia  a¶  
Examples:

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

>>> model = MT5EncoderModel.from_pretrained("google/mt5-small")
>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
>>> input_ids = tokenizer(article, return_tensors="pt").input_ids
>>> outputs = model(input_ids)
>>> hidden_state = outputs.last_hidden_state
```r¯  r±  r²  c                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   ÚMT5EncoderModel.__annotate__x  s   ø€ ÷ 
ñ 
™yñ 
r8   c                óæ   <€ \         SV `  V4       \        P                  ! VP                  VP
                  4      V n        TpR Vn        R Vn        \        V4      V n
        V P                  4        R# r  )rL   rM   r   r½   r”  rz   rq  r¨  r§  r’  rº  rš  )rR   rs   r¾  rU   s   && €r6   rM   ÚMT5EncoderModel.__init__x  sY   ø€ Ü‰Ñ˜Ô Ü—l’l 6×#4Ñ#4°f·n±nÓEˆŒàˆØ#(ˆÔ Ø,1ˆÔ)Ü Ó/ˆŒð 	�‰Ör8   c                ó   € V P                   # r…   rÂ  rÃ  s   &r6   rÄ  Ú$MT5EncoderModel.get_input_embeddings…  rÆ  r8   c                óH   € Wn         V P                  P                  V4       R # r…   )rq  rº  r   rž  s   &&r6   r   Ú$MT5EncoderModel.set_input_embeddings‰  s   € Ø$ŒØ�‰×)Ñ)¨.Ö9r8   c          
      ó®   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r'   r]  Nr,   r¥  r0   rO  )r2   rÎ  rÏ  r   r   r   )r5   rn   s   "€r6   r7   rÿ  �  sd   ø€ ÷ %ñ %á×#Ñ# dÕ*ð%ñ ×)Ñ)¨DÕ0ð%ñ ×(Ñ(¨4Õ/ð	%ñ
 Ñ+Õ,ð%ñ 
ñ%r8   c           	     ó6   € V P                   ! RRVRVRV/VB pV# )aÂ  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. MT5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    To know more on how to prepare `input_ids` for pretraining take a look a [MT5 Training](./mt5#training).

Example:

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

>>> tokenizer = AutoTokenizer.from_pretrained("google/mt5-small")
>>> model = MT5EncoderModel.from_pretrained("google/mt5-small")
>>> input_ids = tokenizer(
...     "Studies have been shown that owning a dog is good for you", return_tensors="pt"
... ).input_ids  # Batch size 1
>>> outputs = model(input_ids=input_ids)
>>> last_hidden_states = outputs.last_hidden_state
```r]  r,   r¥  r„  )rº  )rR   r]  r,   r¥  r0   rÌ  s   &&&&, r6   rc   ÚMT5EncoderModel.forward�  s?   € ðB ,0¯<ª<ñ ,
Øð,
à)ð,
ð (ð,
ð ñ	,
ˆð Ðr8   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # rr   r$   )r5   rn   s   "€r6   r7   rÿ  a  s   ø‡ ‚ ñ" Ñò# r8   )rº  rq  r  )rf   rg   rh   ri   rT  rÝ  rß  rM   rÄ  r   r    r   rc   r�  rj   rk   rl   rm   s   @@r6   rn  rn  a  s]   ù‡ € ñð €Jð 	& ðÐ÷

ó 
òò:ð Ø÷%ñ %ó ó ð%÷_ … r8   rn  z„
    MT5 model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE
    tasks.
    c                   ón   a a€ ] tR tRt oR.tV3R lV 3R llt]]RV3R lR ll4       4       tRt	Vt
V ;t# )	ÚMT5ForSequenceClassificationi¸  r°  c                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú)MT5ForSequenceClassification.__annotate__Â  s   ø€ ÷ ñ ™yñ r8   c                ó†   <€ \         SV `  V4       \        V4      V n        \	        V4      V n        V P                  4        R # r…   )rL   rM   rl  rW  rE  Úclassification_headrš  r‚   s   &&€r6   rM   Ú%MT5ForSequenceClassification.__init__Â  s6   ø€ Ü‰Ñ˜Ô Ü# FÓ+ˆÔÜ#8¸Ó#@ˆÔ ð 	�‰Ör8   c                óš  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[ P                  ,          R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[R,          RS[S[,          RS[/# )r'   r]  Nr,   r\  r^  rÌ  r¥  rÍ  rì  r¨  r0   rO  )	r2   rÎ  r3   ÚlistrÏ  rª   r   r   r   )r5   rn   s   "€r6   r7   r  Í  së   ø€ ÷ }
ñ }
á×#Ñ# dÕ*ð}
ñ Ÿ™ tÕ+ð}
ñ !×+Ñ+¨dÕ2ð	}
ñ
 !&× 0Ñ 0°4Õ 7ð}
ñ ™e×/Ñ/Õ0°4Õ7ð}
ñ ×(Ñ(¨4Õ/ð}
ñ  %×0Ñ0°4Õ7ð}
ñ × Ñ  4Õ'ð}
ñ ˜$•;ð}
ñ Ñ+Õ,ð}
ñ 
)ñ}
r8   c
                óR  € Ve   Rp	Vf'   Ve#   \        RV P                  P                   24      hVf%   Vf!   Vf   \        R4      hV P	                  V4      pV P
                  ! V3RVRVRVRVR	VR
VRV	/V
B pV^ ,          pVP                  V P                  P                  4      P                  VP                  4      p\        \        P                  ! VP                  ^4      4      P                  4       ^8H  R4       VP                   w  rïpWÍR3,          p\        VP                   ^ ,          V,          ^8¬  R4       VP#                  VRV4      R,          pV P%                  V4      pRpVEeÝ   VP                  VP                  4      pV P                  P&                  fª   V P                  P(                  ^8X  d   RV P                  n        M|V P                  P(                  ^8”  dQ   VP*                  \        P,                  8X  g    VP*                  \        P.                  8X  d   RV P                  n        MRV P                  n        V P                  P&                  R8X  dV   \1        4       pV P                  P(                  ^8X  d'   V! VP3                  4       VP3                  4       4      pMšV! VV4      pM�V P                  P&                  R8X  dH   \5        4       pV! VP#                  RV P                  P(                  4      VP#                  R4      4      pM.V P                  P&                  R8X  d   \7        4       pV! VV4      p\9        VVVP:                  VP<                  VP>                  VP@                  VPB                  VPD                  VPF                  R7	      # )aò  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. MT5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    [What are input IDs?](../glossary#input-ids)

    To know more on how to prepare `input_ids` for pretraining take a look a [MT5 Training](./mt5#training).
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    MT5 uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If `past_key_values`
    is used, optionally only the last `decoder_input_ids` have to be input (see `past_key_values`).

    To know more on how to prepare `decoder_input_ids` for pretraining take a look at [MT5
    Training](./mt5#training).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
    config.num_labels - 1]`. If `config.num_labels > 1` a classification loss is computed (Cross-Entropy).
NFz8Passing input embeddings is currently not supported for ú°If no `decoder_input_ids` or `decoder_inputs_embeds` are passed, `input_ids` cannot be `None`. Please pass either `input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`.r,   r\  r^  rÌ  r¥  rÍ  r¨  z7All examples must have the same number of <eos> tokens.rÖ   z3Each example must contain at least one <eos> token.Ú
regressionÚsingle_label_classificationÚmulti_label_classificationrð  r>   )rÖ   r>   rÖ   )$ÚNotImplementedErrorrU   rf   r|  r€  rW  Úeqrs   Úeos_token_idrY   rÕ   r   r2   Úunique_consecutiveÚsumÚnumelrë   rî   r  Úproblem_typerK  r^   rÂ   r©   r   Úsqueezer   r   r   rý   rÔ  rÕ  rZ  rÖ  r;  r×  )rR   r]  r,   r\  r^  rÌ  r¥  rÍ  rì  r¨  r0   Úoutputsró  Úeos_maskÚ
batch_sizer?  rS   ÚselectedÚsentence_representationrò  rñ  rõ  s   &&&&&&&&&&,           r6   rc   Ú$MT5ForSequenceClassification.forwardÊ  sM  € ð^ ÒØˆIàÒ Ò!:Ü%ØJÈ4Ï>É>×KbÑKbÐJcÐdóð ð Ò$Ð)>Ò)FØÒ Ü ðUóð ð
 !%× 1Ñ 1°)Ó <Ðà&*×&6Ò&6Øñ
'
à)ð
'
ð 0ð
'
ð $:ð	
'
ð
 ,ð
'
ð (ð
'
ð #8ð
'
ð  ð
'
ð ñ
'
ˆð " !�*ˆà—<‘< §¡× 8Ñ 8Ó9×<Ñ<¸_×=SÑ=SÓTˆäÜ×$Ò$ X§\¡\°!£_Ó5×;Ñ;Ó=ÀÑBØEô	
ð &5×%:Ñ%:Ñ"ˆ
�{Ø"¨Q ;Õ/ˆÜØ�N‰N˜1Õ Õ+¨qÑ0ØAô	
ð #+§-¡-°
¸BÀÓ"LÈXÕ"VÐØ×)Ñ)Ð*AÓBˆàˆØÓØ—Y‘Y˜vŸ}™}Ó-ˆFØ�{‰{×'Ñ'Ò/Ø—;‘;×)Ñ)¨QÔ.Ø/;�D—K‘KÕ,Ø—[‘[×+Ñ+¨aÔ/°V·\±\ÄUÇZÁZÔ5OÐSY×S_ÑS_Ôch×clÑclÔSlØ/L�D—K‘KÕ,à/K�D—K‘KÔ,à�{‰{×'Ñ'¨<Ô7Ü"›9�Ø—;‘;×)Ñ)¨QÔ.Ù# F§N¡NÓ$4°f·n±nÓ6FÓG‘Dá# F¨FÓ3‘DØ—‘×)Ñ)Ð-JÔJÜ+Ó-�Ù §¡¨B°·±×0FÑ0FÓ GÈÏÉÐUWËÓY‘Ø—‘×)Ñ)Ð-IÔIÜ,Ó.�Ù ¨Ó/�ä.ØØØ#×3Ñ3Ø")×"?Ñ"?Ø&×9Ñ9Ø$×5Ñ5Ø&-×&GÑ&GØ")×"?Ñ"?Ø&×9Ñ9ô

ð 
	
r8   )r  rW  rÜ  )rf   rg   rh   ri   rÞ  rM   r    r   rc   rj   rk   rl   rm   s   @@r6   r  r  ¸  sE   ù‡ € ð +sÐ)sÐ&÷ó ð Ø÷}
ñ }
ó ó ÷}
ð }
r8   r  c                   óh   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4       4       tRtVt	V ;t
# )ru  iM  c                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú&MT5ForTokenClassification.__annotate__P  s   ø€ ÷ 	ñ 	™yñ 	r8   c                ó2  <€ \         SV `  V4       VP                  V n        \        V4      V n        \
        P                  ! VP                  4      V n        \
        P                  ! VP                  VP                  4      V n        V P                  4        R # r…   )rL   rM   rK  rn  rW  r   r~   rJ  r.   ry   rS   rg  rš  r‚   s   &&€r6   rM   Ú"MT5ForTokenClassification.__init__P  sj   ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒä*¨6Ó2ˆÔÜ—z’z &×";Ñ";Ó<ˆŒÜŸ)š) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Ör8   c                óÖ   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r'   r]  Nr,   r¥  rì  r0   rO  )r2   r3   r   r   r   )r5   rn   s   "€r6   r7   r(  ^  sq   ø€ ÷ +
ñ +
á—<‘< $Õ&ð+
ñ Ÿ™ tÕ+ð+
ñ —|‘| dÕ*ð	+
ñ
 —‘˜tÕ#ð+
ñ Ñ+Õ,ð+
ñ 
ñ+
r8   c                óP  € V P                   ! V3RVRV/VB pV^ ,          pV P                  V4      pV P                  V4      pRp	Ve=   \        4       p
V
! VP	                  RV P
                  4      VP	                  R4      4      p	\        V	VVP                  VP                  R7      # )aî  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. MT5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    [What are input IDs?](../glossary#input-ids)

    To know more on how to prepare `input_ids` for pretraining take a look a [MT5 Training](./t5#training).
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
r,   r¥  N)rñ  rò  ra   rY  r>   )	rW  r.   rg  r   rî   rK  r   ra   rY  )rR   r]  r,   r¥  rì  r0   r   ra   rò  rñ  rõ  s   &&&&&,     r6   rc   Ú!MT5ForTokenClassification.forward[  sµ   € ð2 $(×#3Ò#3Øñ$
à)ð$
ð (ð$
ð ñ	$
ˆð   �
ˆØŸ™ ]Ó3ˆØ—‘ Ó/ˆàˆØÒÜ'Ó)ˆHÙ˜FŸK™K¨¨D¯O©OÓ<¸f¿k¹kÈ"»oÓNˆDä$ØØØ!×/Ñ/Ø×)Ñ)ô	
ð 	
r8   )rg  r.   rK  rW  r  )rf   rg   rh   ri   rM   r    r   rc   rj   rk   rl   rm   s   @@r6   ru  ru  M  s5   ù‡ € ÷	ó 	ð Ø÷+
ñ +
ó ó ÷+
ð +
r8   ru  c                   ó†   a a€ ] tR tRt oR.tRRRR/tV3R lV 3R lltR tR	 t]	]
RV3R
 lR ll4       4       tRtVtV ;t# )ro  iŒ  r°  r±  r²  r³  c                ó    <€ V ^8„  d   QhRS[ /# rr   r$   )r5   rn   s   "€r6   r7   Ú$MT5ForQuestionAnswering.__annotate__•  s   ø€ ÷ ñ ™yñ r8   c                ó.  <€ \         SV `  V4       VP                  V n        \        P
                  ! VP                  VP                  4      V n        \        P                  ! V4      pR Vn
        R Vn        \        V4      V n        \        P                  ! V4      pRVn
        VP                  Vn        \        V4      V n        VP"                  V n        \        P$                  ! VP&                  VP"                  4      V n        V P+                  4        R# r·  )rL   rM   rz   rå  r   r½   r”  rq  r¸  r¹  r®   r¨  r’  rº  r»  r—  r¼  rK  ry   rS   rf  rš  r½  s   &&  €r6   rM   Ú MT5ForQuestionAnswering.__init__•  sÈ   ø€ Ü‰Ñ˜Ô ØŸ™ˆŒä—l’l 6×#4Ñ#4°f·n±nÓEˆŒäŸš vÓ.ˆØ$)ˆÔ!Ø#(ˆÔ Ü Ó/ˆŒäŸš vÓ.ˆØ$(ˆÔ!Ø$*×$=Ñ$=ˆÔ!Ü Ó/ˆŒà ×+Ñ+ˆŒÜŸ)š) F×$6Ñ$6¸×8IÑ8IÓJˆŒð 	�‰Ör8   c                ó   € V P                   # r…   rÂ  rÃ  s   &r6   rÄ  Ú,MT5ForQuestionAnswering.get_input_embeddings¬  rÆ  r8   c                ó~   € Wn         V P                  P                  V4       V P                  P                  V4       R # r…   rÈ  rž  s   &&r6   r   Ú,MT5ForQuestionAnswering.set_input_embeddings°  rÊ  r8   c                óÒ  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[S[ P
                  ,          ,          R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[ P                  R,          RS[R,          RS[S[,          RS[	/# )r'   r]  Nr,   r\  r^  rÌ  Ústart_positionsÚend_positionsr¥  rÍ  r¨  r0   rO  )
r2   rÎ  rÏ  rÐ  rÑ  r3   rª   r   r   r   )r5   rn   s   "€r6   r7   r0  ¸  s  ø€ ÷ y
ñ y
á×#Ñ# dÕ*ðy
ñ ×)Ñ)¨DÕ0ðy
ñ !×+Ñ+¨dÕ2ð	y
ñ
 !&× 0Ñ 0°4Õ 7ðy
ñ ™u¡U§\¡\Õ2Õ3°dÕ:ðy
ñ ×)Ñ)¨DÕ0ðy
ñ ×'Ñ'¨$Õ.ðy
ñ ×(Ñ(¨4Õ/ðy
ñ  %×0Ñ0°4Õ7ðy
ñ ˜$•;ðy
ñ Ñ+Õ,ðy
ñ 
-ñy
r8   c                ó8  € Ve   Ve   Rp
Vf%   V	f!   Vf   \        R4      hV P                  V4      pVf   V P                  ! RRVRVRV/VB pM]\        V\        4      '       gH   \	        V^ ,          \        V4      ^8”  d
   V^,          MR\        V4      ^8”  d
   V^,          MRR7      pV^ ,          pV P                  ! RRVRVRV	RRR	VR
VRV
/VB pV^ ,          pV P                  V4      pVP                  ^RR7      w  ppVP                  R4      P                  4       pVP                  R4      P                  4       pRpVeø   Veô   \        VP                  4       4      ^8”  d+   VP                  R4      P                  VP                  4      p\        VP                  4       4      ^8”  d+   VP                  R4      P                  VP                  4      pVP                  ^4      pVP                  ^ V4      pVP                  ^ V4      p\        VR7      pV! VV4      pV! VV4      pVV,           ^,          p\!        VVVVP"                  VP$                  VP&                  VP(                  VP*                  VP$                  VP&                  R7
      # )aÚ  
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
    Indices of input sequence tokens in the vocabulary. T5 is a model with relative position embeddings so you
    should be able to pad the inputs on both the right and the left.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for detail.

    [What are input IDs?](../glossary#input-ids)

    To know more on how to prepare `input_ids` for pretraining take a look a [T5 Training](./t5#training).
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    T5 uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If `past_key_values`
    is used, optionally only the last `decoder_input_ids` have to be input (see `past_key_values`).

    To know more on how to prepare `decoder_input_ids` for pretraining take a look at [T5
    Training](./t5#training).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.
NFr  r]  r,   r¥  rÓ  rý   r;  r<  r¨  r:   rî  )
rñ  Ústart_logitsÚ
end_logitsrý   rÔ  rÕ  rZ  rÖ  r;  r×  r„  r>   )r|  r€  rº  r†   r   rØ  r¼  rf  Úsplitr  rE   r@   rY   rÕ   r:  r   r   rý   ra   rY  rZ  r¦  )rR   r]  r,   r\  r^  rÌ  r8  r9  r¥  rÍ  r¨  r0   ra   rÙ  ró  rò  r;  r<  Ú
total_lossÚignored_indexrõ  Ú
start_lossÚend_losss   &&&&&&&&&&&,           r6   rc   ÚMT5ForQuestionAnswering.forwardµ  sÚ  € ðZ Ò&¨=Ò+DØˆIð
 Ò$Ð)>Ò)FØÒ Ü ðUóð ð
 !%× 1Ñ 1°)Ó <Ðð Ò"Ø"Ÿlšlñ Ø#ðà-ðð ,ðð ñ	‰Oô ˜O¬_×=Ò=Ü-Ø"1°!Õ"4Ü47¸Ó4HÈ1Ô4L˜o¨aÖ0ÐRVÜ14°_Ó1EÈÔ1I˜?¨1Ö-ÈtôˆOð (¨Õ*ˆð Ÿ,š,ñ 	
Ø'ð	
à1ð	
ð 0ð	
ð !ð		
ð
 #0ð	
ð $2ð	
ð  ð	
ð ñ	
ˆð *¨!Õ,ˆà—‘ Ó1ˆØ#)§<¡<°°r <Ó#:Ñ ˆ�jØ#×+Ñ+¨BÓ/×:Ñ:Ó<ˆØ×'Ñ'¨Ó+×6Ñ6Ó8ˆ
àˆ
ØÒ&¨=Ò+Dä�?×'Ñ'Ó)Ó*¨QÔ.Ø"1×"9Ñ"9¸"Ó"=×"@Ñ"@À×ATÑATÓ"U�Ü�=×%Ñ%Ó'Ó(¨1Ô,Ø -× 5Ñ 5°bÓ 9× <Ñ <¸Z×=NÑ=NÓ O�à(×-Ñ-¨aÓ0ˆMØ-×3Ñ3°A°}ÓEˆOØ)×/Ñ/°°=ÓAˆMä'°]ÔCˆHÙ! ,°Ó@ˆJÙ 
¨MÓ:ˆHØ$ xÕ/°1Õ4ˆJä2ØØ%Ø!Ø+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô
ð 	
r8   )r¼  rº  rå  rK  rf  rq  rü  )rf   rg   rh   ri   rÞ  rß  rM   rÄ  r   r    r   rc   rj   rk   rl   rm   s   @@r6   ro  ro  Œ  s^   ù‡ € à*rÐ)sÐ&à% Ø% ðÐ÷ó ò.ò:ð
 Ø÷y
ñ y
ó ó ÷y
ð y
r8   ro  )Nré   N)rn  rm  ro  r  ru  rl  rV  )NrT  r¸  rÇ   Úcollections.abcr   r2   r   Útorch.nnr   r   r   Ú r   rj  Úactivationsr   Úcache_utilsr	   r
   r   Ú
generationr   Úmasking_utilsr   r   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   r   r   r   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr   r   r   r   r   r   Úutils.genericr    r!   Úutils.output_capturingr"   r#   Úconfiguration_mt5r%   Ú
get_loggerrf   r·   rH   r1   rJ   rp   r‹   r—   r¥   r  r   r+  rE  rV  r’  rl  rm  rn  r  ru  ro  Ú__all__r„  r8   r6   Ú<module>rT     s  ðñ ã Û Ý $ã Ý ß AÑ Aå &Ý !ß CÑ CÝ )ß JÝ 9÷÷ ñ ÷ GÝ &ß r× rß Iß EÝ (ð 
×	Ò	˜HÓ	%€÷%ôB+�2—9‘9ô +ô4�r—y‘yô ô.˜BŸI™Iô ô<�—‘ô ô&A8�2—9‘9ô A8ôJ=˜BŸI™Iô =ôB9˜RŸY™Yô 9ô@JPÐ)ô JPô\˜BŸI™Iô ð$ ôj!˜ó j!ó ðj!ô\n
Ð!ô n
ðb ô]
Ð!ó ]
ó ð]
ñ@ ðôô
{)Ð"4°oó {)óð
{)ð| ôSÐ(ó Só ðSñl ðôôL
Ð#5ó L
óðL
ð^ ô;
Ð 2ó ;
ó ð;
ð| ôd
Ð0ó d
ó ðd
òN‚r8   