
    Z jCD                     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{Gz?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       ڄ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/t5gemma2/configuration_t5gemma2.pyrU    T5Gemma2TextConfig.__post_init__Z       "(**-Eq"I# t556 6A (,QU6M,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32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   zz.$7
 #.y!9*I6
 8<7K7K7Wt33]p#  !1299,G ##$45=6A95MD  !12-.99&**\43E3Eh3OP	
 ##$78@9Di8PD  !4501<<&**%;T=O=OPW=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    Hc0s0#*S*#u#L%It L#* +,L#S	/D(, L#*  $$#'OTD[' ND ,/sU{T)/!$3$!%NC$J%$(KcT!(,0UT\0+/EDL/*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3DKKcd(($//1ED4D4DEDd(($//!3!Id6H6H!ID'!3!5DKK`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#d38n4t;B@DM%S#X6=D&)t)")OS4Z)")OS4Z)$+sTz+&*ut|*'++( (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    Hc0s0#*S*#u#L%It L#* +,L#S	/D(, L#*  $$#'OTD[' ND ,/sU{T)/!$3$!%NC$J%$(KcT!(,0UT\0+/EDL/*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   dllD))0@4<<@DL\\!02DLKK^_dllD))0@4<<@DL\\!02DLKK^_040A0A  -595K5K  27;7M7M""4)-)?)?&$($5$5!)-)?)?&#||;;!_ .,3DLLBS,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<<3K3KK LL44@@APTP\P\PhPhOiikm 
 &&STT<<##..$,,2I2II LL44??@t||OfOfNggi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(^3d:A=AG"T#s(^3d:A## #L%#+#%(us{(+.US[.#u#$s$"&OS4Z& $$(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   