
    Z j&                         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/rg)    )Any)strict   )PreTrainedConfig)auto_docstringlogging   )SiglipVisionConfigzgoogle/gemma-3-4b-it)
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'   S/r(\S'-  \S9'   S:S;S<.r)U 4S= jr*S> r+S? r,S@r-U =r.$ )AGemma3TextConfig!   a  
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.
use_bidirectional_attention (`bool`, *optional*, defaults to `False`):
    If True, the model will attend to all text tokens instead of using a causal mask. This does not change
    behavior for vision tokens.

```python
>>> from transformers import Gemma3TextModel, Gemma3TextConfig
>>> # Initializing a Gemma3Text gemma3_text-7b style configuration
>>> configuration = Gemma3TextConfig()
>>> # Initializing a model from the gemma3_text-7b style configuration
>>> model = Gemma3TextModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
```
gemma3_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normi@  
vocab_sizei 	  hidden_sizei $  intermediate_size   num_hidden_layers   num_attention_heads   num_key_value_heads   head_dimgelu_pytorch_tanhhidden_activationi   max_position_embeddings{Gz?initializer_rangegư>rms_norm_epsT	use_cacher   Npad_token_id   eos_token_idr	   bos_token_idtie_word_embeddingsrope_parametersFattention_biasg        attention_dropoutquery_pre_attn_scalari   sliding_windowlayer_typesfinal_logit_softcappingattn_logit_softcappinguse_bidirectional_attentiong    .Ag     @)globallocalc                 b  > U R                   (       a  U R                  S-  S-   U l        UR                  SS5      U l        U R                  cM  [        U R                  5       Vs/ s H'  n[        US-   U R                  -  5      (       a  SOSPM)     snU l        [        TU ]$  " S0 UD6  g s  snf )Nr	   r.   sliding_window_pattern   sliding_attentionfull_attention )
r:   r6   get_sliding_window_patternr7   ranger   boolsuper__post_init__)selfkwargsi	__class__s      ڀ/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/transformers/models/gemma3/configuration_gemma3.pyrH   Gemma3TextConfig.__post_init__h   s    ++#'#6#6!#;q"@D (.zz2JA'N$# t556 6A (,QUd6R6R,R'S'S#Yii6 D
 	'' s   %.B,c                     U R                   U R                  -  S:w  a&  [        SU R                    SU R                   S35      eg)zOPart 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 (z).N)r   r!   
ValueError)rI   s    rM   validate_architecture&Gemma3TextConfig.validate_architecturew   sS    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)r@   rA   rA   
rope_thetar;   r@   rope_local_base_freqr<   )popr2   updaterC   
setdefaultdefault_thetastandardize_rope_params)rI   rJ   rU   default_rope_paramss       rM   convert_rope_params_to_dict,Gemma3TextConfig.convert_rope_params_to_dict   sI   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	

 	$$&rS   )rD   r7   r2   r6   )/__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(   r*   floatr+   r,   rF   r-   r/   listr0   r1   r2   dictr3   r4   r5   r6   r7   r8   r9   r:   r]   rH   rQ   r`   __static_attributes____classcell__rL   s   @rM   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//44*X>M( rS   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$ )Gemma3Config   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 Gemma3ForConditionalGeneration, Gemma3Config, SiglipVisionConfig, Gemma3TextConfig

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

>>> # Initializing a Gemma3 Text config
>>> text_config = Gemma3TextConfig()

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

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

>>> # Accessing the model configuration
>>> configuration = model.config
```gemma3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   r)   r*   Tr1   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 )Nz@text_config is None, using default Gemma3TextConfig text config.zFvision_config is None, using default SiglipVisionConfig vision config.rB   )
r~   r   loggerinfo
isinstancerp   r   r
   rG   rH   )rI   rJ   rL   s     rM   rH   Gemma3Config.__post_init__   s    #/1DKKZ[(($///C$2B2BCDd(($//!3!Id6H6H!ID'!3!5DKK`a''rS   )rb   rc   rd   re   rf   rg   attribute_mapr   r
   sub_configsr~   rp   rm   r   rl   r   r   rk   ry   rz   rx   r*   rn   r1   rF   rH   rq   rr   rs   s   @rM   ru   ru      s    : J-))M (+K
 =AK!DcN2T9@@DM%S#X6=D&)t)")OS4Z)")OS4Z)$+sTz+&*ut|*'++( (rS   ru   N)typingr   huggingface_hub.dataclassesr   configuration_utilsr   utilsr   r   siglipr
   
get_loggerrb   r   r   ru   __all__rB   rS   rM   <module>r      s   *  . 3 , ' 
		H	% 12w' w  3wt 12?(# ?(  3?(D -
.rS   