ó
    qyüiCD  ã                   ó8  • S SK Jr  S SKJr  SSKJr  SSKJrJr  SSK	J
r
  \R                  " \5      r\" SS	9\ " S
 S\5      5       5       r\" SS	9\ " S S\5      5       5       r\" SS	9\ " S S\5      5       5       r\" SS	9\ " S S\5      5       5       r/ SQrg)é    )ÚAny)Ústricté   )ÚPreTrainedConfig)Úauto_docstringÚloggingé   )ÚSiglipVisionConfigzgoogle/t5gemma-2-270m-270m)Ú
checkpointc            
       ó*  ^ • \ rS rSr% SrSrS/rSSSSSSSSSS.	rS	/S
/4SS/S/4S/S/4S.rSr	\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\\S'   Sr\
\S'   S r\\S!'   S"r\\S#'   S$r\\S%'   S&r\
S'-  \S('   S)r\
\\
   -  S'-  \S*'   S+r\
S'-  \S,'   S$r\\S-'   S'r\ S'-  \S.'   S/r!\\S0'   S1r"\
\-  S'-  \S2'   Sr#\
\S3'   S4r$\
S'-  \S5'   S'r%\\   S'-  \S6'   S'r&\S'-  \S7'   S'r'\S'-  \S8'   S9S:S;.r(U 4S< jr)S= r*S> r+S?r,U =r-$ )@ÚT5Gemma2TextConfigé!   áX  
query_pre_attn_scalar (`float`, *optional*, defaults to 256):
    Scaling factor used on the attention scores
final_logit_softcapping (`float`, *optional*):
    Scaling factor when applying tanh softcapping on the logits.
attn_logit_softcapping (`float`, *optional*):
    Scaling factor when applying tanh softcapping on the attention scores.
Út5gemma2_textÚpast_key_valuesÚcolwiseÚreplicated_with_grad_allreduceÚrowwise©	zlayers.*.self_attn.q_projzlayers.*.self_attn.k_projzlayers.*.self_attn.v_projzlayers.*.self_attn.q_normzlayers.*.self_attn.k_normzlayers.*.self_attn.o_projzlayers.*.mlp.gate_projzlayers.*.mlp.up_projzlayers.*.mlp.down_projÚ	input_idsÚinputs_embedsÚhidden_statesÚattention_mask©Úembed_tokensÚlayersÚnormé@  Ú
vocab_sizeé 	  Úhidden_sizeé $  Úintermediate_sizeé   Únum_hidden_layersé   Únum_attention_headsé   Únum_key_value_headsé   Úhead_dimÚgelu_pytorch_tanhÚhidden_activationé   Úmax_position_embeddingsç{®Gáz”?Úinitializer_rangeç�íµ ÷Æ°>Úrms_norm_epsTÚ	use_cacher   NÚpad_token_idé   Úeos_token_idr	   Úbos_token_idÚtie_word_embeddingsÚrope_parametersFÚattention_biasç        Úattention_dropoutÚquery_pre_attn_scalaré   Úsliding_windowÚlayer_typesÚfinal_logit_softcappingÚattn_logit_softcappingç    €„.Aç     ˆÃ@©ÚglobalÚlocalc                 óô   >• UR                  SS5      nU R                  cC  [        U R                  5       Vs/ s H  n[	        US-   U-  5      (       a  SOSPM     snU l        [
        TU ]  " S0 UD6  g s  snf ©NÚsliding_window_patterné   r6   Úsliding_attentionÚfull_attention© ©ÚpoprA   Úranger%   ÚboolÚsuperÚ__post_init__©ÚselfÚkwargsÚ_sliding_window_patternÚiÚ	__class__s       €Úp/home/mande/repo/quber/.venv/lib/python3.13/site-packages/transformers/models/t5gemma2/configuration_t5gemma2.pyrU   Ú T5Gemma2TextConfig.__post_init__Z   ó€   ø€ à"(§*¡*Ð-EÀqÓ"IÐØ×ÑÑ#ô ˜t×5Ñ5Ô6ó â6�Aô (,¨Q°©UÐ6MÑ,M×'NÑ'NÑ#ÐTdÒdÙ6ñ ˆDÔô
 	‰ÒÑ' Ó'ùò ó   ¸$A5c                 óŠ   • U R                   U R                  -  S:w  a&  [        SU R                    SU R                   S35      eg©úOPart of `@strict`-powered validation. Validates the architecture of the config.r   zThe hidden size (z6) is not a multiple of the number of attention heads (ú).N©r!   r'   Ú
ValueError©rW   s    r\   Úvalidate_architectureÚ(T5Gemma2TextConfig.validate_architecturee   óS   € à×Ñ˜d×6Ñ6Ñ6¸!Ó;ÜØ# D×$4Ñ$4Ð#5ð 6Ø×2Ñ2Ð3°2ð7óð ð <ó    c                 ó‚  • UR                  SS 5      nSS0SS0S.nU R                  b  U R                  OUU l        Ub  U R                  S   R                  U5        U R                  R                  S5      c  SS0U R                  S'   U R                  S   R	                  SUR                  SU R
                  S   5      5        U R                  R                  S5      c  SS0U R                  S'   U R                  S   R	                  SUR                  S	U R
                  S
   5      5        U R                  5         U$ ©NÚrope_scalingÚ	rope_typeÚdefault)rM   rN   rN   Ú
rope_thetarG   rM   Úrope_local_base_freqrH   ©rQ   r:   ÚupdateÚgetÚ
setdefaultÚdefault_thetaÚstandardize_rope_params©rW   rX   rm   Údefault_rope_paramss       r\   Úconvert_rope_params_to_dictÚ.T5Gemma2TextConfig.convert_rope_params_to_dictm   óI  € Ø—z‘z .°$Ó7ˆð
 #.¨yÐ!9Ø*¨IÐ6ñ
Ðð 8<×7KÑ7KÑ7W˜t×3Ò3Ð]pˆÔØÑ#Ø× Ñ Ð!1Ñ2×9Ñ9¸,ÔGð ×Ñ×#Ñ#Ð$4Ó5Ñ=Ø6AÀ9Ð5MˆD× Ñ Ð!1Ñ2Ø×ÑÐ-Ñ.×9Ñ9Ø˜&Ÿ*™* \°4×3EÑ3EÀhÑ3OÓPô	
ð ×Ñ×#Ñ#Ð$7Ó8Ñ@Ø9DÀiÐ8PˆD× Ñ Ð!4Ñ5Ø×ÑÐ0Ñ1×<Ñ<Ø˜&Ÿ*™*Ð%;¸T×=OÑ=OÐPWÑ=XÓYô	
ð
 	×$Ñ$Ô&Øˆrj   ©rA   r:   ©.Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferenceÚbase_model_tp_planÚbase_model_pp_planr   ÚintÚ__annotations__r!   r#   r%   r'   r)   r+   r-   Ústrr/   r1   Úfloatr3   r4   rS   r5   r7   Úlistr8   r9   r:   Údictr;   r=   r>   r@   rA   rB   rC   rv   rU   rg   rz   Ú__static_attributes__Ú__classcell__©r[   s   @r\   r   r   !   sÄ  ø‡ ñð !€JØ#4Ð"5Ðà%.Ø%.Ø%.Ø%EØ%EØ%.Ø"+Ø )Ø"+ñ
Ðð &˜¨Ð(9Ð:Ø#Ð%5Ð6¸Ð8IÐJØ!Ð" _Ð$5Ð6ñÐð €J�ÓØ€K�ÓØ!Ð�sÓ!ØÐ�sÓØ Ð˜Ó Ø Ð˜Ó Ø€HˆcÓØ0Ð�sÓ0Ø#*Ð˜SÓ*Ø#Ð�uÓ#Ø€L�%ÓØ€IˆtÓØ €L�#˜‘*Ó Ø+,€L�#˜˜S™	‘/ DÑ(Ó,Ø €L�#˜‘*Ó Ø $Ð˜Ó$Ø#'€O�T˜D‘[Ó'Ø €N�DÓ Ø,/Ð�s˜U‘{ TÑ)Ó/Ø!$Ð˜3Ó$Ø!%€N�C˜$‘JÓ%Ø$(€K��c‘˜TÑ!Ó(Ø,0Ð˜U T™\Ó0Ø+/Ð˜E D™LÓ/Ø*°XÑ>€Mõ	(ò÷ð rj   r   c                   ó  ^ • \ rS rSr% SrSrSSSS.r\\S.r	S	r
\\\\4   -  S	-  \S
'   S	r\\\\4   -  S	-  \S'   Sr\S	-  \S'   Sr\S	-  \S'   Sr\S	-  \S'   Sr\S	-  \S'   Sr\S	-  \S'   Sr\S	-  \S'   U 4S jrSrU =r$ )ÚT5Gemma2EncoderConfigé‹   aý  
mm_tokens_per_image (`int`, *optional*, defaults to 256):
    The number of tokens per image embedding.
boi_token_index (`int`, *optional*, defaults to 255999):
    The begin-of-image token index to wrap the image prompt.
eoi_token_index (`int`, *optional*, defaults to 256000):
    The end-of-image token index to wrap the image prompt.

Example:

```python
>>> from transformers import T5Gemma2EncoderForConditionalGeneration, T5Gemma2EncoderConfig, SiglipVisionConfig, T5Gemma2EncoderTextConfig

>>> # Initializing a Siglip-like vision config
>>> vision_config = SiglipVisionConfig()

>>> # Initializing a T5Gemma2Encoder Text config
>>> text_config = T5Gemma2EncoderTextConfig()

>>> # Initializing a T5Gemma2Encoder gemma-3-4b style configuration
>>> configuration = T5Gemma2EncoderConfig(vision_config, text_config)

>>> # Initializing a model from the gemma-3-4b style configuration
>>> model = T5Gemma2EncoderTextConfig(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```Út5gemma2_encoderÚimage_token_indexÚboi_token_indexÚeoi_token_index)Úimage_token_idÚboi_token_idÚeoi_token_id)Útext_configÚvision_configNr›   rœ   r*   Úmm_tokens_per_imageiÿç i è i   r0   r1   Tr9   c                 óÒ  >• U R                   c%  [        5       U l         [        R                  S5        O9[	        U R                   [
        5      (       a  [        S0 U R                   D6U l         [	        U R                  [
        5      (       a  [        S0 U R                  D6U l        O1U R                  c$  [        5       U l        [        R                  S5        [        TU ]$  " S0 UD6  g )NzItext_config is None, using default T5Gemma2EncoderTextConfig text config.zFvision_config is None, using default SiglipVisionConfig vision config.rO   )
r›   r   ÚloggerÚinfoÚ
isinstancer�   rœ   r
   rT   rU   )rW   rX   r[   s     €r\   rU   Ú#T5Gemma2EncoderConfig.__post_init__À   s­   ø€ Ø×ÑÑ#Ü1Ó3ˆDÔÜ�K‰KÐcÕdÜ˜×(Ñ(¬$×/Ñ/Ü1ÑE°D×4DÑ4DÑEˆDÔä�d×(Ñ(¬$×/Ñ/Ü!3Ñ!I°d×6HÑ6HÑ!IˆDÕØ×ÑÑ'Ü!3Ó!5ˆDÔÜ�K‰KÐ`Ôaä‰ÒÑ' Ó'rj   )r   r€   r�   r‚   rƒ   r„   Úattribute_mapr   r
   Úsub_configsr›   r�   rŠ   r   r‰   rœ   r�   rˆ   r–   r—   r•   r1   r‹   r9   rS   rU   rŽ   r�   r�   s   @r\   r’   r’   ‹   sÍ   ø‡ ñð: $€Jà-Ø)Ø)ñ€Mð *Ø+ñ€Kð
 ?C€KÐ# d¨3°¨8¡nÑ4°tÑ;ÓBØ@D€MÐ%¨¨S°#¨X©Ñ6¸Ñ=ÓDØ&)Ð˜˜t™Ó)Ø")€O�S˜4‘ZÓ)Ø")€O�S˜4‘ZÓ)Ø$+Ð�s˜T‘zÓ+Ø&*Ð�u˜t‘|Ó*Ø'+Ð˜ ™Ó+÷(ó (rj   r’   c            
       ó*  ^ • \ rS rSr% SrSrS/rSSSSSSSSSS.	rS	/S
/4SS/S/4S/S/4S.rSr	\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\
\S'   Sr\\S'   Sr\
\S'   S r\\S!'   S"r\\S#'   S$r\\S%'   S&r\
S'-  \S('   S)r\
\\
   -  S'-  \S*'   S+r\
S'-  \S,'   S$r\\S-'   S'r\ S'-  \S.'   S/r!\\S0'   S1r"\
\-  S'-  \S2'   Sr#\
\S3'   S4r$\
S'-  \S5'   S'r%\\   S'-  \S6'   S'r&\S'-  \S7'   S'r'\S'-  \S8'   S9S:S;.r(U 4S< jr)S= r*S> r+S?r,U =r-$ )@ÚT5Gemma2DecoderConfigéÐ   r   Út5gemma2_decoderr   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   Tr4   r   Nr5   r6   r7   r	   r8   r9   r:   Fr;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   c                 óô   >• UR                  SS5      nU R                  cC  [        U R                  5       Vs/ s H  n[	        US-   U-  5      (       a  SOSPM     snU l        [
        TU ]  " S0 UD6  g s  snf rJ   rP   rV   s       €r\   rU   Ú#T5Gemma2DecoderConfig.__post_init__	  r^   r_   c                 óŠ   • U R                   U R                  -  S:w  a&  [        SU R                    SU R                   S35      egra   rd   rf   s    r\   rg   Ú+T5Gemma2DecoderConfig.validate_architecture  ri   rj   c                 ó‚  • UR                  SS 5      nSS0SS0S.nU R                  b  U R                  OUU l        Ub  U R                  S   R                  U5        U R                  R                  S5      c  SS0U R                  S'   U R                  S   R	                  SUR                  SU R
                  S   5      5        U R                  R                  S5      c  SS0U R                  S'   U R                  S   R	                  SUR                  S	U R
                  S
   5      5        U R                  5         U$ rl   rr   rx   s       r\   rz   Ú1T5Gemma2DecoderConfig.convert_rope_params_to_dict  r|   rj   r}   r~   r�   s   @r\   r¦   r¦   Ð   sÄ  ø‡ ñð $€JØ#4Ð"5Ðà%.Ø%.Ø%.Ø%EØ%EØ%.Ø"+Ø )Ø"+ñ
Ðð &˜¨Ð(9Ð:Ø#Ð%5Ð6¸Ð8IÐJØ!Ð" _Ð$5Ð6ñÐð €J�ÓØ€K�ÓØ!Ð�sÓ!ØÐ�sÓØ Ð˜Ó Ø Ð˜Ó Ø€HˆcÓØ0Ð�sÓ0Ø#*Ð˜SÓ*Ø#Ð�uÓ#Ø€L�%ÓØ€IˆtÓØ €L�#˜‘*Ó Ø+,€L�#˜˜S™	‘/ DÑ(Ó,Ø €L�#˜‘*Ó Ø $Ð˜Ó$Ø#'€O�T˜D‘[Ó'Ø €N�DÓ Ø,/Ð�s˜U‘{ TÑ)Ó/Ø!$Ð˜3Ó$Ø!%€N�C˜$‘JÓ%Ø$(€K��c‘˜TÑ!Ó(Ø,0Ð˜U T™\Ó0Ø+/Ð˜E D™LÓ/Ø*°XÑ>€Mõ	(ò÷ð rj   r¦   c                   ó"  ^ • \ rS rSr% SrSrS/r\\S.r	SSS.r
S	r\\\\4   -  S	-  \S
'   S	r\\\\4   -  S	-  \S'   Sr\\S'   Sr\\-  \S'   Sr\\-  \S'   Sr\\-  \S'   Sr\\S'   Sr\\S'   S	r\S	-  \S'   Sr\\S'   U 4S jrS rSrU =r$ )ÚT5Gemma2Configi:  a,  
encoder (`Union[T5Gemma2EncoderConfig, dict]`, optional, *optional*):
    Configuration for the encoder.
decoder (`Union[T5Gemma2DecoderConfig, dict]`, optional, *optional*):
    Configuration for the decoder.
eoi_token_index (`int`, *optional*):
    The end-of-image token index to wrap the image prompt. Will be same as
    `self.encoder.eoi_token_index`

```python
>>> from transformers import T5Gemma2Config, T5Gemma2Model
>>> t5gemma2_config = T5Gemma2Config.from_pretrained("google/t5gemma-270m-270m")
>>> model = T5Gemma2Model(t5gemma2_config)
```
Út5gemma2r   )ÚencoderÚdecoderr•   r—   )r˜   rš   Nr²   r³   TÚis_encoder_decoderr<   Údropout_rater=   Úclassifier_dropout_rater0   r1   iè r9   c                 óØ  >• [        U R                  [        5      (       a  [        S0 U R                  D6U l        O1U R                  c$  [        5       U l        [        R                  S5        [        U R                  [        5      (       a  [        S0 U R                  D6U l        O1U R                  c$  [        5       U l        [        R                  S5        U R                  U R                  R                  l        U R                  U R                  R                  l
        U R                  U R                  R                  l
        U R                  U R                  l        U R                  U R                  l        U R                  U R                  l
        U R                  R                  U l        S H"  nX!;  d  M
  [        U R                  U5      X'   M$     [        TU ]@  " S0 UD6  g )NzDencoder is None, using default T5Gemma2EncoderConfig encoder config.zDdecoder is None, using default T5Gemma2DecoderConfig decoder config.)r8   r5   r7   r   rO   )r¡   r²   r�   r’   rŸ   r    r³   r¦   rµ   r›   r=   rœ   r•   r—   ÚgetattrrT   rU   )rW   rX   Úspecial_token_keyr[   s      €r\   rU   ÚT5Gemma2Config.__post_init__e  sU  ø€ Ü�d—l‘l¤D×)Ñ)Ü0Ñ@°4·<±<Ñ@ˆD�LØ�\‰\Ñ!Ü0Ó2ˆDŒLÜ�K‰KÐ^Ô_ä�d—l‘l¤D×)Ñ)Ü0Ñ@°4·<±<Ñ@ˆD�LØ�\‰\Ñ!Ü0Ó2ˆDŒLÜ�K‰KÐ^Ô_à04×0AÑ0Aˆ�‰× Ñ Ô-Ø59×5KÑ5Kˆ�‰× Ñ Ô2Ø7;×7MÑ7Mˆ�‰×"Ñ"Ô4Ø)-×)?Ñ)?ˆ�‰Ô&à$(×$5Ñ$5ˆ�‰Ô!Ø)-×)?Ñ)?ˆ�‰Ô&Ø#Ÿ|™|×;Ñ;ˆÔã!_ÐØ Õ.Ü,3°D·L±LÐBSÓ,T�Ó)ñ "`ô 	‰ÒÑ' Ó'rj   c                 ó,  • U R                   R                  R                  U R                  R                  :w  aD  [	        SU R                   R                  R                   SU R                  R                   S35      eU R
                  (       d  [	        S5      eU R                   R                  R                  U R                  R                  :w  aD  [	        SU R                   R                  R                   SU R                  R                   S35      eg)rb   zBImbalanced encoder-decoder is not supported in T5Gemma2: encoder (z) vs decoder (rc   z4T5Gemma2Model only support encoder-decoder modeling.zRImbalanced encoder-decoder vocabulary size is not supported in T5Gemma2: encoder (N)r²   r›   r!   r³   re   r´   r   rf   s    r\   rg   Ú$T5Gemma2Config.validate_architecture�  sê   € à�<‰<×#Ñ#×/Ñ/°4·<±<×3KÑ3KÓKÜðØ ŸL™L×4Ñ4×@Ñ@ÐAÀÐPT×P\ÑP\×PhÑPhÐOiÐikðmóð ð
 ×&×&ÜÐSÓTÐTà�<‰<×#Ñ#×.Ñ.°$·,±,×2IÑ2IÓIÜðØ ŸL™L×4Ñ4×?Ñ?Ð@ÀÈtÏ|É|×OfÑOfÐNgÐgiðkóð ð Jrj   )r³   r²   r—   ) r   r€   r�   r‚   rƒ   r„   r…   r’   r¦   r¤   r£   r²   r�   rŠ   r   r‰   r³   r´   rS   rµ   r‹   rˆ   r=   r¶   r1   r•   r—   r9   rU   rg   rŽ   r�   r�   s   @r\   r°   r°   :  sè   ø‡ ñð  €JØ#4Ð"5Ðð )Ø(ñ€Kð .Ø)ñ€Mð
 >B€GÐ" T¨#¨s¨(¡^Ñ3°dÑ:ÓAØ=A€GÐ" T¨#¨s¨(¡^Ñ3°dÑ:ÓAØ#Ð˜Ó#Ø #€L�%˜#‘+Ó#Ø%(Ð�u˜s‘{Ó(Ø+.Ð˜U S™[Ó.Ø#Ð�uÓ#Ø$Ð�sÓ$Ø"&€O�S˜4‘ZÓ&Ø $Ð˜Ó$õ(÷8ð rj   r°   )r°   r   r’   r¦   N)Útypingr   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   r   Úsiglipr
   Ú
get_loggerr   rŸ   r   r’   r¦   r°   Ú__all__rO   rj   r\   Ú<module>rÄ      sè   ðõ* å .å 3ß ,Ý 'ð 
×	Ò	˜HÓ	%€ñ Ð7Ñ8ØôeÐ)ó eó ó 9ðeñP Ð7Ñ8Øô@(Ð,ó @(ó ó 9ð@(ñF Ð7Ñ8ØôeÐ,ó eó ó 9ðeñP Ð7Ñ8ØôTÐ%ó Tó ó 9ðTòn e�rj   