Ë
    ÜÓ^jCD  ã                   óP  — d dl mZ d dlmZ ddlmZ ddlmZmZ ddl	m
Z
  ej                  e«      Z ed¬	«      e G d
„ de«      «       «       Z ed¬	«      e G d„ de«      «       «       Z ed¬	«      e G d„ de«      «       «       Z ed¬	«      e G d„ de«      «       «       Zg d¢Zy)é    )ÚAny)Ústricté   )ÚPreTrainedConfig)Úauto_docstringÚloggingé   )ÚSiglipVisionConfigzgoogle/t5gemma-2-270m-270m)Ú
checkpointc            
       ó   ‡ — e Zd ZU dZdZdgZddddddddddœ	Zdgd	gfd
dgd
gfd
gd
gfdœZdZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZee
d<   dZe	e
d<   dZee
d <   d!Zee
d"<   d#Zee
d$<   d%Ze	d&z  e
d'<   d(Ze	ee	   z  d&z  e
d)<   d*Ze	d&z  e
d+<   d#Zee
d,<   d&Zed&z  e
d-<   d.Z ee
d/<   d0Z!e	ez  d&z  e
d1<   dZ"e	e
d2<   d3Z#e	d&z  e
d4<   d&Z$ee   d&z  e
d5<   d&Z%ed&z  e
d6<   d&Z&ed&z  e
d7<   d8d9d:œZ'ˆ fd;„Z(d<„ Z)d=„ Z*ˆ xZ+S )>ÚT5Gemma2TextConfigát  
    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                 óà   •— |j                  dd«      }| j                  €;t        | j                  «      D �cg c]  }t	        |dz   |z  «      rdnd‘Œ c}| _        t        ‰| �  di |¤Ž y c c}w ©NÚsliding_window_patterné   r5   Úsliding_attentionÚfull_attention© ©Úpopr@   Úranger$   ÚboolÚsuperÚ__post_init__©ÚselfÚkwargsÚ_sliding_window_patternÚiÚ	__class__s       €ú~/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/t5gemma2/configuration_t5gemma2.pyrT   z T5Gemma2TextConfig.__post_init__Z   óx   ø€ à"(§*¡*Ð-EÀqÓ"IÐØ×ÑÐ#ô ˜t×5Ñ5Ó6ö àô (,¨Q°©UÐ6MÑ,MÔ'NÑ#ÐTdÑdò ˆDÔô
 	‰ÑÑ' Ó'ùò ó   ·A+c                 óˆ   — | j                   | j                  z  dk7  r&t        d| j                   › d| j                  › d�«      ‚y©ú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©rV   s    r[   Úvalidate_architecturez(T5Gemma2TextConfig.validate_architecturee   óS   € à×Ñ˜d×6Ñ6Ñ6¸!Ò;ÜØ# D×$4Ñ$4Ð#5ð 6Ø×2Ñ2Ð3°2ð7óð ð <ó    c                 óz  — |j                  dd «      }ddiddidœ}| j                  �| j                  n|| _        |�| j                  d   j                  |«       | j                  j                  d«      €ddi| j                  d<   | j                  d   j	                  d|j                  d| j
                  d   «      «       | j                  j                  d«      €ddi| j                  d<   | j                  d   j	                  d|j                  d	| j
                  d
   «      «       | j                  «        |S ©NÚrope_scalingÚ	rope_typeÚdefault)rL   rM   rM   Ú
rope_thetarF   rL   Úrope_local_base_freqrG   ©rP   r9   ÚupdateÚgetÚ
setdefaultÚdefault_thetaÚstandardize_rope_params©rV   rW   rj   Údefault_rope_paramss       r[   Úconvert_rope_params_to_dictz.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ô	
ð
 	×$Ñ$Ô&Øˆrg   ©,Ú__name__Ú
__module__Ú__qualname__Ú__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.   r0   Úfloatr2   r3   rR   r4   r6   Úlistr7   r8   r9   Údictr:   r<   r=   r?   r@   rA   rB   rs   rT   re   rw   Ú__classcell__©rZ   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ô	(òörg   r   c                   óþ   ‡ — e Zd ZU dZdZddddœZeedœZdZ	ee
eef   z  dz  ed	<   dZee
eef   z  dz  ed
<   dZedz  ed<   dZedz  ed<   dZedz  ed<   dZedz  ed<   dZedz  ed<   dZedz  ed<   ˆ fd„Zˆ xZS )ÚT5Gemma2EncoderConfigaM  
    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   r/   r0   Tr8   c                 ó¸  •— | j                   €%t        «       | _         t        j                  d«       n4t	        | j                   t
        «      rt        di | j                   ¤Ž| _         t	        | j                  t
        «      rt        di | j                  ¤Ž| _        n0| j                  €$t        «       | _        t        j                  d«       t        ‰| �$  di |¤Ž y )NzItext_config is None, using default T5Gemma2EncoderTextConfig text config.zFvision_config is None, using default SiglipVisionConfig vision config.rN   )
r“   r   ÚloggerÚinfoÚ
isinstancer‡   r”   r
   rS   rT   )rV   rW   rZ   s     €r[   rT   z#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ä‰ÑÑ' Ó'rg   )rz   r{   r|   r}   r~   Úattribute_mapr   r
   Úsub_configsr“   r‡   r„   r   rƒ   r”   r•   r‚   rŽ   r�   r�   r0   r…   r8   rR   rT   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‘|Ó*Ø'+Ð˜ ™Ó+÷(ð (rg   r‹   c            
       ó   ‡ — e Zd ZU dZdZdgZddddddddddœ	Zdgd	gfd
dgd
gfd
gd
gfdœZdZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZe	e
d<   dZee
d<   dZe	e
d<   dZee
d <   d!Zee
d"<   d#Zee
d$<   d%Ze	d&z  e
d'<   d(Ze	ee	   z  d&z  e
d)<   d*Ze	d&z  e
d+<   d#Zee
d,<   d&Zed&z  e
d-<   d.Z ee
d/<   d0Z!e	ez  d&z  e
d1<   dZ"e	e
d2<   d3Z#e	d&z  e
d4<   d&Z$ee   d&z  e
d5<   d&Z%ed&z  e
d6<   d&Z&ed&z  e
d7<   d8d9d:œZ'ˆ fd;„Z(d<„ Z)d=„ Z*ˆ xZ+S )>ÚT5Gemma2DecoderConfigr   Ú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.   r/   r0   r1   r2   Tr3   r   Nr4   r5   r6   r	   r7   r8   r9   Fr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   c                 óà   •— |j                  dd«      }| j                  €;t        | j                  «      D �cg c]  }t	        |dz   |z  «      rdnd‘Œ c}| _        t        ‰| �  di |¤Ž y c c}w rI   rO   rU   s       €r[   rT   z#T5Gemma2DecoderConfig.__post_init__	  r\   r]   c                 óˆ   — | j                   | j                  z  dk7  r&t        d| j                   › d| j                  › d�«      ‚yr_   rb   rd   s    r[   re   z+T5Gemma2DecoderConfig.validate_architecture  rf   rg   c                 óz  — |j                  dd «      }ddiddidœ}| j                  �| j                  n|| _        |�| j                  d   j                  |«       | j                  j                  d«      €ddi| j                  d<   | j                  d   j	                  d|j                  d| j
                  d   «      «       | j                  j                  d«      €ddi| j                  d<   | j                  d   j	                  d|j                  d	| j
                  d
   «      «       | j                  «        |S ri   ro   ru   s       r[   rw   z1T5Gemma2DecoderConfig.convert_rope_params_to_dict  rx   rg   ry   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ô	(òörg   r�   c                   ó  ‡ — e Zd ZU dZdZdgZeedœZdddœZ	dZ
eeeef   z  dz  ed	<   dZeeeef   z  dz  ed
<   dZeed<   dZeez  ed<   dZeez  ed<   dZeez  ed<   dZeed<   dZeed<   dZedz  ed<   dZeed<   ˆ fd„Zd„ Zˆ xZS )ÚT5Gemma2Configa`  
    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_rater/   r0   iè r8   c                 ó¸  •— t        | j                  t        «      rt        di | j                  ¤Ž| _        n0| j                  €$t        «       | _        t        j                  d«       t        | j                  t        «      rt        di | j                  ¤Ž| _        n0| j                  €$t        «       | _        t        j                  d«       | j                  | j                  j                  _        | j                  | j                  j                  _
        | j                  | j                  j                  _
        | j                  | j                  _        | j                  | j                  _        | j                  | j                  _
        | j                  j                  | _        dD ]   }||vsŒt        | j                  |«      ||<   Œ" t        ‰| �@  di |¤Ž y )NzDencoder is None, using default T5Gemma2EncoderConfig encoder config.zDdecoder is None, using default T5Gemma2DecoderConfig decoder config.)r7   r4   r6   r   rN   )r™   r¥   r‡   r‹   r—   r˜   r¦   r�   r¨   r“   r<   r”   r�   r�   ÚgetattrrS   rT   )rV   rW   Úspecial_token_keyrZ   s      €r[   rT   zT5Gemma2Config.__post_init__e  sZ  ø€ Ü�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ˆ�‰Ô!Ø)-×)?Ñ)?ˆ�‰Ô&Ø#Ÿ|™|×;Ñ;ˆÔà!_ò 	UÐØ ¨Ò.Ü,3°D·L±LÐBSÓ,T�Ð(Ò)ð	Uô 	‰ÑÑ' Ó'rg   c                 ó  — | j                   j                  j                  | j                  j                  k7  rDt	        d| j                   j                  j                  › d| j                  j                  › d�«      ‚| j
                  st	        d«      ‚| j                   j                  j                  | j                  j                  k7  rDt	        d| j                   j                  j                  › d| j                  j                  › d�«      ‚y)r`   zBImbalanced encoder-decoder is not supported in T5Gemma2: encoder (z) vs decoder (ra   z4T5Gemma2Model only support encoder-decoder modeling.zRImbalanced encoder-decoder vocabulary size is not supported in T5Gemma2: encoder (N)r¥   r“   r    r¦   rc   r§   r   rd   s    r[   re   z$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rg   )rz   r{   r|   r}   r~   r   r‹   r�   r›   rš   r¥   r‡   r„   r   rƒ   r¦   r§   rR   r¨   r…   r‚   r<   r©   r0   r�   r�   r8   rT   re   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rg   r£   )r£   r   r‹   r�   N)Útypingr   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   r   Úsiglipr
   Ú
get_loggerrz   r—   r   r‹   r�   r£   Ú__all__rN   rg   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�rg   