+
    œ°³jW¢ ã                   óî  € ^ RI t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	t	^ RI	H
t
 ^ RIHt ^RI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H t  ^RI!H"t" ^RI#H$t$H%t% ^RI&H't' ^RI(H)t)H*t* ^RI+H,t, ^RI-H.t.H/t/H0t0H1t1H2t2 ^RI3H4t4H5t5H6t6 ^RI7H8t8H9t9 ^RI:H;t; ^RI<H=t=H>t>H?t?H@t@HAtAHBtBHCtC ^RIDHEtEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtM ^RINHOtO ^RIPHQtQ ^RIRHStS ^RITHUtUHVtVHWtWHXtX ]1P²                  ! ]Z4      t[R R lt\ ! R R]H4      t] ! R  R!]E4      t^] ! R" R#]$4      4       t_]/] ! R$ R%]%4      4       4       t` ! R& R']
PÂ                  4      tb ! R( R)]K4      tc ! R* R+]
PÂ                  4      td ! R, R-]
PÂ                  4      te ! R. R/]
PÂ                  4      tf ! R0 R1]
PÂ                  4      tg ! R2 R3]
PÂ                  4      th ! R4 R5]
PÒ                  4      tj ! R6 R7]
PÂ                  4      tk ! R8 R9]
PÂ                  4      tl ! R: R;]
PÂ                  4      tm ! R< R=]
PÂ                  4      tn ! R> R?]@4      toRqR@ RA lltp ! RB RC]S4      tq]6 ! RD RE]=4      4       tr ! RF RG]>4      ts ! RH RI]
PÂ                  4      tt ! RJ RK]@4      tu ! RL RM]A4      tv ! RN RO]
PÂ                  4      tw ! RP RQ]O4      tx ! RR RS]
PÂ                  4      ty ! RT RU]>4      tz ! RV RW]C4      t{ ! RX RY]J4      t|]/! RZR[7       ! R\ R]]B4      4       t}]/! R^R[7       ! R_ R`]?4      4       t~ ! Ra Rb]|4      t ! Rc Rd]|4      t€ ! Re Rf]I4      t�Rg Rh lt‚Ri Rj ltƒ]/! RkR[7       ! Rl Rm]G4      4       t„]/! RnR[7       ! Ro Rp]F4      4       t…. RrOt†R# )sé    N)ÚUserDict)ÚCallable)Ú	dataclass)Úcached_property)Únn)Ú
functional)Úinitialization)ÚACT2FN)ÚCacheÚDynamicCache)ÚPreTrainedConfig)Ú_preprocess_mask_argumentsÚblockwise_overlayÚcreate_bidirectional_maskÚcreate_causal_maskÚcreate_masks_for_generateÚ!create_sliding_window_causal_maskÚmaybe_pad_block_sequence_idsÚsliding_window_overlay)ÚFlashAttentionKwargs)ÚBaseModelOutputWithPastÚBaseModelOutputWithPooling)ÚROPE_INIT_FUNCTIONS)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚcan_return_tupleÚloggingÚtorch_compilable_check)Úmaybe_autocastÚmerge_with_config_defaultsÚno_inherit_decorator)ÚOutputRecorderÚcapture_outputs)Ú	AutoModel)ÚGemma3AttentionÚGemma3DecoderLayerÚGemma3ForCausalLMÚ	Gemma3MLPÚGemma3RotaryEmbeddingÚGemma3TextModelÚGemma3TextScaledWordEmbedding)	ÚGemma3nCausalLMOutputWithPastÚGemma3nForConditionalGenerationÚGemma3nModelÚGemma3nModelOutputWithPastÚGemma3nMultimodalEmbedderÚGemma3nPreTrainedModelÚGemma3nRMSNormÚapply_rotary_pos_embÚeager_attention_forward)ÚMixtralExperts)Úsliding_window_mask_function)ÚSam3ViTRotaryEmbedding)ÚGemma4AudioConfigÚGemma4ConfigÚGemma4TextConfigÚGemma4VisionConfigc                óæ   € V ^8„  d   QhR\         R\        P                  R\        P                  R,          R\        R,          R\        P                  R,          R\        P                  R\        /# )	é   ÚconfigÚinputs_embedsÚattention_maskNÚpast_key_valuesÚposition_idsÚblock_sequence_idsÚreturn)r   ÚtorchÚTensorr   Údict)Úformats   "Új/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/gemma4/modular_gemma4.pyÚ__annotate__rM   S   sl   € ÷ <ñ <Üð<ä—<‘<ð<ô —L‘L 4Õ'ð<ô ˜T•\ð	<ô
 —,‘, Õ%ð<ô Ÿ™ð<ô 
ñ<ó    c           
     óv  € RV RVRVRVRV/p\        R/ VB p\        VRR4      '       d.   RVP                  9   d   VP                  P                  R4      pM^ p\	        R/ VBR	V/B w  p	  r«r¬V	'       d   TpM\        WRW¼4      p\        R/ VBR
\        V4      R\        V P                  4      R	V/B pRVRV/# )aw  Create full_attention and sliding_attention masks with correct composition.

For global (full attention) layers:  causal only (no bidirectional)
For local (sliding window) layers:  AND(sliding_window, OR(causal, blockwise))

Unlike Gemma 3 (which applies bidirectional attention on all layers), Gemma 4
explicitly disables bidirectional attention on global attention layers.
rA   rB   rC   rD   rE   Ú
is_slidingNTÚ	layer_idxÚor_mask_functionÚand_mask_functionÚfull_attentionÚsliding_attention© )	r   ÚgetattrrP   Úindexr   r   r   r   Úsliding_window)rA   rB   rC   rD   rE   rF   Úmask_kwargsÚ	full_maskÚsliding_layer_idxÚ
early_exitÚ_Ú	kv_lengthÚ	kv_offsetÚpadded_block_sequence_idsÚsliding_masks   &&&&&&         rL   Úcreate_masks_for_vision_modelrc   S   s  € ð" 	�&Ø˜Ø˜.Ø˜?Ø˜ð€Kô #Ñ1 [Ñ1€Iô ˆ ¨d×3Ò3¸À×@ZÑ@ZÔ8ZØ+×6Ñ6×<Ñ<¸TÓBÑàÐô 4Nñ 4Ø
ñ4à#ò4Ñ0€J��1�a A÷ Ø$6Ñ!ä$@Ø°	ó%
Ð!ô &ñ Ø
ñä*Ð+DÓEðô 1°×1FÑ1FÓGðð $ò	€Lð 	˜)Ø˜\ðð rN   c                   ó4   a € ] tR t^’t o RtRtV 3R ltRtV tR# )ÚGemma4ModelOutputWithPastaw  
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
    `past_key_values` input) to speed up sequential decoding.
image_hidden_states (`torch.FloatTensor`, *optional*):
    A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
    image_hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
audio_hidden_states (`torch.FloatTensor`, *optional*):
    A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
    audio_hidden_states of the model produced by the audio encoder and after projecting the last hidden state.
shared_kv_states (`dict`, *optional*):
    Dictionary mapping layer type strings to tuples of (key_states, value_states) tensors.
    Used to pass shared KV states between layers during KV sharing.
Nc                óˆ   <€ V ^8„  d   Qh/ S[ S[S[S[P                  S[P                  3,          3,          R,          ;R&   # ©r@   NÚshared_kv_states©rJ   ÚstrÚtuplerH   rI   )rK   Ú__classdict__s   "€rL   rM   Ú&Gemma4ModelOutputWithPast.__annotate__’   s3   ø‡ ‚ ñ$ ™3¡¡e§l¡l±E·L±LÐ&@Õ AÐAÕBÀTÕIÑPò% rN   rV   ©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rh   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©rl   s   @rL   re   re   ’   s   ø‡ € ñð" MQÐ÷% ƒ rN   re   c                   ó4   a € ] tR t^§t o RtRtV 3R ltRtV tR# )ÚGemma4CausalLMOutputWithPastaÐ  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Language modeling loss (for next-token prediction).
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.text_config.vocab_size)`):
    Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
    `past_key_values` input) to speed up sequential decoding.
image_hidden_states (`torch.FloatTensor`, *optional*):
    A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
    image_hidden_states of the model produced by the vision encoder after projecting last hidden state.
audio_hidden_states (`torch.FloatTensor`, *optional*):
    A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
    audio_hidden_states of the model produced by the audio encoder and after projecting the last hidden state.
shared_kv_states (`dict`, *optional*):
    Dictionary mapping layer type strings to tuples of (key_states, value_states) tensors.
    Used to pass shared KV states between layers during KV sharing.
Nc                óˆ   <€ V ^8„  d   Qh/ S[ S[S[S[P                  S[P                  3,          3,          R,          ;R&   # rg   ri   )rK   rl   s   "€rL   rM   Ú)Gemma4CausalLMOutputWithPast.__annotate__§   s3   ø‡ ‚ ñ, ™3¡¡e§l¡l±E·L±LÐ&@Õ AÐAÕBÀTÕIÑPò- rN   rV   rn   rw   s   @rL   ry   ry   §   s   ø‡ € ñð* MQÐ÷- ƒ rN   ry   c                   ó4   a € ] tR t^Àt o RtRtV 3R ltRtV tR# )ÚGemma4TextModelOutputWithPasta!  
BaseModelOutputWithPast extended with shared_kv_states for KV sharing.

Args:
    shared_kv_states (`dict`, *optional*):
        Dictionary mapping layer type strings to tuples of (key_states, value_states) tensors.
        Used to pass shared KV states between layers during KV sharing.
Nc                óˆ   <€ V ^8„  d   Qh/ S[ S[S[S[P                  S[P                  3,          3,          R,          ;R&   # rg   ri   )rK   rl   s   "€rL   rM   Ú*Gemma4TextModelOutputWithPast.__annotate__À   s3   ø‡ ‚ ñ ™3¡¡e§l¡l±E·L±LÐ&@Õ AÐAÕBÀTÕIÑPò rN   rV   rn   rw   s   @rL   r}   r}   À   s   ø‡ € ñð MQÐ÷ ƒ rN   r}   c                   ó4   a € ] tR t^Ît o RtRtV 3R ltRtV tR# )ÚGemma4AudioModelOutputz›
attention_mask (`torch.BoolTensor`, *optional*):
    A torch.BoolTensor of shape `(batch_size, num_frames)`. True for valid positions, False for padding.
Nc                óH   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   # )r@   NrC   )rH   Ú
BoolTensor)rK   rl   s   "€rL   rM   Ú#Gemma4AudioModelOutput.__annotate__Î   s   ø‡ ‚ ñ ×$Ñ$ tÕ+Ñ2ò rN   rV   )	ro   rp   rq   rr   rs   rC   rt   ru   rv   rw   s   @rL   r�   r�   Î   s   ø‡ € ñð
 /3€N÷ ƒ rN   r�   c                   óP   a a€ ] tR t^Ùt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4ClippableLinearc                ó@   <€ V ^8„  d   QhRS[ S[,          RS[RS[RR/# )r@   rA   Úin_featuresÚout_featuresrG   N)r>   r;   Úint)rK   rl   s   "€rL   rM   Ú"Gemma4ClippableLinear.__annotate__Ú   s?   ø€ ÷ Dñ Dá"Ñ%6Õ6ðDñ ðDñ ð	Dð
 
ñDrN   c                ól  <€ \         SV `  4        VP                  V n        \        P                  ! W#R R7      V n        V P                  '       då   \        P                  ! \        P                  ! \        R4      ) 4      4      V n
        \        P                  ! \        P                  ! \        R4      4      4      V n        \        P                  ! \        P                  ! \        R4      ) 4      4      V n        \        P                  ! \        P                  ! \        R4      4      4      V n        R# R# )F©ÚbiasÚinfN)ÚsuperÚ__init__Úuse_clipped_linearsr   ÚLinearÚlinearÚBufferrH   ÚtensorÚfloatÚ	input_minÚ	input_maxÚ
output_minÚ
output_max)ÚselfrA   rˆ   r‰   Ú	__class__s   &&&&€rL   r‘   ÚGemma4ClippableLinear.__init__Ú   s¹   ø€ ô 	‰ÑÔØ#)×#=Ñ#=ˆÔ Ü—i’i ÀÔFˆŒà×#×#Ð#ÜŸYšY¤u§|¢|´U¸5³\°MÓ'BÓCˆDŒNÜŸYšY¤u§|¢|´E¸%³LÓ'AÓBˆDŒNÜ Ÿiši¬¯ª´e¸E³l°]Ó(CÓDˆDŒOÜ Ÿiši¬¯ª´U¸5³\Ó(BÓCˆDŽOñ	 $rN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# ©r@   Úhidden_statesrG   ©rH   rI   )rK   rl   s   "€rL   rM   r‹   ê   s#   ø€ ÷ 	ñ 	¡U§\¡\ð 	±e·l±lñ 	rN   c                ó  € V P                   '       d,   \        P                  ! WP                  V P                  4      pV P                  V4      pV P                   '       d,   \        P                  ! WP                  V P                  4      pV# ©N)r’   rH   Úclampr˜   r™   r”   rš   r›   )rœ   r¡   s   &&rL   ÚforwardÚGemma4ClippableLinear.forwardê   s^   € Ø×#×#Ð#Ü!ŸKšK¨·~±~ÀtÇ~Á~ÓVˆMàŸ™ MÓ2ˆà×#×#Ð#Ü!ŸKšK¨·±ÈÏÉÓXˆMàÐrN   )r™   r˜   r”   r›   rš   r’   ©	ro   rp   rq   rr   r‘   r¦   ru   rv   Ú__classcell__©r�   rl   s   @@rL   r†   r†   Ù   s    ù‡ € ÷Dó D÷ 	÷ 	ð 	rN   r†   c                   ó   € ] tR t^ötRtR# )ÚGemma4RMSNormrV   N©ro   rp   rq   rr   ru   rV   rN   rL   r¬   r¬   ö   ó   † ÛrN   r¬   c                   óˆ   a a€ ] tR t^út oRtV3R lV 3R llt]P                  ! 4       V3R lR l4       tV3R lt	Rt
VtV ;t# )Ú Gemma4AudioRelPositionalEncodingzáSinusoidal relative positional encoding for the audio encoder.

Produces position embeddings of shape [1, context_size // 2 + 1, hidden_size] with
concatenated [sin..., cos...] layout matching the original Gemma4 convention.
c                ó    <€ V ^8„  d   QhRS[ /# ©r@   rA   ©r;   )rK   rl   s   "€rL   rM   Ú-Gemma4AudioRelPositionalEncoding.__annotate__  s   ø€ ÷ dñ dÑ0ñ drN   c                ó8  <€ \         SV `  4        VP                  V n        VP                  VP                  ,           ^,
          VP
                  ,           V n        RpRpV P                  ^,          p\        P                  ! W2,          4      \        V^,
          ^4      ,          pV\        P                  ! \        P                  ! V4      V) ,          4      ,          p\        P                  ! VP                  ^ 4      P                  ^ 4      RR7      V n        R# )é   ç      ð?ç     ˆÃ@F©Ú
persistentN)r�   r‘   Úhidden_sizeÚattention_chunk_sizeÚattention_context_leftÚattention_context_rightÚcontext_sizeÚmathÚlogÚmaxrH   ÚexpÚaranger   r•   Ú	unsqueezeÚinv_timescales)rœ   rA   Úmin_timescaleÚmax_timescaleÚnum_timescalesÚlog_timescale_incrementrÆ   r�   s   &&     €rL   r‘   Ú)Gemma4AudioRelPositionalEncoding.__init__  sÙ   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔà×'Ñ'¨&×*GÑ*GÕGÈ!ÕKÈf×NlÑNlÕlð 	Ôð ˆØˆØ×)Ñ)¨QÕ.ˆÜ"&§(¢(¨=Õ+HÓ"IÌCÐP^ÐabÕPbÐdeÓLfÕ"fÐØ&¬¯ª´5·<²<ÀÓ3OÐSjÐRjÕ3jÓ)kÕkˆÜ Ÿiši¨×(@Ñ(@ÀÓ(C×(MÑ(MÈaÓ(PÐ]bÔcˆÖrN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r    r¢   )rK   rl   s   "€rL   rM   r´     s#   ø€ ÷ 7ñ 7¡U§\¡\ð 7±e·l±lñ 7rN   c                ó’  € \         P                  ! V P                  ^,          RRVP                  R7      pVR,          pW P                  P                  VP                  R7      ,          p\         P                  ! \         P                  ! V4      \         P                  ! V4      .RR7      pVP                  VP                  R7      # )r@   ©Údevice©Údim©Údtypeéÿÿÿÿ©.N)
rH   rÄ   r¿   rÏ   rÆ   ÚtoÚcatÚsinÚcosrÓ   )rœ   r¡   rE   Úscaled_timeÚ	pos_embeds   &&   rL   r¦   Ú(Gemma4AudioRelPositionalEncoding.forward  s’   € ä—|’| D×$5Ñ$5¸Õ$:¸BÀÈ=×K_ÑK_Ô`ˆØ# IÕ.ˆØ"×%8Ñ%8×%;Ñ%;À=×CWÑCWÐ%;Ó%XÕXˆÜ—I’IœuŸyšy¨Ó5´u·y²yÀÓ7MÐNÐTVÔWˆ	Ø�|‰| -×"5Ñ"5ˆ|Ó6Ð6rN   c                ó:   <€ V ^8„  d   Qh/ S[ P                  ;R&   # )r@   rÆ   r¢   )rK   rl   s   "€rL   rM   r´   ú   s   ø‡ ‚ ñ —L‘LÑ ò rN   )r¿   r»   rÆ   )ro   rp   rq   rr   rs   r‘   rH   Úno_gradr¦   rt   ru   rv   r©   rª   s   @@rL   r°   r°   ú   s7   ù‡ € ñ÷dó dð ‡]‚]ƒ_÷7ó ð7÷/ … rN   r°   c                   óŽ   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V3R lR ltV3R	 lR
 ltRV3R lR llt	Rt
VtV ;t# )ÚGemma4AudioAttentioni  z3Chunked local attention with relative position biasc                ó&   <€ V ^8„  d   QhRS[ RS[/# ©r@   rA   rQ   ©r;   rŠ   )rK   rl   s   "€rL   rM   Ú!Gemma4AudioAttention.__annotate__  s    ø€ ÷ añ aÑ0ð a¹Sñ arN   c                ó–  <€ \         SV `  4        Wn        W n        VP                  V n        VP                  VP                  ,          V n        VP                  V n	        V P                  R,          \        P                  ! ^4      ,          V n        \        P                  ! ^\        P                  ,           4      \        P                  ! ^4      ,          V n        VP                  V n        VP"                  ^,
          V n        VP&                  V n        V P                   V P$                  ,           V P(                  ,           V n        \-        WP                  V P                  V P                  ,          4      V n        \-        WP                  V P                  V P                  ,          4      V n        \-        WP                  V P                  V P                  ,          4      V n        \-        WP                  VP                  4      V n        \6        P8                  ! VP                  V P                  V P                  ,          RR7      V n        \6        P<                  ! \>        P@                  ! V P                  4      4      V n!        \6        PD                  ! \>        PF                  ! V P
                  4      RR7      V n$        R# )ç      à?Fr�   r¹   Nç      à¿)%r�   r‘   rA   rQ   Úattention_logit_capÚattention_logits_soft_capr»   Únum_attention_headsÚhead_dimÚ	num_headsrÀ   rÁ   Úq_scaleÚeÚk_scaler¼   Ú
chunk_sizer½   Úmax_past_horizonr¾   Úmax_future_horizonr¿   r†   Úq_projÚk_projÚv_projÚpostr   r“   Úrelative_k_projÚ	ParameterrH   ÚzerosÚper_dim_scaler•   r–   Úsoftcap©rœ   rA   rQ   r�   s   &&&€rL   r‘   ÚGemma4AudioAttention.__init__  sÌ  ø€ Ü‰ÑÔØŒØ"ŒØ)/×)CÑ)CˆÔ&Ø×*Ñ*¨f×.HÑ.HÕHˆŒØ×3Ñ3ˆŒàŸ™ tÕ+¬t¯xªx¸«{Õ:ˆŒÜ—x’x ¤D§F¡F¥
Ó+¬d¯hªh°q«kÕ9ˆŒà ×5Ñ5ˆŒØ &× =Ñ =ÀÕ AˆÔØ"(×"@Ñ"@ˆÔØ ŸO™O¨d×.CÑ.CÕCÀd×F]ÑF]Õ]ˆÔä+¨F×4FÑ4FÈÏÉÐY]×YfÑYfÕHfÓgˆŒÜ+¨F×4FÑ4FÈÏÉÐY]×YfÑYfÕHfÓgˆŒÜ+¨F×4FÑ4FÈÏÉÐY]×YfÑYfÕHfÓgˆŒÜ)¨&×2DÑ2DÀf×FXÑFXÓYˆŒ	ä!Ÿyšy¨×);Ñ);¸T¿^¹^ÈdÏmÉmÕ=[ÐbgÔhˆÔÜŸ\š\¬%¯+ª+°d·m±mÓ*DÓEˆÔä—y’y¤§¢¨d×.LÑ.LÓ!MÐZ_Ô`ˆŽrN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r    r¢   )rK   rl   s   "€rL   rM   rä   6  s'   ø€ ÷ pñ p©u¯|©|ð pÁÇÁñ prN   c           	     ó6  € VP                   w  r#rEW0P                  ,           ^,
          V P                  ,          pW`P                  ,          V,
          p\        P                  ! V^ ^ ^ ^ ^ V34      pVP	                  W&V P                  WE4      P                  4       # )z€Splits a `(batch_size, seq_len, num_heads, head_dim)` tensor into non-overlapping blocks of `chunk_size` along the sequence dim.)Úshaperð   ÚFÚpadÚreshapeÚ
contiguous)rœ   r¡   Ú
batch_sizeÚseq_lenrì   rë   Ú
num_blocksr  s   &&      rL   Ú_convert_to_blockÚ&Gemma4AudioAttention._convert_to_block6  s|   € à3@×3FÑ3FÑ0ˆ
˜YØ§¡Õ/°!Õ3¸¿¹ÕGˆ
ØŸ?™?Õ*¨WÕ4ˆÜŸš˜m¨a°°A°q¸!¸SÐ-AÓBˆØ×$Ñ$ Z¸T¿_¹_ÈiÓb×mÑmÓoÐorN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r    r¢   )rK   rl   s   "€rL   rM   rä   >  s#   ø€ ÷ *ñ *±E·L±Lð *ÁUÇ\Á\ñ *rN   c           
     óP  € VP                   w  r#rE\        P                  ! V^ ^ ^ ^ V P                  V P                  V P
                  ,           ^,
          34      pVP                  ^V P                  V P
                  4      p\        P                  ! VR^4      pVP                  4       # )z`Extracts overlapping context windows of `context_size` for every block, strided by `chunk_size`.rÔ   )r   r  r  rñ   rò   rð   Úunfoldr¿   rH   Úmovedimr  )rœ   r¡   r  r  rì   rë   s   &&    rL   Ú_extract_block_contextÚ+Gemma4AudioAttention._extract_block_context>  s‘   € à3@×3FÑ3FÑ0ˆ
˜YÜŸšØ˜A˜q ! Q¨×(=Ñ(=¸t×?VÑ?VÐY]×YhÑYhÕ?hÐklÕ?lÐmó
ˆð &×,Ñ,¨Q°×0AÑ0AÀ4Ç?Á?ÓSˆÜŸš m°R¸Ó;ˆØ×'Ñ'Ó)Ð)rN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# ©r@   ÚxrG   r¢   )rK   rl   s   "€rL   rM   rä   H  s'   ø€ ÷ Sñ S™EŸL™Lð S©U¯\©\ñ SrN   c                ó  € VP                   w  r#rEpV P                  p\        P                  ! V^ V^,           V,
          34      pVP	                  W#WEV^,           ,          4      pVRRWW,          13,          pVP	                  W#WEV4      # )zjRelative position shift for blocked attention. See appendix B of https://huggingface.co/papers/1901.02860..N)r   r¿   r  r  Úview)rœ   r  r  rì   r  Ú
block_sizeÚposition_lengthr¿   s   &&      rL   Ú
_rel_shiftÚGemma4AudioAttention._rel_shiftH  s‚   € àIJÏÉÑFˆ
˜z°Ø×(Ñ(ˆÜ�EŠE�!�a˜¨Õ)¨OÕ;Ð<Ó=ˆØ�F‰F�:¨*ÀLÐSTÕDTÕ6UÓVˆØˆcÐ.�ZÕ.Ð.Ð.Õ/ˆØ�v‰v�j¨ZÀ\ÓRÐRrN   c          
      ó¤   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[S[ P                  R3,          /# )r@   r¡   Úposition_embeddingsrC   NrG   )rH   rI   rƒ   rk   )rK   rl   s   "€rL   rM   rä   Q  sT   ø€ ÷ 1)ñ 1)á—|‘|ð1)ñ #Ÿ\™\ð1)ñ ×(Ñ(¨4Õ/ð	1)ñ
 
‰u�|‰|˜TÐ!Õ	"ñ1)rN   c                ó,  € VP                   w  rEpWEV P                  V P                  3pV P                  V4      P	                  4       P                  V4      pV P                  V4      P	                  4       P                  V4      p	V P                  V4      P	                  4       P                  V4      p
W€P                  ,          \        P                  ! V P                  4      ,          pW�P                  ,          p	V P                  V4      pV P                  V	4      p	V P                  V
4      p
VP                   ^,          pV P                  V4      pVP                  RV P                  V P                  4      pVP!                  VP"                  R7      pVP%                  ^ ^^^^4      pWÙP%                  ^ ^^^^4      ,          pVP'                  W@P                  RV P                  4      pWüP%                  ^^^ 4      ,          pVP'                  W@P                  W°P(                  R4      pV P+                  V4      pVV,           pVV P,                  ,          p\.        P0                  ! V4      pVV P,                  ,          pVe5   VP3                  VP5                  4       V P6                  P8                  4      p\        P:                  ! VR\.        P<                  R7      P!                  V
P"                  4      pVV
P%                  ^ ^^^^4      ,          pVP%                  ^ ^^^^4      P'                  WKV P(                  ,          R4      pVRRV13,          P?                  4       pV PA                  VP!                  VP"                  4      4      pVV3# )r¶   rÒ   N©rÑ   rÓ   ºNNNrÔ   )!r   rì   rë   ró   r—   r  rô   rõ   rí   r  Úsoftplusrú   rï   r  r  r÷   rÖ   rÓ   Úpermuter  rð   r  rû   rH   ÚtanhÚmasked_fillÚlogical_notrA   Úattention_invalid_logits_valueÚsoftmaxÚfloat32r  rö   )rœ   r¡   r  rC   r  Ú
seq_lengthr^   Úhidden_shapeÚquery_statesÚ
key_statesÚvalue_statesr  Úrelative_key_statesÚqueriesÚ	matrix_acÚqueries_flatÚ	matrix_bdÚattn_weightsÚattn_outputs   &&&&               rL   r¦   ÚGemma4AudioAttention.forwardQ  sï  € ð %2×$7Ñ$7Ñ!ˆ
 Ø"°·±ÀÇÁÐNˆà—{‘{ =Ó1×7Ñ7Ó9×>Ñ>¸|ÓLˆØ—[‘[ Ó/×5Ñ5Ó7×<Ñ<¸\ÓJˆ
Ø—{‘{ =Ó1×7Ñ7Ó9×>Ñ>¸|ÓLˆà#§l¡lÕ2´Q·Z²ZÀ×@RÑ@RÓ5SÕSˆØ§,¡,Õ.ˆ
à×-Ñ-¨lÓ;ˆØ×0Ñ0°Ó<ˆ
Ø×2Ñ2°<Ó@ˆØ!×'Ñ'¨Õ*ˆ
à"×2Ñ2Ð3FÓGÐØ1×6Ñ6°r¸4¿>¹>È4Ï=É=ÓYÐØ1×4Ñ4¸<×;MÑ;MÐ4ÓNÐà×&Ñ& q¨!¨Q°°1Ó5ˆØ×0Ñ0°°A°q¸!¸QÓ?Õ?ˆ	à—‘ z·>±>À2ÀtÇ}Á}ÓUˆØ ×#>Ñ#>¸qÀ!ÀQÓ#GÕGˆ	Ø×%Ñ% j·.±.À*ÏoÉoÐ_aÓbˆ	Ø—O‘O IÓ.ˆ	à  9Õ,ˆØ# d§l¡lÕ2ˆÜ—z’z ,Ó/ˆØ# d§l¡lÕ2ˆàÒ%Ø'×3Ñ3Ø×*Ñ*Ó,¨d¯k©k×.XÑ.XóˆLô —y’y °2¼U¿]¹]ÔK×NÑNÈ|×OaÑOaÓbˆØ" \×%9Ñ%9¸!¸QÀÀ1ÀaÓ%HÕHˆØ!×)Ñ)¨!¨Q°°1°aÓ8×@Ñ@ÀÐZ^×ZiÑZiÕMiÐkmÓnˆØ! ! [ j [ .Õ1×<Ñ<Ó>ˆØ—i‘i §¡¨}×/BÑ/BÓ CÓDˆà˜LÐ(Ð(rN   )ré   rð   rA   r¿   rë   rô   rï   rQ   rò   rñ   rì   rú   rö   ró   rí   r÷   rû   rõ   r¤   )ro   rp   rq   rr   rs   r‘   r  r  r  r¦   ru   rv   r©   rª   s   @@rL   rà   rà     sE   ù‡ € Ù=÷aó a÷4pð p÷*ð *÷Sð S÷1)÷ 1)ò 1)rN   rà   c                   óH   a a€ ] tR tRt oV 3R ltRV3R lR lltRtVtV ;t# )Ú'Gemma4AudioSubSampleConvProjectionLayeri…  c           	     óÖ   <€ \         SV `  4        \        P                  ! VVRR^RR7      V n        \        P
                  ! W#RRR7      V n        \        P                  ! 4       V n        R# )é   F)Úin_channelsÚout_channelsÚkernel_sizeÚstrideÚpaddingrŽ   T)ÚepsÚelementwise_affinerŽ   N)r6  r6  )r@   r@   )	r�   r‘   r   ÚConv2dÚconvÚ	LayerNormÚnormÚReLUÚact)rœ   r7  r8  Únorm_epsr�   s   &&&&€rL   r‘   Ú0Gemma4AudioSubSampleConvProjectionLayer.__init__†  sU   ø€ Ü‰ÑÔÜ—I’IØ#Ø%ØØØØô
ˆŒ	ô —L’L ÐPTÐ[`ÔaˆŒ	Ü—7’7“9ˆŽrN   c                ó\   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          /# )r@   r¡   ÚmaskNr¢   )rK   rl   s   "€rL   rM   Ú4Gemma4AudioSubSampleConvProjectionLayer.__annotate__“  s(   ø€ ÷ #ñ #¡U§\¡\ð #¹¿¹ÈÕ9Lñ #rN   c           
     ó   € Ve,   VP                  VP                  R7      pWR,          ,          pV P                  VP                  V P                  P                  P                  4      4      pV P                  V P                  VP                  ^ ^^^4      4      P                  ^ ^^^4      P                  4       4      pVe
   VR,          pW3# )NrÎ   )r  Nr  N)r  :NNr@   )	rÖ   rÏ   r?  ÚweightrÓ   rC  rA  r  r  )rœ   r¡   rG  s   &&&rL   r¦   Ú/Gemma4AudioSubSampleConvProjectionLayer.forward“  s³   € ØÒØ—7‘7 -×"6Ñ"6�7Ó7ˆDØ)Ð1AÕ,BÕBˆMàŸ	™	 -×"2Ñ"2°4·9±9×3CÑ3C×3IÑ3IÓ"JÓKˆØŸ™ §¡¨=×+@Ñ+@ÀÀAÀqÈ!Ó+LÓ!M×!UÑ!UÐVWÐYZÐ\]Ð_`Ó!a×!lÑ!lÓ!nÓoˆàÒØ˜•<ˆDàÐ"Ð"rN   )rC  r?  rA  r¤   r¨   rª   s   @@rL   r4  r4  …  s   ù‡ € õ÷#÷ #ò #rN   r4  c                   óT   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tRtVtV ;t# )Ú"Gemma4AudioSubSampleConvProjectioni¡  c                ó    <€ V ^8„  d   QhRS[ /# r²   r³   )rK   rl   s   "€rL   rM   Ú/Gemma4AudioSubSampleConvProjection.__annotate__¢  s   ø€ ÷ [ñ [Ñ0ñ [rN   c                ó°  <€ \         SV `  4        \        ^VP                  ^ ,          VP                  R7      V n        \        VP                  ^ ,          VP                  ^,          VP                  R7      V n        VP                  ^ ,          ^,          VP                  ^,          ,          p\        P                  ! W!P                  RR7      V n
        R# )r¶   )r7  r8  rD  Fr�   N)r�   r‘   r4  Úsubsampling_conv_channelsÚrms_norm_epsÚlayer0Úlayer1r   r“   r»   Úinput_proj_linear)rœ   rA   Úproj_input_dimr�   s   && €rL   r‘   Ú+Gemma4AudioSubSampleConvProjection.__init__¢  s©   ø€ Ü‰ÑÔÜ=ØØ×9Ñ9¸!Õ<Ø×(Ñ(ô
ˆŒô
 >Ø×8Ñ8¸Õ;Ø×9Ñ9¸!Õ<Ø×(Ñ(ô
ˆŒð
 !×:Ñ:¸1Õ=ÀÕBÀf×FfÑFfÐghÕFiÕiˆÜ!#§¢¨>×;MÑ;MÐTYÔ!ZˆÖrN   c                ó    <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[ P                  S[ P                  3,          /# )r@   Úinput_featuresÚinput_features_maskNrG   ©rH   rI   rk   )rK   rl   s   "€rL   rM   rO  ±  sH   ø€ ÷ ;ñ ;áŸ™ð;ñ #Ÿ\™\¨DÕ0ð;ñ 
‰u�|‰|™UŸ\™\Ð)Õ	*ñ	;rN   c                ó  € VP                  ^4      pV P                  W24      w  r4V P                  W44      w  r4VP                  w  rVrvVP	                  ^ ^^^4      P                  4       P                  WWR4      pV P                  V4      V3# )r¶   rÔ   )rÅ   rS  rT  r   r  r  r  rU  )rœ   rY  rZ  r¡   rG  r  r^   r  s   &&&     rL   r¦   Ú*Gemma4AudioSubSampleConvProjection.forward±  s‰   € ð
 '×0Ñ0°Ó3ˆØ"Ÿk™k¨-ÓMÑˆØ"Ÿk™k¨-Ó>Ñˆà$1×$7Ñ$7Ñ!ˆ
�wØ%×-Ñ-¨a°°A°qÓ9×DÑDÓF×NÑNÈzÐdfÓgˆØ×%Ñ% mÓ4°dÐ:Ð:rN   )rU  rS  rT  r¤   r¨   rª   s   @@rL   rM  rM  ¡  s    ù‡ € ÷[ó [÷;÷ ;ò ;rN   rM  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4AudioFeedForwardi¿  c                ó    <€ V ^8„  d   QhRS[ /# r²   r³   )rK   rl   s   "€rL   rM   Ú#Gemma4AudioFeedForward.__annotate__À  s   ø€ ÷ 7ñ 7Ñ0ñ 7rN   c                óÄ  <€ \         SV `  4        Wn        \        WP                  VP                  ^,          4      V n        \        WP                  ^,          VP                  4      V n        \        VP                  4      V n        \        VP                  4      V n	        \        VP                  ,          V n        VP                  V n        VP                  V n        R# )é   N)r�   r‘   rA   r†   r»   Úffw_layer_1Úffw_layer_2r¬   Úpre_layer_normÚpost_layer_normr
   Ú
hidden_actÚact_fnÚgradient_clippingÚresidual_weightÚpost_layer_scale©rœ   rA   r�   s   &&€rL   r‘   ÚGemma4AudioFeedForward.__init__À  s©   ø€ Ü‰ÑÔØŒä0°×9KÑ9KÈV×M_ÑM_ÐbcÕMcÓdˆÔÜ0°×9KÑ9KÈaÕ9OÐQW×QcÑQcÓdˆÔä+¨F×,>Ñ,>Ó?ˆÔÜ,¨V×-?Ñ-?Ó@ˆÔÜ˜V×.Ñ.Õ/ˆŒà!'×!9Ñ!9ˆÔØ &× 6Ñ 6ˆÖrN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r    r¢   )rK   rl   s   "€rL   rM   ra  Î  ó#   ø€ ÷ ñ ¡U§\¡\ð ±e·l±lñ rN   c                óÄ  € \        V P                  \        P                  ! VP                  4      P
                  4      pTp\        P                  ! W) V4      pV P                  V4      pV P                  V4      pV P                  V4      pV P                  V4      p\        P                  ! W) V4      pV P                  V4      pWP                  ,          pW,          pV# r¤   )Úminrj  rH   ÚfinforÓ   rÂ   r¥   rf  rd  ri  re  rg  rl  )rœ   r¡   rj  Úresiduals   &&  rL   r¦   ÚGemma4AudioFeedForward.forwardÎ  sÁ   € ä × 6Ñ 6¼¿ºÀM×DWÑDWÓ8X×8\Ñ8\Ó]Ðà ˆÜŸš MÐ3EÐGXÓYˆØ×+Ñ+¨MÓ:ˆà×(Ñ(¨Ó7ˆØŸ™ MÓ2ˆØ×(Ñ(¨Ó7ˆäŸš MÐ3EÐGXÓYˆØ×,Ñ,¨]Ó;ˆØ×.Ñ.Õ.ˆØÕ!ˆàÐrN   )ri  rA   rd  re  rj  rg  rl  rf  r¨   rª   s   @@rL   r_  r_  ¿  s   ù‡ € ÷7ó 7÷÷ ð rN   r_  c                   óN   a a€ ] tR tRt o]R 4       tV3R lV 3R lltRtVtV ;t	# )ÚGemma4AudioCausalConv1diã  c                ó¦   € V P                   ^ ,          ^,
          V P                  ^ ,          ,          ^,           pWP                  ^ ,          ,
          # ©r   )r9  Údilationr:  )rœ   Úeffective_kernel_sizes   & rL   Úleft_padÚ Gemma4AudioCausalConv1d.left_padñ  s<   € à!%×!1Ñ!1°!Õ!4°qÕ!8¸D¿M¹MÈ!Õ<LÕ LÈqÕ PÐØ$§{¡{°1¥~Õ5Ð5rN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r  r¢   )rK   rl   s   "€rL   rM   Ú$Gemma4AudioCausalConv1d.__annotate__ö  s'   ø€ ÷ "ñ "á�<‰<ð"ñ 
�‰ñ	"rN   c                óx   <€ \         P                  P                  WP                  ^ 34      p\        SV `  V4      # ry  )r   r   r  r|  r�   r¦   )rœ   r  r�   s   &&€rL   r¦   ÚGemma4AudioCausalConv1d.forwardö  s1   ø€ ô �M‰M×Ñ˜a§-¡-°Ð!3Ó4ˆä‰w‰˜qÓ!Ð!rN   rV   )
ro   rp   rq   rr   r   r|  r¦   ru   rv   r©   rª   s   @@rL   rw  rw  ã  s(   ù‡ € ð ñ6ó ð6÷"÷ "ó "rN   rw  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4AudioLightConv1di  c                ó    <€ V ^8„  d   QhRS[ /# r²   r³   )rK   rl   s   "€rL   rM   Ú#Gemma4AudioLightConv1d.__annotate__  s   ø€ ÷ :ñ :Ñ0ñ :rN   c                óB  <€ \         SV `  4        Wn        \        WP                  VP                  ^,          4      V n        \        WP                  VP                  4      V n        \        VP                  VP                  VP                  VP                  RR7      V n	        \        VP                  VP                  RR7      V n        \        VP                  VP                  RR7      V n        \        VP                  ,          V n        VP"                  V n        R# )r@   F)r7  r8  r9  ÚgroupsrŽ   T©r<  Ú
with_scaleN)r�   r‘   rA   r†   r»   Úlinear_startÚ
linear_endrw  Úconv_kernel_sizeÚdepthwise_conv1dr¬   rR  rf  Ú	conv_normr
   rh  ri  rj  rm  s   &&€rL   r‘   ÚGemma4AudioLightConv1d.__init__  sß   ø€ Ü‰ÑÔØŒä1°&×:LÑ:LÈf×N`ÑN`ÐcdÕNdÓeˆÔÜ/°×8JÑ8JÈF×L^ÑL^Ó_ˆŒÜ 7Ø×*Ñ*Ø×+Ñ+Ø×/Ñ/Ø×%Ñ%Øô!
ˆÔô ,¨F×,>Ñ,>ÀF×DWÑDWÐdhÔiˆÔÜ& v×'9Ñ'9¸v×?RÑ?RÐ_cÔdˆŒÜ˜V×.Ñ.Õ/ˆŒà!'×!9Ñ!9ˆÖrN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# r    r¢   )rK   rl   s   "€rL   rM   r…    rp  rN   c                ó  € TpV P                  V4      pV P                  V4      p\        P                  P	                  VRR7      pV P                  VP                  ^^4      4      P                  ^^4      p\        V P                  \        P                  ! VP                  4      P                  4      p\        P                  ! W) V4      pV P                  V4      pV P                  V4      pV P!                  V4      pW,          pV# )r¶   rÐ   rÔ   )rf  rŠ  r   r   Úglur�  Ú	transposerr  rj  rH   rs  rÓ   rÂ   r¥   rŽ  ri  r‹  )rœ   r¡   rt  rj  s   &&  rL   r¦   ÚGemma4AudioLightConv1d.forward  sâ   € Ø ˆà×+Ñ+¨MÓ:ˆØ×)Ñ)¨-Ó8ˆÜŸ™×)Ñ)¨-¸RÐ)Ó@ˆà×-Ñ-¨m×.EÑ.EÀaÈÓ.KÓL×VÑVÐWXÐZ[Ó\ˆô   × 6Ñ 6¼¿ºÀM×DWÑDWÓ8X×8\Ñ8\Ó]ÐÜŸš MÐ3EÐGXÓYˆØŸ™ }Ó5ˆàŸ™ MÓ2ˆØŸ™¨Ó6ˆØÕ!ˆØÐrN   )ri  rA   rŽ  r�  rj  r‹  rŠ  rf  r¨   rª   s   @@rL   rƒ  rƒ    s   ù‡ € ÷:ó :÷(÷ ð rN   rƒ  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4AudioLayeri-  c                ó&   <€ V ^8„  d   QhRS[ RS[/# râ   rã   )rK   rl   s   "€rL   rM   ÚGemma4AudioLayer.__annotate__.  s   ø€ ÷ :ñ :Ñ0ð :¹Sñ :rN   c                ón  <€ \         SV `  4        Wn        \        V4      V n        \        V4      V n        \        W4      V n        \        V4      V n	        \        VP                  4      V n        \        VP                  4      V n        \        VP                  4      V n        VP                  V n        R # r¤   )r�   r‘   rA   r_  Úfeed_forward1Úfeed_forward2rà   Ú	self_attnrƒ  Úlconv1dr¬   r»   Únorm_pre_attnÚnorm_post_attnÚnorm_outrj  rü   s   &&&€rL   r‘   ÚGemma4AudioLayer.__init__.  s‹   ø€ Ü‰ÑÔØŒä3°FÓ;ˆÔÜ3°FÓ;ˆÔÜ-¨fÓ@ˆŒÜ-¨fÓ5ˆŒä*¨6×+=Ñ+=Ó>ˆÔÜ+¨F×,>Ñ,>Ó?ˆÔÜ% f×&8Ñ&8Ó9ˆŒà!'×!9Ñ!9ˆÖrN   c          
      ó¦   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  RS[S[,          RS[ P                  /# )r@   r¡   rC   Nr  ÚkwargsrG   )rH   rI   rƒ   r   r   )rK   rl   s   "€rL   rM   r˜  =  sZ   ø€ ÷  ñ  á—|‘|ð ñ ×(Ñ(¨4Õ/ð ñ #Ÿ\™\ð	 ñ
 Ñ+Õ,ð ñ 
�‰ñ rN   c                óF  € \        V P                  \        P                  ! V P                  P
                  P                  4      P                  4      pV P                  V4      pTp\        P                  ! W) V4      pV P	                  V4      pV P                  VVVR 7      w  r\        P                  ! W) V4      pV P                  V4      pW,          pV P                  V4      pV P                  V4      p\        P                  ! W) V4      pV P                  V4      pV# ))r¡   r  rC   )rr  rj  rH   rs  rž  rJ  rÓ   rÂ   rš  r¥   rœ  rŸ  r�  r›  r   )rœ   r¡   rC   r  r£  rj  rt  r^   s   &&&&,   rL   r¦   ÚGemma4AudioLayer.forward=  s  € ô   × 6Ñ 6¼¿ºÀD×DVÑDV×D]ÑD]×DcÑDcÓ8d×8hÑ8hÓiÐà×*Ñ*¨=Ó9ˆØ ˆäŸš MÐ3EÐGXÓYˆØ×*Ñ*¨=Ó9ˆàŸ>™>Ø'Ø 3Ø)ð *ó 
Ñˆô Ÿš MÐ3EÐGXÓYˆØ×+Ñ+¨MÓ:ˆØÕ!ˆàŸ™ ]Ó3ˆØ×*Ñ*¨=Ó9ˆäŸš MÐ3EÐGXÓYˆØŸ™ mÓ4ˆàÐrN   )	rA   rš  r›  rj  r�  r   rŸ  rž  rœ  r¨   rª   s   @@rL   r–  r–  -  s   ù‡ € ÷:ó :÷ ÷  ð  rN   r–  c                   ób   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltV3R lR ltRtVtV ;t	# )	ÚGemma4VisionPatchEmbedderic  c                ó    <€ V ^8„  d   QhRS[ /# r²   ©r>   )rK   rl   s   "€rL   rM   Ú&Gemma4VisionPatchEmbedder.__annotate__d  s   ø€ ÷ tñ tÑ1ñ trN   c                ó   <€ \         SV `  4        Wn        VP                  V n        VP                  V n        VP
                  V n        \        P                  ! ^V P                  ^,          ,          V P                  RR7      V n        \        P                  ! \        P                  ! ^V P
                  V P                  4      4      V n        R# )r6  Fr�   N)r�   r‘   rA   r»   Ú
patch_sizeÚposition_embedding_sizer   r“   Ú
input_projrø   rH   ÚonesÚposition_embedding_tablerm  s   &&€rL   r‘   Ú"Gemma4VisionPatchEmbedder.__init__d  s�   ø€ Ü‰ÑÔØŒØ!×-Ñ-ˆÔØ ×+Ñ+ˆŒØ'-×'EÑ'EˆÔ$äŸ)š) A¨¯©¸Õ(:Õ$:¸D×<LÑ<LÐSXÔYˆŒÜ(*¯ª´U·Z²ZÀÀ4×C_ÑC_Ðae×aqÑaqÓ5rÓ(sˆÖ%rN   c                óh   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  /# )r@   Úpixel_position_idsÚpadding_positionsrG   r¢   )rK   rl   s   "€rL   rM   rª  n  s4   ø€ ÷ #ñ #±u·|±|ð #ÑX]×XdÑXdð #Ñin×iuÑiuñ #rN   c                óD  € VP                  ^ R7      p\        P                  ! VR,          V P                  ^ ,          4      p\        P                  ! VR,          V P                  ^,          4      pWE,           p\        P
                  ! VP                  R4      RV4      pV# )aC  Compute 2-D patch position embeddings via embedding lookup.

``pixel_position_ids`` has shape ``(batch, num_patches, 2)`` where the
last dimension holds (x, y) indices into ``position_embedding_table``
(shape ``(2, position_embedding_size, hidden_size)``).  The result is the
sum of the x- and y-embeddings for each patch.
©rr  ç        ©.r   ©.r¶   rÔ   )r¥   r  Ú	embeddingr°  rH   ÚwhererÅ   )rœ   r³  r´  Úclamped_positionsÚx_embÚy_embr  s   &&&    rL   Ú_position_embeddingsÚ.Gemma4VisionPatchEmbedder._position_embeddingsn  sŒ   € ð /×4Ñ4¸Ð4Ó;Ðô —’Ð-¨fÕ5°t×7TÑ7TÐUVÕ7WÓXˆÜ—’Ð-¨fÕ5°t×7TÑ7TÐUVÕ7WÓXˆØ#�mÐÜ#ŸkškÐ*;×*EÑ*EÀbÓ*IÈ3ÐPcÓdÐØ"Ð"rN   c                ó‚   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[ P                  /# )r@   Úpixel_valuesr³  r´  rG   r¢   )rK   rl   s   "€rL   rM   rª  „  s?   ø€ ÷ 	3ñ 	3Ù!ŸL™Lð	3Ù>C¿l¹lð	3Ù_d×_kÑ_kð	3á	�‰ñ	3rN   c                óü   € ^VR,
          ,          pV P                   P                  P                  ;pP                  '       d   VP	                  V4      pV P                  V4      pV P                  W#4      pWV,           # )r@   ræ   )r®  rJ  rÓ   Úis_floating_pointrÖ   r¿  )rœ   rÂ  r³  r´  Útarget_dtyper¡   r  s   &&&&   rL   r¦   Ú!Gemma4VisionPatchEmbedder.forward„  sk   € ð ˜L¨3Õ.Õ/ˆØ ŸO™O×2Ñ2×8Ñ8Ð8ˆL×K×KÐKØ'Ÿ?™?¨<Ó8ˆLØŸ™¨Ó5ˆØ"×7Ñ7Ð8JÓ^ÐØÕ2Ð2rN   )rA   r»   r®  r¬  r­  r°  )
ro   rp   rq   rr   r‘   r¿  r¦   ru   rv   r©   rª   s   @@rL   r§  r§  c  s*   ù‡ € ÷tó t÷#ð #÷,	3÷ 	3ð 	3rN   r§  c                   ój   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
V3R lR lltR	tVt	V ;t
# )ÚGemma4VisionPooleri�  aK  Spatial pooling and ``sqrt(hidden_size)`` scaling for vision encodings.

The scaling expands the activation magnitude, which can exceed the float16 range, so it is
computed in float32 and the pooled features are returned in float32. The caller
(``Gemma4VisionModel.forward``) standardizes them and casts back to the working dtype.
c                ó    <€ V ^8„  d   QhRS[ /# r²   r©  )rK   rl   s   "€rL   rM   ÚGemma4VisionPooler.__annotate__˜  s   ø€ ÷ 6ñ 6Ñ1ñ 6rN   c                óv   <€ \         SV `  4        VP                  V n        V P                  R ,          V n        R# )ræ   N)r�   r‘   r»   Úroot_hidden_sizerm  s   &&€rL   r‘   ÚGemma4VisionPooler.__init__˜  s/   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔØ $× 0Ñ 0°#Õ 5ˆÖrN   c          
      ó˜   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[RS[S[ P                  S[ P                  3,          /# )r@   r¡   r³  ÚlengthrG   ©rH   rI   rŠ   rk   )rK   rl   s   "€rL   rM   rÊ  �  sG   ø€ ÷ 4ñ 4Ù"Ÿ\™\ð4Ù?D¿|¹|ð4ÙUXð4á	‰u�|‰|™UŸ\™\Ð)Õ	*ñ4rN   c                ó  € VP                   ^,          p\        WC,          R,          4      pV^,          pWc,          V8w  d(   \        RVP                    RV RV: RV: RV R24      hVP                  ^ R7      pVR,          P	                  RR	R
7      ^ ,          ^,           p\
        P                  ! WuRR7      p	V	R,          W…,          V	R,          ,          ,           p	\        P                  ! V	P                  4       V4      P                  4       V,          p
V
P                  ^^4      VP                  4       ,          p\
        P                  ! V
^ 8H  P                  ^R7      4      pVP                  VP                  4      V3# )z¹
2D spatial pooling according to patch positions.
Pools the input tokens by averaging patches within a `k^2` grid, where `k` is determined by the ratio between
input and output lengths
ræ   zCannot pool z to z: k=z^2 times length=z	 must be Ú.r¶  T©rÑ   ÚkeepdimÚfloor)Úrounding_moderÐ   r¸  rÔ   r¹  )r   rŠ   Ú
ValueErrorr¥   rÂ   rH   Údivr  Úone_hotÚlongr—   r“  r"  ÚallrÖ   rÓ   )rœ   r¡   r³  rÏ  Úinput_seq_lenÚkÚ	k_squaredr¼  Úmax_xÚkernel_idxsÚweightsÚoutputrG  s   &&&&         rL   Ú_avg_pool_by_positionsÚ)Gemma4VisionPooler._avg_pool_by_positions�  s`  € ð &×+Ñ+¨AÕ.ˆÜ�Õ(¨SÕ0Ó1ˆØ�q•Dˆ	ØÕ Ô.ÜØ˜}×2Ñ2Ð3°4¸°x¸uÀ!ÁÐEVÈvÉiÐW`ÐanÐ`oÐopÐqóð ð /×4Ñ4¸Ð4Ó;ÐØ! &Õ)×-Ñ-°"¸dÐ-ÓCÀAÕFÈÕJˆÜ—i’iÐ 1ÀGÔLˆØ! &Õ)¨U­Z¸;ÀvÕ;NÕ,NÕNˆÜ—)’)˜K×,Ñ,Ó.°Ó7×=Ñ=Ó?À)ÕKˆØ×"Ñ" 1 aÓ(¨=×+>Ñ+>Ó+@Õ@ˆÜ× Ò  '¨Q¡,×!3Ñ!3¸Ð!3Ó!:Ó;ˆØ�y‰y˜×,Ñ,Ó-¨tÐ3Ð3rN   c                óÀ   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  RS[R,          RS[S[ P                  S[ P                  3,          /# )r@   r¡   r³  r´  Úoutput_lengthNrG   rÐ  )rK   rl   s   "€rL   rM   rÊ  ¸  s_   ø€ ÷ 0ñ 0á—|‘|ð0ñ "ŸL™Lð0ñ !Ÿ<™<ð	0ñ
 ˜T•zð0ñ 
‰u�|‰|™UŸ\™\Ð)Õ	*ñ0rN   c                óX  € WAP                   ^,          8”  d$   \        RV RVP                   ^,           R24      hVP                  VP                  R4      R4      pVP                   ^,          V8w  d   V P	                  WV4      w  rVP                  4       V P                  ,          pW3# )r¶   z*Cannot output more soft tokens (requested z) than there are patches (z9). Change the value of `num_soft_tokens` when processing.r·  rÔ   )r   r×  r!  rÅ   rã  r—   rÌ  )rœ   r¡   r³  r´  ræ  s   &&&&&rL   r¦   ÚGemma4VisionPooler.forward¸  s¹   € ð ×.Ñ.¨qÕ1Ô1ÜØ<¸]¸Oð LØ"×(Ñ(¨Õ+Ð,Ð,eðgóð ð
 &×1Ñ1Ð2C×2MÑ2MÈbÓ2QÐSVÓWˆà×Ñ˜qÕ! ]Ô2Ø/3×/JÑ/JØ°=ó0Ñ,ˆMð &×+Ñ+Ó-°×0EÑ0EÕEˆØÐ/Ð/rN   )r»   rÌ  r¤   )ro   rp   rq   rr   rs   r‘   rã  r¦   ru   rv   r©   rª   s   @@rL   rÈ  rÈ  �  s-   ù‡ € ñ÷6ó 6÷
4ð 4÷60÷ 0ò 0rN   rÈ  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚGemma4VisionMLPiÓ  c                ó    <€ V ^8„  d   QhRS[ /# r²   r©  )rK   rl   s   "€rL   rM   ÚGemma4VisionMLP.__annotate__Ô  s   ø€ ÷ añ aÑ1ñ arN   c                ó  <€ \         SV `  W4       \        WP                  V P                  4      V n        \        WP                  V P                  4      V n        \        WP                  V P                  4      V n        R # r¤   )r�   r‘   r†   r»   Úintermediate_sizeÚ	gate_projÚup_projÚ	down_projrm  s   &&€rL   r‘   ÚGemma4VisionMLP.__init__Ô  s^   ø€ Ü‰Ñ˜Ô&Ü.¨v×7GÑ7GÈ×I_ÑI_Ó`ˆŒÜ,¨V×5EÑ5EÀt×G]ÑG]Ó^ˆŒÜ.¨v×7MÑ7MÈt×O_ÑO_Ó`ˆŽrN   )rñ  rï  rð  ©ro   rp   rq   rr   r‘   ru   rv   r©   rª   s   @@rL   rê  rê  Ó  s   ù‡ € ÷a÷ aó arN   rê  c                óÄ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\         P                  R\        R\         P                  /# )r@   r  rÙ   rØ   rE   Úunsqueeze_dimrG   )rH   rI   rŠ   )rK   s   "rL   rM   rM   Û  sX   € ÷ 5&ñ 5&Ü‡|�|ð5&ä	�‰ð5&ô 
�‰ð5&ô —,‘,ð	5&ô
 ð5&ô ‡\�\ñ5&rN   c           
     ó  € VP                   R,          pV P                   R,          p^V^V,          ,          ,          pV^ 8:  d   \        RV RV RV R24      hV.V,          p\        P                  ! WRR7      p	\        P                  ! WRR7      p
\        P                  ! W(RR7      p\	        V4       Uu. uF$  p\        Wœ,          W¬,          W¼,          VR7      NK&  	  pp\        P                  ! VRR7      # u upi )a#  Applies multidimensional RoPE to inputs.

Args:
    x (`torch.Tensor`): The tensor to embed.
    cos (`torch.Tensor`): The cosine part of the rotary embedding.
    sin (`torch.Tensor`): The sine part of the rotary embedding.
    position_ids (`torch.Tensor`, *optional*):
        If position_ids.ndim + 2 == x.ndim, then this function passes through to `apply_rotary_pos_emb()`.
        Otherwise, position_ids is used to split the inputs, x, into multiple pieces, where each piece is fed to
        `apply_rotary_pos_emb()`, and then concatenated back together.
    unsqueeze_dim (`int`, *optional*, defaults to 1):
        The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
        sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
        that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
        k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
        cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
        the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.

Returns:
  Tensor of shape [B, L, N, H] with RoPE applied.
zEInvalid configuration: num_rotated_channels_per_dim must be > 0, got z (num_input_channels=z, ndim=Ú)rÐ   )r  rÙ   rØ   rõ  rÔ   )r   r×  rH   ÚsplitÚranger6   r×   )r  rÙ   rØ   rE   rõ  ÚndimÚnum_input_channelsÚnum_rotated_channels_per_dimÚsplit_sizesÚx_partsÚ	cos_partsÚ	sin_partsrÝ  Úy_partss   &&&&&         rL   Úapply_multidimensional_roper  Û  s
  € ð8 ×Ñ˜bÕ!€DØŸ™ �ÐØ#$Ð(:¸qÀ4½xÕ(HÕ#IÐ à# qÔ(ÜðØ,Ð-Ð-BÐCUÐBVð WØ�F˜!ðó
ð 	
ð 0Ð0°4Õ7€KÜ�kŠk˜!¨bÔ1€GÜ—’˜C°"Ô5€IÜ—’˜C°"Ô5€Iô �t”óñ ˆAô 	Ø�jØ•Ø•Ø'÷		
ñ ð ð ô �9Š9�W "Ô%Ð%ùòs   Â9*C=c                   ój   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V 3R llltR tR tRtVt	V ;t
# )
ÚGemma4VisionRotaryEmbeddingi  c                ó    <€ V ^8„  d   QhRS[ /# r²   r©  )rK   rl   s   "€rL   rM   Ú(Gemma4VisionRotaryEmbedding.__annotate__  s   ø€ ÷ )ñ )Ñ1ñ )rN   c                ó&   <€ \         SV `  W4       R # r¤   )r�   r‘   )rœ   rA   rÏ   r�   s   &&&€rL   r‘   Ú$Gemma4VisionRotaryEmbedding.__init__  s   ø€ Ü‰Ñ˜Ö(rN   c                óP   <€ V ^8„  d   QhRS[ RS[S[P                  S[3,          /# )r@   rA   rG   )r>   rk   rH   rI   r—   )rK   rl   s   "€rL   rM   r    s3   ø€ ÷ Oñ OÑ.@ð OÑ\aÑbg×bnÑbnÑpuÐbuÕ\vñ OrN   c                ó&   <€ \         SV `  ! W3/ VB # r¤   )r�   Úcompute_axial_rope_parameters)rA   rÏ   r£  r�   s   &&,€rL   r  Ú9Gemma4VisionRotaryEmbedding.compute_axial_rope_parameters  s   ø€ Ü‰wÒ4°VÑNÀvÑNÐNrN   c                óÒ  € V P                   R,          P                  4       pVR,          P                  4       p\        VP                  P                  \
        4      '       d2   VP                  P                  R8w  d   VP                  P                  MRp\        VRR7      ;_uu_ 4        WC,          pVP                  4       V P                  ,          pVP                  4       V P                  ,          pR R R 4       V P                  X4      pV P                  X4      pVP                  VP                  4      VP                  VP                  4      3#   + '       g   i     Lh; i)NÚmpsÚcpuF)Údevice_typeÚenabled)N.rÕ   )Úinv_freqr—   Ú
isinstancerÏ   Útyperj   r"   rÙ   Úattention_scalingrØ   Úrecomposition_frequenciesrÖ   rÓ   )	rœ   r  rE   Úinv_freq_expandedÚposition_ids_expandedr  ÚfreqsrÙ   rØ   s	   &&&      rL   r¦   Ú#Gemma4VisionRotaryEmbedding.forward  sø   € Ø ŸM™M¨)Õ4×:Ñ:Ó<ÐØ ,¨YÕ 7× =Ñ =Ó ?Ðä'1°!·(±(·-±-Ä×'EÒ'EÈ!Ï(É(Ï-É-Ð[`ÔJ`�a—h‘h—m’mÐfkˆÜ¨¸U×CÖCØ)Õ=ˆEØ—)‘)“+ × 6Ñ 6Õ6ˆCØ—)‘)“+ × 6Ñ 6Õ6ˆC÷ Dð
 ×,Ñ,¨SÓ1ˆØ×,Ñ,¨SÓ1ˆØ�v‰v�a—g‘g‹ §¡ q§w¡w£Ð/Ð/÷ D×Cús   Â+AEÅE&	c                óX   € VR,          VR,          r2\         P                  ! W"W3.RR7      # )zM
Recompose the frequencies into the final spatial layout used per each grid.
rÐ   )r  r  r   )r  r  r¶   rÔ   )rH   r×   )rœ   ÚfreqÚfreq_hÚfreq_ws   &&  rL   r  Ú5Gemma4VisionRotaryEmbedding.recomposition_frequencies)  s)   € ð
 ˜g�¨¨W­�Ü�yŠy˜&¨&Ð9¸rÔBÐBrN   rV   r¤   )ro   rp   rq   rr   r‘   r  r¦   r  ru   rv   r©   rª   s   @@rL   r  r    s,   ù‡ € ÷)õ )÷Oõ Oò0÷Cò CrN   r  c                   óT   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tRtVtV ;t# )ÚGemma4VisionAttentioni2  c                ó&   <€ V ^8„  d   QhRS[ RS[/# râ   ©r>   rŠ   )rK   rl   s   "€rL   rM   Ú"Gemma4VisionAttention.__annotate__4  s    ø€ ÷ ^ñ ^Ñ1ð ^¹cñ ^rN   c                óN  <€ \         SV `  WV4       V =V =V =R V n        RV n        \        WP                  VP                  V P                  ,          4      V n        \        WP                  VP                  V P                  ,          4      V n        \        WP                  VP                  V P                  ,          4      V n        \        WP                  V P                  ,          VP                  4      V n        \!        V P                  VP"                  RR7      V n        R# )r·   Frˆ  N)r�   r‘   Úattn_logit_softcappingrY   rP   ÚscalingÚ	is_causalr†   r»   Únum_key_value_headsrë   rô   rê   ró   rõ   Úo_projr¬   rR  Úv_normrü   s   &&&€rL   r‘   ÚGemma4VisionAttention.__init__4  så   ø€ Ü‰Ñ˜ yÔ1ØÐ'ØÐØˆOØˆŒØˆŒÜ+¨F×4FÑ4FÈ×HbÑHbÐei×erÑerÕHrÓsˆŒÜ+¨F×4FÑ4FÈ×HbÑHbÐei×erÑerÕHrÓsˆŒÜ+¨F×4FÑ4FÈ×HbÑHbÐei×erÑerÕHrÓsˆŒÜ+¨F×4NÑ4NÐQU×Q^ÑQ^Õ4^Ð`f×`rÑ`rÓsˆŒÜ# D§M¡M°v×7JÑ7JÐW\Ô]ˆŽrN   c                ó<  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[S[ P                  S[ P                  R,          S[S[ P                  ,          R,          3,          /# ©r@   r¡   r  rC   NrE   r£  rG   )rH   rI   Ú
LongTensorr   r   rk   )rK   rl   s   "€rL   rM   r$  A  s�   ø€ ÷ ,)ñ ,)á—|‘|ð,)ñ #Ÿ\™\ð,)ñ Ÿ™ tÕ+ð	,)ñ
 ×&Ñ&¨Õ-ð,)ñ Ñ+Õ,ð,)ñ 
‰u�|‰|™UŸ\™\¨DÕ0±%¹¿¹Õ2EÈÕ2LÐLÕ	Mñ,)rN   c                óR  € VP                   R R p. VORNV P                  N5pVw  r‰V P                  V4      P                  V4      p
V P	                  V
4      p
\        W¨W”4      p
V
P                  ^^4      p
V P                  V4      P                  V4      pV P                  V4      p\        W¸W”4      pVP                  ^^4      pV P                  V4      P                  V4      pV P                  V4      pVP                  ^^4      p\        P                  ! V P                  P                  \        4      pT! V V
VVV3RV P                   '       d   V P"                  MRRV P$                  /VB w  rïVP&                  ! . VORN5!  P)                  4       pV P+                  V4      pWï3# )NÚdropoutr·  r'  rÔ   )r   rë   ró   r  Úq_normr  r“  rô   Úk_normrõ   r+  r   Úget_interfacerA   Ú_attn_implementationr7   ÚtrainingÚattention_dropoutr'  r  r  r*  )rœ   r¡   r  rC   rE   r£  Úinput_shaper'  rÙ   rØ   r(  r)  r*  Úattention_interfacer1  r0  s   &&&&&,          rL   r¦   ÚGemma4VisionAttention.forwardA  s£  € ð $×)Ñ)¨#¨2Ð.ˆØ8˜Ð8 bÐ8¨$¯-©-Ñ8ˆà&‰ˆà—{‘{ =Ó1×6Ñ6°|ÓDˆØ—{‘{ <Ó0ˆÜ2°<ÀcÓXˆØ#×-Ñ-¨a°Ó3ˆà—[‘[ Ó/×4Ñ4°\ÓBˆ
Ø—[‘[ Ó,ˆ
Ü0°À#ÓTˆ
Ø×)Ñ)¨!¨QÓ/ˆ
à—{‘{ =Ó1×6Ñ6°|ÓDˆØ—{‘{ <Ó0ˆØ#×-Ñ-¨a°Ó3ˆä(?×(MÒ(MØ�K‰K×,Ñ,Ô.Eó)
Ðñ %8ØØØØØñ	%
ð /3¯m¯m¨m�D×*Ò*Àð	%
ð —L‘Lð	%
ð ñ	%
Ñ!ˆð "×)Ò)Ð;¨;Ð;¸Ó;×FÑFÓHˆØ—k‘k +Ó.ˆØÐ(Ð(rN   )r(  rô   r*  ró   r'  r+  rõ   ©NNNr¨   rª   s   @@rL   r!  r!  2  s    ù‡ € ÷^ó ^÷,)÷ ,)ò ,)rN   r!  c                   óT   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tRtVtV ;t# )ÚGemma4VisionEncoderLayeriq  c                ó&   <€ V ^8„  d   QhRS[ RS[/# râ   r#  )rK   rl   s   "€rL   rM   Ú%Gemma4VisionEncoderLayer.__annotate__r  s   ø€ ÷ +ñ +Ñ1ð +¹cñ +rN   c                ój   <€ \         SV `  WV4       \        WR 7      V n        \	        V4      V n        R# ©©rA   rQ   N)r�   r‘   r!  rœ  rê  Úmlprü   s   &&&€rL   r‘   Ú!Gemma4VisionEncoderLayer.__init__r  s*   ø€ Ü‰Ñ˜ yÔ1Ü.°fÔRˆŒÜ" 6Ó*ˆŽrN   c                ó0  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[S[ P                  S[S[ P                  S[ P                  3,          R,          3,          /# r.  )rH   rI   r/  r   r   rk   ÚFloatTensor)rK   rl   s   "€rL   rM   r?  w  s•   ø€ ÷ ñ á—|‘|ðñ #Ÿ\™\ðñ Ÿ™ tÕ+ð	ñ
 ×&Ñ&¨Õ-ðñ Ñ+Õ,ðñ 
‰u× Ñ ¡%©×(9Ñ(9¹5×;LÑ;LÐ(LÕ"MÐPTÕ"TÐTÕ	UñrN   c                ó  € TpV P                  V4      pV P                  ! RR VRVRVRV/VB w  rV P                  V4      pWa,           pTpV P                  V4      pV P	                  V4      pV P                  V4      pWa,           pV# )r¡   r  rC   rE   rV   )Úinput_layernormrœ  Úpost_attention_layernormÚpre_feedforward_layernormrC  Úpost_feedforward_layernorm)rœ   r¡   r  rC   rE   r£  rt  r^   s   &&&&&,  rL   r¦   Ú Gemma4VisionEncoderLayer.forwardw  s³   € ð !ˆà×,Ñ,¨]Ó;ˆàŸ>š>ñ 
Ø'ð
à 3ð
ð *ð
ð &ð	
ð
 ñ
Ñˆð ×5Ñ5°mÓDˆØ Õ0ˆà ˆØ×6Ñ6°}ÓEˆØŸ™ Ó/ˆØ×7Ñ7¸ÓFˆØ Õ0ˆàÐrN   )rC  rœ  r;  r¨   rª   s   @@rL   r=  r=  q  s   ù‡ € ÷+ó +÷
÷ ò rN   r=  c                   óT   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tRtVtV ;t# )ÚGemma4VisionEncoderi–  c                ó    <€ V ^8„  d   QhRS[ /# r²   r©  )rK   rl   s   "€rL   rM   Ú Gemma4VisionEncoder.__annotate__—  s   ø€ ÷ 
ñ 
Ñ1ñ 
rN   c           
     ó  <€ \         SV `  4        Wn        VP                  V n        \        V4      V n        \        P                  ! \        V P                  4       Uu. uF  p\        WR 7      NK  	  up4      V n        R# u upi rA  )r�   r‘   rA   Únum_hidden_layersÚ
num_layersr  Ú
rotary_embr   Ú
ModuleListrù  r=  Úlayers)rœ   rA   Úir�   s   && €rL   r‘   ÚGemma4VisionEncoder.__init__—  se   ø€ Ü‰ÑÔØŒØ ×2Ñ2ˆŒÜ5°fÓ=ˆŒÜ—m’mÜKPÐQU×Q`ÑQ`ÔKaÓbÑKaÀaÔ%¨V×AÑKaÑbó
ˆŽùÚbs   ÁBc          
      ó’   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[S[,          RS[/# )r@   rB   rC   r³  Nr£  rG   )rH   rI   r/  r   r   r   )rK   rl   s   "€rL   rM   rP     s]   ø€ ÷ Hñ Há—|‘|ðHñ Ÿ™ðHñ "×,Ñ,¨tÕ3ð	Hñ
 Ñ+Õ,ðHñ 
!ñHrN   c           
     óâ   € \        V P                  VVR7      pTpV P                  WS4      pV P                  RV P                  P                    F  pV! V3RVRVRV/VB pK  	  \        VR7      # )zw
pixel_position_ids (torch.Tensor):
    Patch positions as (x, y) coordinates in the image as [batch, num_patches, 2].
)rA   rB   rC   NrC   r  rE   ©Úlast_hidden_state)r   rA   rT  rV  rR  r   )rœ   rB   rC   r³  r£  r¡   r  Údecoder_layers   &&&&,   rL   r¦   ÚGemma4VisionEncoder.forward   s”   € ô 3Ø—;‘;Ø'Ø)ô
ˆð &ˆØ"Ÿo™o¨mÓPÐð "Ÿ[™[Ð)H¨4¯;©;×+HÑ+HÓIˆMÙ)Øñà-ðð %8ðð 0ð	ð
 ñŠMñ Jô '¸ÔGÐGrN   )rA   rV  rS  rT  r¤   r¨   rª   s   @@rL   rN  rN  –  s!   ù‡ € ÷
ó 
÷H÷ Hò HrN   rN  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚGemma4TextMLPiÅ  c                ó&   <€ V ^8„  d   QhRS[ RS[/# râ   ©r=   rŠ   )rK   rl   s   "€rL   rM   ÚGemma4TextMLP.__annotate__Æ  s    ø€ ÷ ^ñ ^Ñ/ð ^¹Cñ ^rN   c                óø   <€ VP                   VP                  ,
          pY#u;8¬  ;'       d    ^ 8„  Mu pVP                  ;'       d    Tp\        SV `  4        VP
                  V'       d   ^M^,          V n        R# )r   N)rR  Únum_kv_shared_layersÚuse_double_wide_mlpr�   r‘   rî  )rœ   rA   rQ   Úfirst_kv_shared_layer_idxÚis_kv_shared_layerrf  r�   s   &&&   €rL   r‘   ÚGemma4TextMLP.__init__Æ  sd   ø€ Ø$*×$<Ñ$<¸v×?ZÑ?ZÕ$ZÐ!Ø&×GÔGÀaÔGÐØ$×8Ñ8×OÐOÐ=OÐÜ‰ÑÔØ!'×!9Ñ!9×BU¹QÐ[\Õ!]ˆÖrN   )rî  ró  rª   s   @@rL   r`  r`  Å  s   ù‡ € ÷^÷ ^ó ^rN   r`  c                   ó6   a € ] tR tRt o RV 3R lR lltRtV tR# )ÚGemma4TextRotaryEmbeddingiÎ  Nc                ó    <€ V ^8„  d   QhRS[ /# r²   ©r=   )rK   rl   s   "€rL   rM   Ú&Gemma4TextRotaryEmbedding.__annotate__Ï  s   ø€ ÷ Uñ UÑ/ñ UrN   c           
     óú  € \         P                  P                  V 4       VP                  V n        VP                  V n        Wn        \        \        VP                  4      4      V n	        / V n
        / V n        V P                   Fò  pV P                  P                  V,          pVf   K&  VR,          ;pR8w  d   \        V,          pMV P                  pW`P                  V&   WPP                  V&   VP                  V,          pV! WrVR7      w  r‰\!        W R2\         P"                  ! VRR7      4       \!        W R2\         P"                  ! VP%                  4       RR7      4       \!        W R2V	4       Kô  	  R # )	NÚ	rope_typeÚdefault©Ú
layer_typeÚ	_inv_freqFr¹   Ú_original_inv_freqÚ_attention_scaling)r   ÚModuler‘   Úmax_position_embeddingsÚmax_seq_len_cachedÚoriginal_max_seq_lenrA   ÚsortedÚsetÚlayer_typesÚrope_init_fnsrp  Úrope_parametersr   Úcompute_default_rope_parametersÚper_layer_configÚsetattrr•   Úclone)
rœ   rA   rÏ   rs  Úrope_paramsrp  Úrope_init_fnÚrope_configÚcurr_inv_freqÚcurr_attention_scalings
   &&&       rL   r‘   Ú"Gemma4TextRotaryEmbedding.__init__Ï  sC  € Ü
�	‰	×Ñ˜4Ô Ø"(×"@Ñ"@ˆÔØ$*×$BÑ$BˆÔ!àŒÜ!¤# f×&8Ñ&8Ó"9Ó:ˆÔØSUˆÔØ)+ˆŒà×*Ô*ˆJØŸ+™+×5Ñ5°jÕAˆKØÒ"Ùà(¨Õ5Ð5�	¸)ÔCÜ2°9Õ=‘à#×CÑC�à-9×Ñ˜zÑ*Ø)2�N‰N˜:Ñ&ð !×1Ñ1°*Õ=ˆKÙ4@ÀÐakÔ4lÑ1ˆMÜ�D˜L¨	Ð2´B·I²I¸mÐX]Ô4^Ô_Ü�D˜LÐ(:Ð;¼R¿YºYÀ}×GZÑGZÓG\ÐinÔ=oÔpÜ�D˜LÐ(:Ð;Ð=SÖTó' +rN   )rA   r}  ry  rz  r~  rp  r¤   )ro   rp   rq   rr   r‘   ru   rv   rw   s   @rL   rk  rk  Î  s   ø‡ € ÷U÷ Uð UrN   rk  c                   óX   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tRtVtV ;t	# )	ÚGemma4TextAttentioniï  z=Multi-headed attention from 'Attention Is All You Need' paperc                ó&   <€ V ^8„  d   QhRS[ RS[/# râ   rb  )rK   rl   s   "€rL   rM   Ú Gemma4TextAttention.__annotate__ò  s   ø€ ÷ /
ñ /
Ñ/ð /
¹Cñ /
rN   c                ój  <€ \         SV `  4        \        VR 4      '       d   VP                  V,          MRV n        Wn        W n        V P                  R8H  V n        V P                  '       d   VP                  MRV n        VP                  V,          pVP                  V n
        VP                  ;'       d    V P                  '       * V n        VP                  VP                  ,          V n        RV n        V P
                  P"                  V n        VP$                  R8g  V n        V P
                  P(                  \+        V P
                  R^ 4      ,
          pY$u;8¬  ;'       d    ^ 8¬  Mu V n        VP                  RV pV P,                  '       * ;'       dG    V\/        V4      ^,
          VRRR
1,          P1                  VP                  V,          4      ,
          8H  V n        \4        P6                  ! VP8                  VP                  V P                  ,          VP:                  R7      V n        \?        V P                  VP@                  R7      V n!        V P,                  '       gü   \?        V P                  VP@                  R7      V n"        \?        V P                  VP@                  RR	7      V n#        \4        P6                  ! VP8                  VP                  V P                  ,          VP:                  R7      V n$        V P                  '       gI   \4        P6                  ! VP8                  VP                  V P                  ,          VP:                  R7      MRV n%        \4        P6                  ! VP                  V P                  ,          VP8                  VP:                  R7      V n&        R# )r}  NrU   r·   rÛ  re  r�   )rÑ   r<  Frˆ  rÔ   )'r�   r‘   Úhasattrr}  rs  rA   rQ   rP   rY   r�  rë   Úattention_k_eq_vÚuse_alternative_attentionrê   r)  Únum_key_value_groupsr'  r7  Úuse_bidirectional_attentionr(  rR  rW   rh  ÚlenrX   Ústore_full_length_kvr   r“   r»   Úattention_biasró   r¬   rR  r2  r3  r+  rô   rõ   r*  )rœ   rA   rQ   Úlayer_configrg  Úprev_layersr�   s   &&&   €rL   r‘   ÚGemma4TextAttention.__init__ò  sÍ  ø€ Ü‰ÑÔÜ;BÀ6È=×;YÒ;Y˜&×,Ñ,¨YÖ7Ð_cˆŒØŒØ"ŒØŸ/™/Ð-@Ñ@ˆŒØ7;··°˜f×3Ò3ÈDˆÔà×.Ñ.¨yÕ9ˆØ$×-Ñ-ˆŒØ)/×)@Ñ)@×)XÐ)XÈÏÉÔEXˆÔ&Ø$*×$>Ñ$>À,×BbÑBbÕ$bˆÔ!ØˆŒØ!%§¡×!>Ñ!>ˆÔØ×;Ñ;¸uÑDˆŒð %)§K¡K×$AÑ$AÄGÈDÏKÉKÐYoÐqrÓDsÕ$sÐ!Ø"+×"MÔ"MÈAÔ"MˆÔØ×(Ñ(Ð)CÐ*CÐDˆØ(,×(?Ñ(?Ô$?÷ %/ð %/ÀIÔQTÐU`ÓQaÐdeÕQeÐhsÙˆbˆDõi
ç
‰%�×"Ñ" 9Õ-Ó
.õR/ñ E/ˆÔ!ô —i’iØ×Ñ × :Ñ :¸T¿]¹]Õ JÐQW×QfÑQfô
ˆŒô $¨¯©¸6×;NÑ;NÔOˆŒð ×&×&Ð&Ü'¨D¯M©M¸v×?RÑ?RÔSˆDŒKÜ'¨¯©¸6×;NÑ;NÐ[`ÔaˆDŒKäŸ)š)Ø×"Ñ" L×$DÑ$DÀtÇ}Á}Õ$TÐ[a×[pÑ[pôˆDŒKð ×5×5Ð5ô —	’	Ø×&Ñ&¨×(HÑ(HÈ4Ï=É=Õ(XÐ_e×_tÑ_tõð ð ŒKô —i’iØ×&Ñ&¨¯©Õ6¸×8JÑ8JÐQW×QfÑQfô
ˆŽrN   c                óL  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[S[S[S[ P                  S[ P                  3,          3,          RS[R,          RS[S[,          RS[S[ P                  S[ P                  R,          3,          /# )	r@   r¡   r  rC   Nrh   rD   r£  rG   )rH   rI   rJ   rj   rk   r   r   r   )rK   rl   s   "€rL   rM   r�  #  sŸ   ø€ ÷ =)ñ =)á—|‘|ð=)ñ #Ÿ\™\ð=)ñ Ÿ™ tÕ+ð	=)ñ
 ™s¡E©%¯,©,¹¿¹Ð*DÕ$EÐEÕFð=)ñ  �ð=)ñ Ñ-Õ.ð=)ñ 
‰u�|‰|™UŸ\™\¨DÕ0Ð0Õ	1ñ=)rN   c           	     óú  € VP                   R R p. VORNV P                  N5pVw  ršV P                  V4      P                  V4      pV P	                  V4      p\        W¹V
^R7      pVP                  ^^4      pV P                  '       dL   W@P                  ,          w  rÍVP                  VP                  4      pVP                  VP                  4      pM¤V P                  V4      P                  V4      pV P                  e!   V P                  V4      P                  V4      MTpV P                  V4      p\        WÉV
^R7      pVP                  ^^4      pV P                  V4      pVP                  ^^4      pVe1   V P                  '       g   VP                  WÍV P                   4      w  rÍV P"                  '       d   WÍ3W@P                  &   \$        P&                  ! V P(                  P*                  \,        4      pT! V VVVV3RV P.                  '       d   V P0                  MRRV P2                  RV P4                  /VB w  ppVP6                  ! . VORN5!  P9                  4       pV P;                  V4      pVV3# )N)rõ  r1  r·  r'  rY   rÔ   )r   rë   ró   r  r2  r6   r“  rh  rs  rÖ   rÏ   rô   rõ   r3  r+  ÚupdaterQ   r•  r   r4  rA   r5  r7   r6  r7  r'  rY   r  r  r*  )rœ   r¡   r  rC   rh   rD   r£  r8  r'  rÙ   rØ   r(  r)  r*  r9  r1  r0  s   &&&&&&,          rL   r¦   ÚGemma4TextAttention.forward#  sW  € ð $×)Ñ)¨#¨2Ð.ˆØ8˜Ð8 bÐ8¨$¯-©-Ñ8ˆà&‰ˆà—{‘{ =Ó1×6Ñ6°|ÓDˆØ—{‘{ <Ó0ˆÜ+¨L¸sÐRSÔTˆØ#×-Ñ-¨a°Ó3ˆð
 ×"×"Ð"Ø'7¿¹Õ'HÑ$ˆJà#Ÿ™ |×':Ñ':Ó;ˆJØ'Ÿ?™?¨<×+>Ñ+>Ó?‰LàŸ™ ]Ó3×8Ñ8¸ÓFˆJØLPÏKÉKÒLc˜4Ÿ;™; }Ó5×:Ñ:¸<ÔHÐisˆLàŸ™ ZÓ0ˆJÜ-¨j¸sÐRSÔTˆJØ#×-Ñ-¨a°Ó3ˆJàŸ;™; |Ó4ˆLØ'×1Ñ1°!°QÓ7ˆLàÒ&¨t×/F×/FÐ/FØ'6×'=Ñ'=¸jÐX\×XfÑXfÓ'gÑ$ˆJØ×$×$Ð$Ø0:Ð0HÐŸ_™_Ñ-ä(?×(MÒ(MØ�K‰K×,Ñ,Ô.Eó)
Ðñ %8ØØØØØñ
%
ð /3¯m¯m¨m�D×*Ò*Àð
%
ð —L‘Lð
%
ð  ×.Ñ.ð
%
ð ñ
%
Ñ!ˆ�\ð "×)Ò)Ð;¨;Ð;¸Ó;×FÑFÓHˆØ—k‘k +Ó.ˆØ˜LÐ(Ð(rN   )r7  rA   rë   r(  rh  rP   r3  rô   rQ   rs  r’  r*  r2  ró   r'  rY   r•  r‘  r+  rõ   r¤   )
ro   rp   rq   rr   rs   r‘   r¦   ru   rv   r©   rª   s   @@rL   r‹  r‹  ï  s"   ù‡ € ÙG÷/
ó /
÷b=)÷ =)ò =)rN   r‹  c                   ó>   a a€ ] tR tRt oV3R lV 3R lltRtVtV ;t# )ÚGemma4TextExpertsic  c                ó    <€ V ^8„  d   QhRS[ /# r²   rm  )rK   rl   s   "€rL   rM   ÚGemma4TextExperts.__annotate__d  s   ø€ ÷ 7ñ 7Ñ/ñ 7rN   c                ó    <€ \         SV `  4        VP                  V n        VP                  V n        \
        VP                  ,          V n        R # r¤   )r�   r‘   Únum_expertsÚmoe_intermediate_sizeÚintermediate_dimr
   Úhidden_activationri  rm  s   &&€rL   r‘   ÚGemma4TextExperts.__init__d  s<   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔØ &× <Ñ <ˆÔÜ˜V×5Ñ5Õ6ˆŽrN   )ri  r¥  r£  ró  rª   s   @@rL   rŸ  rŸ  c  s   ù‡ € ÷7÷ 7ó 7rN   rŸ  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4TextRouterik  c                ó    <€ V ^8„  d   QhRS[ /# r²   rm  )rK   rl   s   "€rL   rM   ÚGemma4TextRouter.__annotate__l  s   ø€ ÷ 
Mñ 
MÑ/ñ 
MrN   c                ó:  <€ \         SV `  4        Wn        VP                  V n        V P                  R,          V n        VP
                  V n        \        V P                  V P                  RR7      V n        \        P                  ! VP                  VP                  RR7      V n        \        P                  ! \        P                  ! V P                  4      4      V n        \        P                  ! \        P                  ! VP                  4      4      V n        R# )ræ   Frˆ  r�   Nrç   )r�   r‘   rA   r»   Úscalar_root_sizerR  r<  r¬   rA  r   r“   r£  Úprojrø   rH   r¯  ÚscaleÚper_expert_scalerm  s   &&€rL   r‘   ÚGemma4TextRouter.__init__l  sº   ø€ Ü‰ÑÔØŒØ!×-Ñ-ˆÔØ $× 0Ñ 0°$Õ 6ˆÔØ×&Ñ&ˆŒä! $×"2Ñ"2¸¿¹ÈUÔSˆŒ	Ü—I’I˜f×0Ñ0°&×2DÑ2DÈ5ÔQˆŒ	Ü—\’\¤%§*¢*¨T×-=Ñ-=Ó">Ó?ˆŒ
Ü "§¢¬U¯ZªZ¸×8JÑ8JÓ-KÓ LˆÖrN   c                óx   <€ V ^8„  d   QhRS[ P                  RS[S[ P                  S[ P                  3,          /# r    r[  )rK   rl   s   "€rL   rM   r«  x  s5   ø€ ÷ @ñ @¡U§\¡\ð @±e¹E¿L¹LÉ%Ï,É,Ð<VÕ6Wñ @rN   c                ó¶  € V P                  V4      pWP                  ,          V P                  ,          pV P                  V4      p\        P
                  P                  VR\        P                  R7      p\        P                  ! VV P                  P                  RR7      w  rEWDP                  RRR7      ,          pW@P                  V,          ,          pW4V3# )r¶   r  )rÝ  rÑ   TrÓ  rÔ   )rA  r¯  r­  r®  r   r   r$  rH   r%  ÚtopkrA   Útop_k_expertsÚsumr°  )rœ   r¡   Úexpert_scoresÚrouter_probabilitiesÚtop_k_weightsÚtop_k_indexs   &&    rL   r¦   ÚGemma4TextRouter.forwardx  s¸   € ØŸ	™	 -Ó0ˆØ%¯
©
Õ2°T×5JÑ5JÕJˆàŸ	™	 -Ó0ˆä!Ÿ}™}×4Ñ4°]ÈÔRW×R_ÑR_Ð4Ó`Ðô &+§Z¢ZØ Ø�k‰k×'Ñ'Øô&
Ñ"ˆð 	×*Ñ*¨r¸4Ð*Ó@Õ@ˆð &×(=Ñ(=¸kÕ(JÕJˆà#°KÐ?Ð?rN   )rA   r<  r»   rA  r°  r®  r­  r¯  r¨   rª   s   @@rL   r©  r©  k  s#   ù‡ € ÷
Mó 
M÷@÷ @ð @rN   r©  c                   óT   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tRtVtV ;t# )ÚGemma4TextDecoderLayeri�  c                ó6   <€ V ^8„  d   QhRS[ S[,          RS[/# râ   )r=   r>   rŠ   )rK   rl   s   "€rL   rM   Ú#Gemma4TextDecoderLayer.__annotate__‘  s'   ø€ ÷ hñ hÑ/Ñ2DÕDð hÑQTñ hrN   c                óÆ  <€ \         SV `  W4       \        WR 7      V n        \	        W4      V n        \        P                  ! \        P                  ! ^4      4      V n
        VP                  V n        V P                  '       d§   \        VP                  ,          V n        \        P                  ! V P                   V P                  RR7      V n        \        P                  ! V P                  V P                   RR7      V n        \'        V P                   VP(                  R7      V n        VP,                  V n        V P,                  '       d•   \/        V4      V n        \3        V4      V n        \'        V P                   VP(                  R7      V n        \'        V P                   VP(                  R7      V n        \'        V P                   VP(                  R7      V n        R# R# )rB  Fr�   ©r<  N)r�   r‘   r‹  rœ  r`  rC  r   r•   rH   r¯  Úlayer_scalarÚhidden_size_per_layer_inputr
   r¦  ri  r“   r»   Úper_layer_input_gateÚper_layer_projectionr¬   rR  Úpost_per_layer_input_normÚenable_moe_blockr©  ÚrouterrŸ  ÚexpertsÚpost_feedforward_layernorm_1Úpost_feedforward_layernorm_2Úpre_feedforward_layernorm_2rü   s   &&&€rL   r‘   ÚGemma4TextDecoderLayer.__init__‘  sY  ø€ Ü‰Ñ˜Ô+Ü,°FÔPˆŒÜ  Ó3ˆŒÜŸIšI¤e§j¢j°£mÓ4ˆÔà+1×+MÑ+MˆÔ(Ø×+×+Ð+Ü  ×!9Ñ!9Õ:ˆDŒKÜ(*¯	ª	°$×2BÑ2BÀD×DdÑDdÐkpÔ(qˆDÔ%Ü(*¯	ª	°$×2RÑ2RÐTX×TdÑTdÐkpÔ(qˆDÔ%Ü-:¸4×;KÑ;KÐQW×QdÑQdÔ-eˆDÔ*à &× 7Ñ 7ˆÔØ× × Ð Ü*¨6Ó2ˆDŒKÜ,¨VÓ4ˆDŒLÜ0=¸d×>NÑ>NÐTZ×TgÑTgÔ0hˆDÔ-Ü0=¸d×>NÑ>NÐTZ×TgÑTgÔ0hˆDÔ-Ü/<¸T×=MÑ=MÐSY×SfÑSfÔ/gˆDÖ,ñ !rN   c                óN  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[S[S[ P                  S[ P                  3,          3,          R,          RS[ P                  RS[ P                  R,          RS[ P
                  R,          RS[R,          R	S[ P                  /# )
r@   r¡   Úper_layer_inputrh   Nr  rC   rE   rD   rG   )rH   rI   rJ   rj   rk   r/  r   )rK   rl   s   "€rL   rM   r¿  ¦  s¤   ø€ ÷ 9ñ 9á—|‘|ð9ñ Ÿ™ð9ñ ™s¡E©%¯,©,¹¿¹Ð*DÕ$EÐEÕFÈÕMð	9ñ
 #Ÿ\™\ð9ñ Ÿ™ tÕ+ð9ñ ×&Ñ&¨Õ-ð9ñ  �ð9ñ 
�‰ñ9rN   c                ón  € Tp	V P                  V4      pV P                  ! RR VRVRVRVRVRV/VB w  rV P                  V4      pW‘,           pTp	V P                  V4      pV P	                  V4      pV P
                  '       d    V P                  V4      pV	P                  RV	P                  R,          4      pV P                  V4      w  r­pV P                  V4      pV P                  WþV4      pVP                  V	P                  4      pV P                  V4      pW¿,           pV P                  V4      pW‘,           pV P                  '       dW   Tp	V P                  V4      pV P!                  V4      pW,          pV P#                  V4      pV P%                  V4      pW‘,           pWP&                  ,          pV# )r¡   r  rC   rh   rE   rD   rV   rÔ   )rH  rœ  rI  rJ  rC  rÇ  rÊ  r  r   rÈ  rÌ  rÉ  rË  rK  rÃ  rÄ  ri  rÅ  rÆ  rÂ  )rœ   r¡   rÏ  rh   r  rC   rE   rD   r£  rt  r^   Úhidden_states_1Úhidden_states_flatr¹  rº  Úhidden_states_2s   &&&&&&&&,       rL   r¦   ÚGemma4TextDecoderLayer.forward¦  sÑ  € ð !ˆà×,Ñ,¨]Ó;ˆØŸ>š>ñ 
Ø'ð
à 3ð
ð *ð
ð .ð	
ð
 &ð
ð ,ð
ð ñ
Ñˆð ×5Ñ5°mÓDˆØ Õ0ˆà ˆØ×6Ñ6°}ÓEˆØŸ™ Ó/ˆà× × Ð Ø"×?Ñ?ÀÓNˆOð "*×!1Ñ!1°"°h·n±nÀRÕ6HÓ!IÐØ,0¯K©KÐ8JÓ,KÑ)ˆA˜kØ"×>Ñ>Ð?QÓRˆOØ"Ÿl™l¨?ÈÓWˆOØ-×5Ñ5°h·n±nÓEˆOØ"×?Ñ?ÀÓPˆOð ,Õ=ˆMà×7Ñ7¸ÓFˆØ Õ0ˆà×+×+Ð+Ø$ˆHØ ×5Ñ5°mÓDˆMØ ŸK™K¨Ó6ˆMØ)Õ;ˆMØ ×5Ñ5°mÓDˆMØ ×:Ñ:¸=ÓIˆMØ$Õ4ˆMà×*Ñ*Õ*ˆØÐrN   )ri  rÇ  rÉ  rÃ  rÂ  rC  rÄ  rÅ  rÊ  rË  rÆ  rÌ  rÈ  rœ  )NNNNNNr¨   rª   s   @@rL   r½  r½  �  s    ù‡ € ÷hó h÷*9÷ 9ò 9rN   r½  c                   ó   € ] tR tRtRtR# )ÚGemma4TextScaledWordEmbeddingiâ  rV   Nr­   rV   rN   rL   rÖ  rÖ  â  r®   rN   rÖ  c                   ó^   a € ] tR tRt o . ROtRtRt]P                  ! 4       R 4       t	Rt
V tR# )ÚGemma4PreTrainedModelié  Nc                ó’	  € \         P                  ! V4       \        V\        4      '       d#   \        P
                  ! VP                  4       R# \        V\        4      '       dÆ   R pRpVP                  ^,          p\        P                  ! W2,          4      \        V^,
          ^4      ,          pV\        P                  ! \        P                  ! V4      V) ,          4      ,          p\        P                  ! VP                   VP#                  ^ 4      P#                  ^ 4      4       R# \        V\$        4      '       dN   \        P&                  ! VP(                  VP*                  4       \        P,                  ! VP.                  4       R# \        V\0        4      '       d”   VP2                  P5                  4        Fs  w  rxVP6                  P8                  V,          p	V! W—R7      w  r«\        P                  ! \;        W R24      V
4       \        P                  ! \;        W R24      V
4       Ku  	  R# \        V\<        4      '       d.   \        P&                  ! VP>                  VP@                  4       R# \        V\B        4      '       dC   \        P
                  ! VPD                  4       \        P
                  ! VPF                  4       R# \        V\H        4      '       d_   V P6                  PJ                  p\        PL                  ! VPN                  RVR7       \        PL                  ! VPP                  RVR7       R# \        V\R        4      '       d#   \        P
                  ! VPT                  4       R# \        V\V        4      '       d¿   VPX                  '       d­   \        P&                  ! VPZ                  \]        R4      ) 4       \        P&                  ! VP^                  \]        R4      4       \        P&                  ! VP`                  \]        R4      ) 4       \        P&                  ! VPb                  \]        R4      4       R# \        V\d        4      '       da   VP6                  Pf                  '       dC   \        P,                  ! VPh                  4       \        P
                  ! VPj                  4       R# R# R# )	r·   r¸   rr  rt  ru  r·  )ÚmeanÚstdr�   N)6r   Ú_init_weightsr  r§  ÚinitÚones_r°  r°   r»   rÀ   rÁ   rÂ   rH   rÃ   rÄ   Úcopy_rÆ   rÅ   rà   Ú	constant_rû   ré   Úzeros_rú   rk  r~  ÚitemsrA   r�  rW   rÖ  Úembed_scaleÚscalar_embed_scaler©  r¯  r°  rŸ  Úinitializer_rangeÚnormal_Úgate_up_projrñ  r½  rÂ  r†   r’   r˜   r—   r™   rš   r›   ÚGemma4VisionModelÚstandardizeÚstd_biasÚ	std_scale)rœ   ÚmodulerÇ   rÈ   rÉ   rÊ   rÆ   rs  r…  r†  r‡  r^   rÛ  s   &&           rL   rÜ  Ú#Gemma4PreTrainedModel._init_weightsó  s  € ä×%Ò% fÔ-Ü�fÔ7×8Ò8Ü�JŠJ�v×6Ñ6Ö7Ü˜Ô @×AÒAØˆMØ#ˆMØ#×/Ñ/°1Õ4ˆNÜ&*§h¢h¨}Õ/LÓ&MÔPSÐTbÐefÕTfÐhiÓPjÕ&jÐ#Ø*¬U¯YªY´u·|²|ÀNÓ7SÐWnÐVnÕ7nÓ-oÕoˆNÜ�JŠJ�v×,Ñ,¨n×.FÑ.FÀqÓ.I×.SÑ.SÐTUÓ.VÖWÜ˜Ô 4×5Ò5Ü�NŠN˜6Ÿ>™>¨6×+KÑ+KÔLÜ�KŠK˜×,Ñ,Ö-Ü˜Ô 9×:Ò:Ø,2×,@Ñ,@×,FÑ,FÖ,HÑ(�
Ø$Ÿm™m×<Ñ<¸ZÕH�Ù#/°Ô#SÑ �Ü—
’
œ7 6¨\¸Ð+CÓDÀmÔTÜ—
’
œ7 6¨\Ð9KÐ+LÓMÈ}Ö]ó	 -Iô
 ˜Ô =×>Ò>Ü�NŠN˜6×-Ñ-¨v×/HÑ/HÖIÜ˜Ô 0×1Ò1Ü�JŠJ�v—|‘|Ô$Ü�JŠJ�v×.Ñ.Ö/Ü˜Ô 1×2Ò2Ø—+‘+×/Ñ/ˆCÜ�LŠL˜×,Ñ,°3¸CÕ@Ü�LŠL˜×)Ñ)°¸×=Ü˜Ô 6×7Ò7Ü�JŠJ�v×*Ñ*Ö+Ü˜Ô 5×6Ò6¸6×;U×;UÐ;UÜ�NŠN˜6×+Ñ+¬e°E«l¨]Ô;Ü�NŠN˜6×+Ñ+¬U°5«\Ô:Ü�NŠN˜6×,Ñ,¬u°U«|¨mÔ<Ü�NŠN˜6×,Ñ,¬e°E«lÖ;Ü˜Ô 1×2Ò2°v·}±}×7P×7PÐ7PÜ�KŠK˜Ÿ™Ô(Ü�JŠJ�v×'Ñ'Ö(ñ 8QÑ2rN   rV   )r½  r=  r§  r–  )ÚimageÚtextÚvideoÚaudio)ro   rp   rq   rr   Ú_no_split_modulesÚinput_modalitiesÚ_can_record_outputsrH   rÞ   rÜ  ru   rv   rw   s   @rL   rØ  rØ  é  s3   ø‡ € òÐð ;ÐØÐà
‡]‚]ƒ_ñ&)ó ö&)rN   rØ  zAThe base Gemma 4 language model without a language modeling head.©Úcustom_introc                   óÆ   a a€ ] tR tRt oR]! ]^ R7      R]R]/tV3R lV 3R llt	V3R lR	 lt
RV3R
 lR llt]]]RV3R lR ll4       4       4       tV3R ltRtVtV ;t# )ÚGemma4TextModeli  Úrouter_logits)rX   r¡   Ú
attentionsc                ó    <€ V ^8„  d   QhRS[ /# r²   rm  )rK   rl   s   "€rL   rM   ÚGemma4TextModel.__annotate__&  s   ø€ ÷ "ñ "Ñ/ñ "rN   c           
     ó  <€ \         SV `  V4       \        P                  ! \	        VP
                  4       Uu. uF  p\        W4      NK  	  up4      V n        \        V4      V n	        \        V P                  P                  4      V n        VP                  V n        V P                  '       dÝ   \        VP                   VP
                  VP                  ,          V P"                  VP                  R ,          R7      V n        R	V n        \        P(                  ! VP*                  VP
                  VP                  ,          RR7      V n        VP*                  R,          V n        \1        VP                  VP2                  R7      V n        . V n        \9        V P                  4       FT  w  r4VP:                  P<                  '       g   K#  V P6                  P?                  R
 Uu. uF  pRV RV 2NK  	  up4       KV  	  R# u upi u upi )ræ   )rã  Fr�   rÁ  zlayers.z.self_attn.Nrç   gÍ;fž æ?)rô   rõ   r3  r+  ) r�   r‘   r   rU  rù  rR  r½  rV  rk  rT  r|  rA   r}  Úunique_layer_typesrÃ  rÖ  Úvocab_size_per_layer_inputÚpadding_idxÚembed_tokens_per_layerÚper_layer_input_scaler“   r»   Úper_layer_model_projectionÚ per_layer_model_projection_scaler¬   rR  Úper_layer_projection_normÚ"_keys_to_ignore_on_load_unexpectedÚ	enumeraterœ  rh  Úextend)rœ   rA   rQ   rW  ÚlayerÚnamer�   s   &&    €rL   r‘   ÚGemma4TextModel.__init__&  s£  ø€ Ü‰Ñ˜Ô Ü—m’mÜHMÈf×NfÑNfÔHgÓhÑHg¸9Ô# FÖ6ÑHgÑhó
ˆŒô 4°FÓ;ˆŒÜ"% d§k¡k×&=Ñ&=Ó">ˆÔð
 ,2×+MÑ+MˆÔ(Ø×+×+Ð+Ü*GØ×1Ñ1Ø×(Ñ(¨6×+MÑ+MÕMØ× Ñ Ø"×>Ñ>ÀÕCô	+ˆDÔ'ð *3ˆDÔ&Ü.0¯iªiØ×"Ñ"Ø×(Ñ(¨6×+MÑ+MÕMØô/ˆDÔ+ð
 5;×4FÑ4FÈÕ4LˆDÔ1Ü-:¸6×;]Ñ;]Ðci×cvÑcvÔ-wˆDÔ*ð 35ˆÔ/Ü! $§+¡+Ö.‰HˆAØ�‰×1×1Ò1Ø×7Ñ7×>Ñ>Ù@hÓiÑ@h¸�w˜q˜c ¨T¨FÓ3Ñ@hÑiöó /ùò7 iùò< js   ¸HÇ#H
c                ó„   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  /# ©r@   Ú	input_idsNrB   rG   r¢   )rK   rl   s   "€rL   rM   rü  J  s?   ø€ ÷ *
ñ *
©e¯l©l¸TÕ.Að *
ÑRW×R^ÑR^ÐaeÕReð *
Ñjo×jvÑjvñ *
rN   c                óÄ  € V P                   '       g   \        RV P                   24      hVf¹   \        P                  ! 4       ;_uu_ 4        VR,          V P
                  P                  R,          V P                  P                  R,          ,          8H  P                  ^R7      P                  4       R	,          p VP                  VP                  R,          4      p RRR4       V P                  V4      P                  ! . VP                  OV P                  P                  NV P                   N5!  #   \         d    \        R4      hi ; i  + '       g   i     Lx; i)
aç  Compute the token-identity component of Per-Layer Embeddings (PLE).

Looks up `input_ids` in `embed_tokens_per_layer` (a scaled embedding that multiplies
by `sqrt(hidden_size_per_layer_input)`) and reshapes the packed output from
`[batch, seq, num_hidden_layers * hidden_size_per_layer_input]` to
`[batch, seq, num_hidden_layers, hidden_size_per_layer_input]`.

If only `inputs_embeds` is provided (no `input_ids`), reverses the main embedding
to recover `input_ids` for the PLE lookup.
z}Attempting to call get_per_layer_inputs() from a model initialized with a config that does not support per-layer embeddings. Nræ   rÐ   :Nr@   Na)  It seems like you tried to call `forward` from `inputs_embeds` without providing `input_ids`, and that the `inputs_embeds` you provided do not exactly match the embedding weights. Since Gemma4 needs to reverse the embedding to compute another embedding, make sure you provide exact `inputs_embeds`)r  r  Nr  )NNr  r  )r  r@   )rÃ  ÚRuntimeErrorrA   rH   rÞ   Úembed_tokensrJ  r»   rÛ  Únonzeror  r   r  r  rR  )rœ   r  rB   s   &&&rL   Úget_per_layer_inputsÚ$Gemma4TextModel.get_per_layer_inputsJ  s:  € ð ×/×/Ð/Üð*Ø*.¯+©+¨ð8óð ð ÒÜ—’—•ð & mÕ4Ø×,Ñ,×3Ñ3Ð4DÕEÈÏÉ×H_ÑH_ÐadÕHdÕdñe÷ ‘S˜Q�S“Zß‘W“Y˜tõ%ð ðØ )§¡¨}×/BÑ/BÀ2Õ/FÓ G‘I÷ !ð$ ×*Ñ*¨9Ó5×=Ò=ð 
Ø�_‰_ð
à�K‰K×)Ñ)ð
ð ×,Ñ,ó
ð 	
øô $ô Ü&ðróð ðú÷ !—ús   ÁA/EÂ<"D5Ä5EÅEÅE	c                óv   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  /# )r@   rB   Úper_layer_inputsNrG   r¢   )rK   rl   s   "€rL   rM   rü  v  s?   ø€ ÷ !Vñ !Vá—|‘|ð!Vñ  Ÿ,™,¨Õ-ð!Vñ 
�‰ñ	!VrN   c                ó~  € V P                   '       g   \        RV P                   24      hV P                  V4      V P                  ,          pVP
                  ! . VP                  RR OV P                  P                  NV P                   N5!  pV P                  V4      pVf   V# W2,           V P                  ,          # )aL  Compute the context-aware component of PLE and combine with token-identity.

Projects `inputs_embeds` through `per_layer_model_projection` (Linear), scales by
`1/sqrt(hidden_size)`, reshapes to `[batch, seq, num_layers, ple_dim]`, and normalizes
with `per_layer_projection_norm` (RMSNorm).

If `per_layer_inputs` (the token-identity component from `get_per_layer_inputs()`)
is provided, combines both: `(context_projection + token_identity) * (1/sqrt(2))`.
If `per_layer_inputs` is None (e.g. for multimodal inputs where input_ids are not
available), returns just the context projection.
z�Attempting to call project_per_layer_inputs() from a model initialized with a config that does not support per-layer embeddings. NrÔ   )
rÃ  r  rA   r  r  r  r   rR  r  r  )rœ   rB   r  rÅ  s   &&& rL   Úproject_per_layer_inputsÚ(Gemma4TextModel.project_per_layer_inputsv  sÌ   € ð  ×/×/Ð/Üð2Ø26·+±+°ð@óð ð
  $×>Ñ>¸}ÓMÐPT×PuÑPuÕuÐØ3×;Ò;ð  
Ø× Ñ   "Ð%ð 
à�K‰K×)Ñ)ð 
ð ×,Ñ,ó 
Ðð
  $×=Ñ=Ð>RÓSÐàÒ#Ø'Ð'à$Õ7¸4×;UÑ;UÕUÐUrN   c                ó&  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          RS[R,          R	S[S[,          R
S[/	# )r@   r  NrC   rE   rD   rB   r  Ú	use_cacher£  rG   )	rH   r/  rI   r   rF  Úboolr   r   r}   )rK   rl   s   "€rL   rM   rü  œ  s±   ø€ ÷ Y
ñ Y
á×#Ñ# dÕ*ðY
ñ Ÿ™ tÕ+ðY
ñ ×&Ñ&¨Õ-ð	Y
ñ
  �ðY
ñ ×(Ñ(¨4Õ/ðY
ñ  Ÿ,™,¨Õ-ðY
ñ ˜$•;ðY
ñ Ñ+Õ,ðY
ñ 
'ñY
rN   c                óÜ  € VRJ VRJ,          '       d   \        R4      hVe   Ve   \        R4      hVe   V P                  V4      pV P                  '       d'   Vf   V P                  W4      pV P	                  WV4      pV'       d   Vf   \        V P                  R7      pVfb   Ve   VP                  4       M^ p	\        P                  ! VP                  ^,          VP                  R7      V	,           pVP                  ^ 4      p\        T;p
\        4      '       g/   RV P                  RVRVR	VR
V/pR\        R/ VB R\!        R/ VB /p
Tp/ pV P"                   F  pV P%                  WÃV4      WÞ&   K  	  VP'                  R\)        4       4      p\+        V P,                  RV P                  P.                   4       Fo  w  ppVe   VRRVR3,          MRpV! VV3RVRWÐP                  P0                  V,          ,          RW P                  P0                  V,          ,          R
VR	V/VB pKq  	  V P3                  V4      p\5        TTVP7                  RR4      '       d   VR7      # RR7      # )a3  
per_layer_inputs (`torch.Tensor`, *optional*):
    Pre-computed per-layer input text embeddings of shape `(batch_size, sequence_length, num_hidden_layers,
    hidden_size_per_layer_input)`. When provided, these are used directly instead of being computed from `input_ids`
    via `get_per_layer_inputs()` in the text model. If calling the `forward` with `inputs_embeds` instead of `input_ids`,
    you should probably precompute them and forward them along `inputs_embeds`, otherwise recomputing them needs
    to reverse the main embedding, which is expensive.
Nú:You must specify exactly one of input_ids or inputs_embedsú<You cannot specify per_layer_inputs if input_ids is provided)rA   rÎ   rA   rB   rC   rD   rE   rT   rU   rh   r  r  Úreturn_shared_kv_statesF)r\  rD   rh   rV   )r×  r  rÃ  r  r  r   rA   Úget_seq_lengthrH   rÄ   r   rÏ   rÅ   r  rJ   r   r   rþ  rT  Úpopr   r  rV  rR  r}  rA  r}   Úget)rœ   r  rC   rE   rD   rB   r  r  r£  Úpast_seen_tokensÚcausal_mask_mappingrZ   r¡   r  rs  rh   rW  r]  rÏ  s   &&&&&&&&,          rL   r¦   ÚGemma4TextModel.forward™  s�  € ð, ˜Ð -°tÐ";×<Ô<ÜÐYÓZÐZàÒ Ð%5Ò%AÜÐ[Ó\Ð\àÒ Ø ×-Ñ-¨iÓ8ˆMà×+×+Ð+ØÒ'Ø#'×#<Ñ#<¸YÓ#VÐ Ø#×<Ñ<¸]Ó]Ðç˜Ò0Ü*°$·+±+Ô>ˆOàÒØCRÒC^˜×=Ñ=Ô?ÐdeÐÜ Ÿ<š<¨×(;Ñ(;¸AÕ(>À}×G[ÑG[Ô\Ð_oÕoˆLØ'×1Ñ1°!Ó4ˆLô °Ð?Ð-Ä×FÒFð ˜$Ÿ+™+Ø Ø  .Ø! ?Ø ðˆKð !Ô"4Ñ"C°{Ñ"CØ#Ô%FÑ%UÈÑ%Uð#Ðð &ˆØ ÐØ×1Ô1ˆJØ.2¯o©o¸mÐ[eÓ.fÐÓ+ñ 2ð "Ÿ:™:Ð&8¼(»*ÓEÐô !*¨$¯+©+Ð6U¸¿¹×8UÑ8UÐ*VÖ WÑˆAˆ}Ø>NÒ>ZÐ.¨q°!°Q¸¨zÖ:Ð`dˆOá)ØØñ	ð "2ð	ð %8¿¹×8OÑ8OÐPQÕ8RÕ$Sð		ð
  3·;±;×3JÑ3JÈ1Õ3MÕNð	ð *ð	ð !0ð	ð ñ	ŠMñ !Xð Ÿ	™	 -Ó0ˆä,Ø+Ø+Ø17·±Ð<UÐW\×1]Ò1]Ð-ô
ð 	
ð dhô
ð 	
rN   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # r²   rm  )rK   rl   s   "€rL   rM   rü    s   ø‡ ‚ áÑò rN   )
r  r  rÃ  rV  r  r  r  r  rT  rþ  r¤   )NNNNNNN)ro   rp   rq   rr   r%   r©  r½  r‹  rô  r‘   r  r  r#   r&   r   r¦   rt   ru   rv   r©   rª   s   @@rL   rø  rø    s   ù‡ € ð 	™Ð(8ÀÔBØÐ/ØÐ)ðÐ÷"ó "÷H*
ð *
÷X!Vò !VðF  ØØ÷Y
ñ Y
ó ó ó  ðY
÷ … rN   rø  z>The base Gemma 4 language model with a language modeling head.c                   óN   a € ] tR tRt o Rt]]RV 3R lR ll4       4       tRtV t	R# )ÚGemma4ForCausalLMiø  ÚmodelNc                óx  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          RS[R,          R	S[S[ P                  ,          R
S[ P                  R,          RS[S[,          RS[	/# )r@   r  NrC   rE   rD   rB   Úlabelsr  Úlogits_to_keepr  r£  rG   )
rH   r/  rI   r   rF  r  rŠ   r   r   ry   )rK   rl   s   "€rL   rM   ÚGemma4ForCausalLM.__annotate__þ  sÛ   ø€ ÷ E
ñ E
á×#Ñ# dÕ*ðE
ñ Ÿ™ tÕ+ðE
ñ ×&Ñ&¨Õ-ð	E
ñ
  �ðE
ñ ×(Ñ(¨4Õ/ðE
ñ × Ñ  4Õ'ðE
ñ ˜$•;ðE
ñ ™eŸl™lÕ*ðE
ñ  Ÿ,™,¨Õ-ðE
ñ Ñ+Õ,ðE
ñ 
&ñE
rN   c
                ó`  € V P                   ! RRVRVRVRVRVRV	RV/V
B pVP                  p\        V\        4      '       d   \	        V) R4      MTpV P                  VR	VR	3,          4      pV P                  P                  eO   WàP                  P                  ,          p\        P                  ! V4      pWàP                  P                  ,          pRpVe   V P                  ! WæV P                  3/ V
B p\        VVVP                  VP                  VP                  VP                   R
7      # )a]  
per_layer_inputs (`torch.Tensor`, *optional*):
    Pre-computed per-layer input text embeddings of shape `(batch_size, sequence_length, num_hidden_layers,
    hidden_size_per_layer_input)`. When provided, these are used directly instead of being computed from `input_ids`
    via `get_per_layer_inputs()` in the text model. If calling the `forward` with `inputs_embeds` instead of `input_ids`,
    you should probably precompute them and forward them along `inputs_embeds`, otherwise recomputing them needs
    to reverse the main embedding, which is expensive.

Example:

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

>>> model = Gemma4ForCausalLM.from_pretrained("google/gemma-4-E2B-it")
>>> tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E2B-it")

>>> prompt = "What is your favorite condiment?"
>>> inputs = tokenizer(prompt, return_tensors="pt")

>>> # Generate
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
"What is your favorite condiment?"
```r  rC   rE   rD   rB   r  r  Nr  )ÚlossÚlogitsrD   r¡   rú  rh   rV   )r*  r\  r  rŠ   ÚsliceÚlm_headrA   Úfinal_logit_softcappingrH   r   Úloss_functionÚ
vocab_sizery   rD   r¡   rú  rh   )rœ   r  rC   rE   rD   rB   r,  r  r-  r  r£  Úoutputsr¡   Úslice_indicesr1  r0  s   &&&&&&&&&&,     rL   r¦   ÚGemma4ForCausalLM.forwardü  sC  € ðP 26·²ñ 	2
Øð	2
à)ð	2
ð &ð	2
ð ,ð		2
ð
 (ð	2
ð .ð	2
ð  ð	2
ð ñ	2
ˆð  ×1Ñ1ˆä8BÀ>ÔSV×8WÒ8Wœ˜~˜o¨tÔ4Ð]kˆØ—‘˜m¨A¨}¸aÐ,?Õ@ÓAˆØ�;‰;×.Ñ.Ò:ØŸk™k×AÑAÕAˆFÜ—Z’Z Ó'ˆFØŸk™k×AÑAÕAˆFàˆØÒØ×%Ò% f°d·o±oÑPÈÑPˆDä+ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø$×5Ñ5ô
ð 	
rN   rV   )	NNNNNNNr   N)
ro   rp   rq   rr   Úbase_model_prefixr   r   r¦   ru   rv   rw   s   @rL   r)  r)  ø  s-   ø‡ € àÐàØ÷E
ñ E
ó ó öE
rN   r)  c                   ó¶   a a€ ] tR tRt oRtRtRtR]R]/t	V3R lV 3R llt
V3R	 lR
 lt]]]! RR7      RV3R lR ll4       4       4       tV3R ltRtVtV ;t# )ÚGemma4AudioModeliF  znAn audio encoder based on the [Universal Speech Model](https://huggingface.co/papers/2303.01037) architecture.rY  zmodel.audio_towerr¡   rú  c                ó    <€ V ^8„  d   QhRS[ /# r²   r³   )rK   rl   s   "€rL   rM   ÚGemma4AudioModel.__annotate__Q  s   ø€ ÷ ñ Ñ0ñ rN   c           	     óŽ  <€ \         SV `  V4       Wn        \        V4      V n        \        V4      V n        \        P                  ! \        VP                  4       Uu. uF  p\        W4      NK  	  up4      V n        \        P                  ! VP                  VP                  R R7      V n        V P#                  4        R# u upi )Tr�   N)r�   r‘   rA   rM  Úsubsample_conv_projectionr°   Úrel_pos_encr   rU  rù  rR  r–  rV  r“   r»   Úoutput_proj_dimsÚoutput_projÚ	post_initrü   s   && €rL   r‘   ÚGemma4AudioModel.__init__Q  s˜   ø€ Ü‰Ñ˜Ô ØŒä)KÈFÓ)SˆÔ&Ü;¸FÓCˆÔÜ—m’mÜBGÈ×H`ÑH`ÔBaÓbÑBa°YÔ˜fÖ0ÑBaÑbó
ˆŒô Ÿ9š9 V×%7Ñ%7¸×9PÑ9PÐW[Ô\ˆÔà�‰Öùò	 cs   ÁCc                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r@   Úmask_4drG   r¢   )rK   rl   s   "€rL   rM   r>  ^  s#   ø€ ÷ .ñ .±e·l±lð .ÁuÇ|Á|ñ .rN   c                ó¼  € VP                   w  r#rCVP                  pV P                  P                  pV P                  P                  ^,
          pV P                  P
                  pWF,           ^,
          V,          p	W–,          p
W¤,
          p\        P                  ! V^ V^ V3RR7      pVP                  V^W–V
4      p\        P                  ! WÇV3RR7      p\        P                  ! W•R7      V,          p\        P                  ! Wg,           V,           VR7      pVR,          VR,          ,           pVR,          P                  V^RVR4      pVP                  RV4      # )zÄ
Convert a standard 4D attention mask `[batch_size, 1, seq_len, seq_len]` to the 5D blocked format
`[batch_size, 1, num_blocks, chunk_size, context_size]` expected by the chunked local attention,
F)ÚvaluerÎ   )r  N)Nr  )NNr  Nr  rÔ   )r   rÏ   rA   r¼   r½   r¾   r  r  r  rH   rÄ   ÚexpandÚgather)rœ   rG  r  r^   r  rÏ   rð   rñ   rò   r  Úpadded_seq_lenÚ
pad_amountÚmask_5dÚblock_startsÚoffsetsÚ
kv_indicess   &&              rL   Ú_convert_4d_mask_to_blocked_5dÚ/Gemma4AudioModel._convert_4d_mask_to_blocked_5d^  s(  € ð
 %,§M¡MÑ!ˆ
�wØ—‘ˆà—[‘[×5Ñ5ˆ
ØŸ;™;×=Ñ=ÀÕAÐØ!Ÿ[™[×@Ñ@ÐàÕ*¨QÕ.°:Õ=ˆ
Ø#Õ0ˆØ#Õ-ˆ
ä—%’%˜ ! Z°°JÐ!?ÀuÔMˆØ—/‘/ *¨a°ÈÓXˆÜ—%’%˜Ð4FÐ!GÈuÔUˆä—|’| JÔ>ÀÕKˆÜ—,’,˜zÕ<Ð?QÕQÐZ`ÔaˆØ! 'Õ*¨W°WÕ-=Õ=ˆ
ØÐ 6Õ7×>Ñ>¸zÈ1ÈbÐR\Ð^`Óaˆ
à�~‰~˜b *Ó-Ð-rN   z&Encodes audio features to soft tokens.rõ  c          
      ó¶   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[S[ P                  S[ P
                  3,          /# )r@   rY  rC   Nr£  rG   )rH   rI   r   r   rk   rƒ   )rK   rl   s   "€rL   rM   r>  |  s`   ø€ ÷ cñ cáŸ™ðcñ Ÿ™ tÕ+ðcñ Ñ+Õ,ð	cñ
 
‰u�|‰|™U×-Ñ-Ð-Õ	.ñcrN   c           	     óÂ  € V P                  W4      w  rEV P                  V4      p\        V P                  VV\	        V P                  P
                  ^,
          V P                  P                  34      R7      pVe   V P                  V4      pV P                  RV P                  P                    F  pV! V3RVRV/VB pK  	  V P                  V4      p\        WER7      # )r¶   )rA   rB   rC   rS   NrC   r  )r\  rC   )r@  rA  r   rA   r9   r½   r¾   rR  rV  rR  rC  r�   )rœ   rY  rC   r£  r¡   Úoutput_maskr  Úencoder_layers   &&&,    rL   r¦   ÚGemma4AudioModel.forwardy  sç   € ð &*×%CÑ%CÀNÓ%cÑ"ˆØ"×.Ñ.¨}Ó=Ðä2Ø—;‘;Ø'Ø&Ü:Ø—‘×3Ñ3°aÕ7¸¿¹×9\Ñ9\Ð]óô	
ˆð Ò%Ø!×@Ñ@ÀÓPˆNà!Ÿ[™[Ð)H¨4¯;©;×+HÑ+HÓIˆMÙ)Øñà-ðð %8ðð ñ	ŠMñ Jð ×(Ñ(¨Ó7ˆÜ%¸ÔbÐbrN   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # r²   r³   )rK   rl   s   "€rL   rM   r>  F  s   ø‡ ‚ ñ Ñò rN   )rA   rV  rC  rA  r@  r¤   )ro   rp   rq   rr   rs   Úmain_input_namer:  r–  rà   rô  r‘   rR  r#   r&   r   r¦   rt   ru   rv   r©   rª   s   @@rL   r<  r<  F  sx   ù‡ € Ùxð '€OØ+ÐàÐ)ØÐ*ðÐ÷
ó ÷.ð .ð6  ØÙÐ!IÔJ÷cñ có Kó ó  ðc÷m … rN   r<  c                   ó˜   a a€ ] tR tRt oRtR]R]/tV3R lV 3R llt]	]
]! RR7      V3R	 lR
 l4       4       4       tV3R ltRtVtV ;t# )rè  iœ  zThe Gemma 4 Vision Encoder.r¡   rú  c                ó    <€ V ^8„  d   QhRS[ /# r²   r©  )rK   rl   s   "€rL   rM   ÚGemma4VisionModel.__annotate__¥  s   ø€ ÷ 
ñ 
Ñ1ñ 
rN   c                óê  <€ \         SV `  V4       \        V4      V n        \	        V4      V n        \        V4      V n        V P                  P                  '       d‡   \        P                  ! \        P                  ! V P                  P                  4      4      V n        \        P                  ! \        P                  ! V P                  P                  4      4      V n        V P#                  4        R # r¤   )r�   r‘   r§  Úpatch_embedderrN  ÚencoderrÈ  ÚpoolerrA   ré  r   r•   rH   Úemptyr»   rê  rë  rD  rm  s   &&€rL   r‘   ÚGemma4VisionModel.__init__¥  s•   ø€ Ü‰Ñ˜Ô Ü7¸Ó?ˆÔÜ*¨6Ó2ˆŒÜ(¨Ó0ˆŒà�;‰;×"×"Ð"ÜŸIšI¤e§k¢k°$·+±+×2IÑ2IÓ&JÓKˆDŒMÜŸYšY¤u§{¢{°4·;±;×3JÑ3JÓ'KÓLˆDŒNà�‰ÖrN   z1Encodes image pixels to soft tokens from patches.rõ  c                ój   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[,          RS[/# )r@   rÂ  r³  r£  rG   )rH   rF  r/  r   r   r   )rK   rl   s   "€rL   rM   r]  ´  sK   ø€ ÷ )Hñ )Há×'Ñ'ð)Hñ "×,Ñ,ð)Hñ Ñ+Õ,ð	)Hñ
 
!ñ)HrN   c           	     óD  € V P                   P                  pVP                  R,          WD,          ,          pVR8H  P                  RR7      pV P	                  WV4      pV P
                  ! R	RVRV( RV/VB pV P                  VP                  VVVR7      w  ršWš,          p	V P                   P                  '       d@   W�P                  P                  4       ,
          V P                  P                  4       ,          p	V	P                  VP                  4      p	\        V	R7      # )
a°  
pixel_values (`torch.FloatTensor` or `list[torch.FloatTensor]`):
    The images to encode. Either a single `[batch, channels, height, width]` tensor
    (all images same size) or a list of `[1, channels, height, width]` tensors (different sizes).
pixel_position_ids (`torch.LongTensor` of shape `(batch_size, max_patches, 2)`):
    The patch positions as (x, y) coordinates in the image. Padding patches are indicated by (-1, -1).
rÐ   rB   rC   r³  )r¡   r³  r´  ræ  r[  éþÿÿÿrÔ   rV   )rA   Úpooling_kernel_sizer   rÛ  r_  r`  ra  r\  ré  rê  r—   rë  rÖ   rÓ   r   )rœ   rÂ  r³  r£  rg  ræ  r´  rB   râ  r¡   Úpooler_masks   &&&,       rL   r¦   ÚGemma4VisionModel.forward±  s  € ð  #Ÿk™k×=Ñ=ÐØ$×*Ñ*¨2Õ.Ð3FÕ3\Õ]ˆà/°2Ñ5×:Ñ:¸rÐ:ÓBÐØ×+Ñ+¨LÐN_Ó`ˆØ—’ñ 
Ø'ð
à-Ð-ð
ð  2ð
ð ñ	
ˆð &*§[¡[Ø ×2Ñ2Ø1Ø/Ø'ð	 &1ó &
Ñ"ˆð &Õ2ˆð �;‰;×"×"Ð"Ø*¯]©]×-@Ñ-@Ó-BÕBÀdÇnÁn×FZÑFZÓF\Õ\ˆMØ%×(Ñ(¨×)<Ñ)<Ó=ˆä&¸ÔGÐGrN   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # r²   r©  )rK   rl   s   "€rL   rM   r]  œ  s   ø‡ ‚ ñ Ñò rN   )r`  r_  ra  rê  rë  )ro   rp   rq   rr   rs   r=  r!  rô  r‘   r#   r&   r   r¦   rt   ru   rv   r©   rª   s   @@rL   rè  rè  œ  s\   ù‡ € Ù%ð 	Ð1ØÐ+ðÐ÷

ó 
ð  ØÙÐ!TÔU÷)Hó Vó ó  ð)H÷1 … rN   rè  c                   óP   a a€ ] tR tRt oV3R lV 3R lltV3R lR ltRtVtV ;t# )ÚGemma4MultimodalEmbedderià  c                ó6   <€ V ^8„  d   QhRS[ S[,          RS[/# )r@   Úmultimodal_configÚtext_config)r;   r>   r=   )rK   rl   s   "€rL   rM   Ú%Gemma4MultimodalEmbedder.__annotate__á  s)   ø€ ÷ xñ xá,Ñ/AÕAðxñ &ñxrN   c                óÄ   <€ \         SV `  W4       V =V =V =V =V =V =\        VR VP                  4      V n
        \        V P                  V P                  RR7      V n        R# )rB  Frˆ  N)r�   r‘   rº  Úhard_embedding_normÚsoft_embedding_normÚvocab_offsetr6  Úembedding_post_projection_normrW   r»   Úmultimodal_hidden_sizer¬   r<  Úembedding_pre_projection_norm)rœ   rn  ro  r�   s   &&&€rL   r‘   Ú!Gemma4MultimodalEmbedder.__init__á  sn   ø€ ô 	‰ÑÐ*Ô8ØˆNØÐ$ØÐ$ØÐØˆOØÐ/ä&-Ð.?ÐASÐUf×UrÑUrÓ&sˆÔ#Ü-:¸4×;VÑ;VÐ\`×\dÑ\dÐqvÔ-wˆÖ*rN   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r@   rB   rG   r¢   )rK   rl   s   "€rL   rM   rp  ó  s#   ø€ ÷ 6ñ 6¡U§\¡\ð 6±e·l±lñ 6rN   c                óF   € V P                  V4      pV P                  V4      # )a  Embeds token ids or soft tokens for multimodal content into language model space.
Args:
    inputs_embeds: A torch.Tensor containing the soft tokens to embed.
Returns:
    A torch.Tensor of embeddings with shape `[batch_size, seq_len, self.config.text_config.hidden_size]`.
)rw  Úembedding_projection)rœ   rB   Úembs_normeds   && rL   r¦   Ú Gemma4MultimodalEmbedder.forwardó  s%   € ð ×8Ñ8¸ÓGˆØ×(Ñ(¨Ó5Ð5rN   )rw  rv  r¨   rª   s   @@rL   rl  rl  à  s    ù‡ € ÷xó x÷$6÷ 6ð 6rN   rl  c                óŽ   € V ^8„  d   QhR\         P                  R,          R\         P                  R,          R\        R,          /# )r@   Útoken_type_idsNÚimage_group_idsrG   )rH   rI   r   )rK   s   "rL   rM   rM   ÿ  s<   € ÷ ñ Ü—L‘L 4Õ'ðä—\‘\ DÕ(ðô �…_ñrN   c                ó&   a€ V f   R# R V3R llpV# )z‰
This function adds the correct offsets to the `q_idx` and `kv_idx` as the torch API can only accept lengths,
not start and end indices.
Nc          
      óT   € V ^8„  d   QhR\         R\         R\         R\         R\        /# )r@   Ú	batch_idxÚhead_idxÚq_idxÚkv_idxrG   )rŠ   r  )rK   s   "rL   rM   Ú2token_type_ids_mask_function.<locals>.__annotate__  s/   € ÷ 6ñ 6œcð 6¬Sð 6¼ð 6Äcð 6Ìdñ 6rN   c                 ó:  <€ S	P                   R,          pVP                  V^,
          R7      pVP                  V^,
          R7      pS	W3,          pS	W3,          p\        P                  ! W$8  VR4      p\        P                  ! W48  VR4      pWx8H  V^ 8¬  ,          # )r¶   )rÂ   rÔ   )r   r¥   rH   r»  )
rƒ  r„  r…  r†  r&  Úq_idx_clampedÚkv_idx_clampedÚq_groupÚkv_groupr€  s
   &&&&     €rL   Ú
inner_maskÚ0token_type_ids_mask_function.<locals>.inner_mask  s•   ø€ Ø$×*Ñ*¨2Õ.ˆ
ð Ÿ™¨
°Q­˜Ó7ˆØŸ™¨*°q­.˜Ó9ˆð " )Ð":Õ;ˆØ" 9Ð#<Õ=ˆÜ—+’+˜eÑ0°'¸2Ó>ˆÜ—;’;˜vÑ2°H¸bÓAˆØÑ#¨°1©Õ5Ð5rN   rV   )r  r€  r�  s   &f rL   Útoken_type_ids_mask_functionr�  ÿ  s    ø€ ð ÒÙ÷6ð 6ð ÐrN   c                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )r@   Úmm_token_type_idsrÏ   rG   )rH   rI   rÏ   )rK   s   "rL   rM   rM     s0   € ÷ 	ñ 	´u·|±|ð 	ÌUÏ\É\ð 	Ô^c×^jÑ^jñ 	rN   c                 ó  € V P                  V4      p V ^8H  V ^8H  ,          p\        P                  ! V^RR7      pRVR&   W#( ,          p\        P                  ! VP	                  4       ^R7      ^,
          p\        P
                  ! W%R4      pV# )r¶   )ÚshiftsÚdimsFrÐ   rÔ   r¸  )rÖ   rH   ÚrollÚcumsumrŠ   r»  )r‘  rÏ   Ú	is_visionÚis_prev_visionÚnew_vision_startsÚvision_group_idsrF   s   &&     rL   Úget_block_sequence_ids_for_maskr›    s†   € Ø)×,Ñ,¨VÓ4Ðà" aÑ'Ð,=ÀÑ,BÕC€IÜ—Z’Z 	°!¸"Ô=€NØ"€N�6ÑØ! OÕ3ÐÜ—|’|Ð$5×$9Ñ$9Ó$;ÀÔCÀaÕGÐÜŸš YÀ"ÓEÐØÐrN   zŒ
    The base Gemma 4 model comprising a vision backbone, an audio backbone, and a language model without a
    language modeling head.
    c                   ó8  a a€ ] tR tRt oV3R lV 3R lltR tR t]]! RR7      RV3R lR	 ll4       4       t	]]! R
R7      RV3R lR ll4       4       t
RV3R lR llt]]]RV3R lR ll4       4       4       t]]! RR7      V3R lR l4       4       tRtVtV ;t# )ÚGemma4Modeli(  c                ó    <€ V ^8„  d   QhRS[ /# r²   )r<   )rK   rl   s   "€rL   rM   ÚGemma4Model.__annotate__/  s   ø€ ÷ 
ñ 
™|ñ 
rN   c                óÜ  <€ \         SV `  V4       VP                  e!   \        P                  ! VP                  4      MR V n        VP                  e!   \        VP                  VP                  4      MR V n        VP                  e!   \        P                  ! VP                  4      MR V n
        VP                  e(   \        VP                  VP                  4      V n        R # R V n        R # r¤   )r�   r‘   Úvision_configr'   Úfrom_configÚvision_towerrl  ro  Úembed_visionÚaudio_configÚaudio_towerÚembed_audiorm  s   &&€rL   r‘   ÚGemma4Model.__init__/  sÎ   ø€ Ü‰Ñ˜Ô ØKQ×K_ÑK_ÒKkœI×1Ò1°&×2FÑ2FÔGÐquˆÔð ×#Ñ#Ò/ô % V×%9Ñ%9¸6×;MÑ;MÔNàð 	Ôð
 JP×I\ÑI\ÒIhœ9×0Ò0°×1DÑ1DÔEÐnrˆÔð ×"Ñ"Ò.ô % V×%8Ñ%8¸&×:LÑ:LÓMð 	Öð ð 	ÖrN   c                ó.   € V P                   P                  # r¤   ©Úlanguage_modelr  ©rœ   s   &rL   Úget_per_layer_input_embeddingsÚ*Gemma4Model.get_per_layer_input_embeddings>  s   € Ø×"Ñ"×9Ñ9Ð9rN   c                ó&   € WP                   n        R # r¤   rª  ©rœ   rI  s   &&rL   Úset_per_layer_input_embeddingsÚ*Gemma4Model.set_per_layer_input_embeddingsA  s   € Ø5:×ÑÖ2rN   zOProjects the last hidden state from the vision model into language model space.rõ  c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# )r@   rÂ  Úimage_position_idsNr£  rG   ©rH   rF  r/  r   r   r   )rK   rl   s   "€rL   rM   rŸ  F  sJ   ø€ ÷ ñ á×'Ñ'ðñ "×,Ñ,¨tÕ3ðñ Ñ+Õ,ð	ñ
 
$ñrN   c                óü  € V P                   ! RRVRV/VB pVP                  pV P                  VR7      pVP                  R,          V P                  P
                  P                  ^,          ,          p\        VP                  ^,          V,          R,          4      ^,          pVR8g  P                  RR7      p	V	P                  RR7      V,          P                  4       p
\        P                  ! Wj4      Vn        V# )	zÅ
image_position_ids (`torch.LongTensor` of shape `(batch_size, max_patches, 2)`, *optional*):
    The patch positions as (x, y) coordinates in the image. Padding patches are indicated by (-1, -1).
rÂ  r³  ©rB   ræ   rÐ   rV   rf  rÔ   )r£  r\  r¤  r   rA   r¡  rg  rŠ   rÛ  r¶  ÚtolistrH   rø  Úpooler_output)rœ   rÂ  r´  r£  Úvision_outputsr\  r¹  ræ  rÞ  Únon_pad_maskrý  s   &&&,       rL   Úget_image_featuresÚGemma4Model.get_image_featuresD  sñ   € ð ×*Ò*ñ 
Ø%ð
à1ð
ð ñ
ˆð
 +×<Ñ<ÐØ×)Ñ)Ð8IÐ)ÓJˆà$×*Ñ*¨2Õ.°4·;±;×3LÑ3L×3`Ñ3`ÐbcÕ3cÕdˆÜÐ+×1Ñ1°!Õ4¸ÕEÈ#ÕMÓNÐRSÕSˆ	Ø*¨bÑ0×5Ñ5¸"Ð5Ó=ˆØ#×'Ñ'¨BÐ'Ó/°9Õ<×DÑDÓFˆÜ',§{¢{°=Ó'NˆÔ$ØÐrN   zQProjects the last hidden state from the vision encoder into language model space.c                óx   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          RS[/# )r@   Úpixel_values_videosÚvideo_position_idsNr£  rG   rµ  )rK   rl   s   "€rL   rM   rŸ  a  sJ   ø€ ÷ ñ á"×.Ñ.ðñ "×,Ñ,¨tÕ3ðñ Ñ+Õ,ð	ñ
 
$ñrN   c           
     ó@  € VP                  ^ ^4      pV P                  ! RRVRVP                  ^ ^4      /VB pVP                  pV P                  VR7      pVP                  R,          V P
                  P                  P                  ^,          ,          p\        VP                  R,          V,          R,          4      ^,          pVR8g  P                  RR7      p	V	P                  R	R7      V,          P                  4       p
\        P                  ! Wj4      Vn        V# )
a  
video_position_ids (`torch.LongTensor` of shape `(num_videos, num_frames, max_patches, 2)`, *optional*):
    2D patch position coordinates from the video processor, with `(-1, -1)` indicating padding.
    Passed through to the vision encoder for positional embedding computation.
rÂ  r³  r·  ræ   rÐ   rV   rf  rÔ   )rf  rÔ   )Úflattenr£  r\  r¤  r   rA   r¡  rg  rŠ   rÛ  r¶  r¸  rH   rø  r¹  )rœ   r¿  rÀ  r£  rº  r\  r¹  ræ  rÞ  r»  rý  s   &&&,       rL   Úget_video_featuresÚGemma4Model.get_video_features_  s  € ð 2×9Ñ9¸!¸QÓ?ÐØ×*Ò*ñ 
Ø,ð
à1×9Ñ9¸!¸QÓ?ð
ð ñ
ˆð
 +×<Ñ<ÐØ×)Ñ)Ð8IÐ)ÓJˆà+×1Ñ1°"Õ5¸$¿+¹+×:SÑ:S×:gÑ:gÐijÕ:jÕkˆÜÐ,×2Ñ2°2Õ6¸-ÕGÈCÕOÓPÐTUÕUˆ	Ø*¨bÑ0×5Ñ5¸"Ð5Ó=ˆØ#×'Ñ'¨HÐ'Ó5¸ÕB×JÑJÓLˆä',§{¢{°=Ó'NˆÔ$ØÐrN   c          	      óÆ   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[S[ P                  S[ P                  S[ P                  3,          /# r  )rH   r/  rF  rk   rƒ   )rK   rl   s   "€rL   rM   rŸ  }  sb   ø€ ÷ +Jñ +Já×#Ñ# dÕ*ð+Jñ ×(Ñ(¨4Õ/ð+Jñ 
‰u×Ñ¡×!1Ñ!1±5×3CÑ3CÐCÕ	Dñ	+JrN   c           
     ó.  € VeK   WP                   P                  8H  pWP                   P                  8H  pWP                   P                  8H  pEMDVV P	                  4       ! \
        P                  ! RV P                   P                  \
        P                  VP                  R7      4      8H  P                  R4      pVV P	                  4       ! \
        P                  ! RV P                   P                  \
        P                  VP                  R7      4      8H  P                  R4      pVV P	                  4       ! \
        P                  ! RV P                   P                  \
        P                  VP                  R7      4      8H  P                  R4      pW4V3# )a;  
Obtains mask for multimodal placeholders (replaced by soft tokens) and hard text tokens.

Masks will be obtained from `mm_token_type_ids`, `input_ids`, or `inputs_embeds` as available and in that
precedence order. If passing `input_ids` or `inputs_embeds`, the image mask will be derived using
`config.image_token_id`. Same goes for audio and video masks

Args:
    input_ids: A tensor containing the hard token IDs from the text tokenizer.
    inputs_embeds: A tensor containing the embeddings for all hard text tokens.

Returns:
    image_mask, video_mask, audio_mask
)rÓ   rÏ   rV   rÔ   )
rA   Úimage_token_idÚvideo_token_idÚaudio_token_idÚget_input_embeddingsrH   ÚfullrÚ  rÏ   rÛ  )rœ   r  rB   Úspecial_image_maskÚspecial_video_maskÚspecial_audio_masks   &&&   rL   Úget_placeholder_maskÚ Gemma4Model.get_placeholder_mask}  sG  € ð& Ò Ø!*¯k©k×.HÑ.HÑ!HÐØ!*¯k©k×.HÑ.HÑ!HÐØ!*¯k©k×.HÑ.HÑ!HÒð Ø×,Ñ,Ô.Ü—J’J˜r 4§;¡;×#=Ñ#=ÄUÇZÁZÐXe×XlÑXlÔmóñ÷ ‰c�"‹gð ð Ø×,Ñ,Ô.Ü—J’J˜r 4§;¡;×#=Ñ#=ÄUÇZÁZÐXe×XlÑXlÔmóñ÷ ‰c�"‹gð ð Ø×,Ñ,Ô.Ü—J’J˜r 4§;¡;×#=Ñ#=ÄUÇZÁZÐXe×XlÑXlÔmóñ÷ ‰c�"‹gð ð "Ð7IÐIÐIrN   c                 ó>  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          R	S[R,          R
S[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[S[,          RS[/# )r@   r  NrÂ  r¿  rY  rC   rZ  rE   rD   r‘  rB   r  r´  rÀ  r  r£  rG   )	rH   r/  rF  rI   r   r  r   r   re   )rK   rl   s   "€rL   rM   rŸ  ­  sI  ø€ ÷ d
ñ d
á×#Ñ# dÕ*ðd
ñ ×'Ñ'¨$Õ.ðd
ñ #×.Ñ.°Õ5ð	d
ñ
 ×)Ñ)¨DÕ0ðd
ñ Ÿ™ tÕ+ðd
ñ #Ÿ\™\¨DÕ0ðd
ñ ×&Ñ&¨Õ-ðd
ñ  �ðd
ñ !×+Ñ+¨dÕ2ðd
ñ ×(Ñ(¨4Õ/ðd
ñ ˜$•;ðd
ñ "×,Ñ,¨tÕ3ðd
ñ "×,Ñ,¨tÕ3ðd
ñ  Ÿ,™,¨Õ-ðd
ñ  Ñ+Õ,ð!d
ñ" 
#ñ#d
rN   c                ó„  € VRJ V
RJ,          '       d   \        R4      hVe   Ve   \        R4      hV P                  W4      w  pppVV,          V,          pRpV
f]   VP                  4       p\        P                  ! VV P
                  P                  P                  V4      pV P                  4       ! V4      p
VfÙ   V P
                  P                  4       P                  '       d¯   V P                  P                  P                  V P
                  P                  P                  R3,          pVP                  V
P                  4      p\        P                  ! VR,          VP!                  ^^R4      V
4      pV P                  P#                  VV4      pVEe0   V P%                  W,RR7      P&                  p\        P(                  ! V^ R7      P                  V
P                  V
P*                  4      pVP-                  4       pVP/                  R4      P1                  V
4      P                  V
P                  4      p\3        V
V,          P5                  4       VP5                  4       8H  RV R	VP6                  ^ ,           24       V
P9                  VP                  V
P                  4      VP                  V
P                  4      4      p
VEe0   V P;                  W=RR7      P&                  p\        P(                  ! V^ R7      P                  V
P                  V
P*                  4      pVP-                  4       pVP/                  R4      P1                  V
4      P                  V
P                  4      p\3        V
V,          P5                  4       VP5                  4       8H  R
V R	VP6                  ^ ,           24       V
P9                  VP                  V
P                  4      VP                  V
P                  4      4      p
VEeL   VEeG   V P=                  WFRR7      pVP&                  pVP>                  pVVP                  VP                  4      ,          pVP-                  4       pVP/                  R4      P1                  V
4      P                  V
P                  4      p\3        V
V,          P5                  4       VP5                  4       8H  RV R	VP6                  ^ ,          VP6                  ^,          ,           24       V
P9                  VP                  V
P                  4      VP                  V
P                  V
P*                  4      4      p
Vfb   Ve   VPA                  4       M^ p\        PB                  ! V
P6                  ^,          V
P                  R7      V,           pVP/                  ^ 4      p\E        T;p \F        4      '       g‰   RV P
                  P                  4       RV
RVRVRV/p!V P
                  P                  4       p"V"PH                  R8H  p#V#'       d)   V	e%   \K        WšP                  R7      p$\M        RRV$/V!B p M\O        R/ V!B p V P                  ! RRVRV RVRVRV
RVRR/VB p%\Q        V%PR                  V%PT                  V%PV                  V%PX                  Ve   XMRVe   XMRV%PZ                  R7      # )áÒ  
input_features_mask (`torch.FloatTensor` of shape `(num_images, seq_length)`):
    The attention mask for the input audio.
image_position_ids (`torch.LongTensor` of shape `(batch_size, max_patches, 2)`, *optional*):
    2D patch position coordinates from the image processor, with `(-1, -1)` indicating padding.
    Passed through to the vision encoder for positional embedding computation.
video_position_ids (`torch.LongTensor` of shape `(num_videos, num_frames, max_patches, 2)`, *optional*):
    2D patch position coordinates from the video processor, with `(-1, -1)` indicating padding.
    Passed through to the vision encoder for positional embedding computation.
per_layer_inputs (`torch.Tensor`, *optional*):
    Pre-computed per-layer input text embeddings of shape `(batch_size, sequence_length, num_hidden_layers,
    hidden_size_per_layer_input)`. When provided, these are used directly instead of being computed from `input_ids`
    via `get_per_layer_inputs()` in the text model. If calling the `forward` with `inputs_embeds` instead of `input_ids`,
    you should probably precompute them and forward them along `inputs_embeds`, otherwise recomputing them needs
    to reverse the main embedding, which is expensive.
Nr  r  r  T)Úreturn_dictrÐ   z6Image features and image tokens do not match, tokens: z, features: z6Video features and video tokens do not match, tokens: z6Audio features and audio tokens do not match, tokens: rÎ   rA   rB   rC   rD   rE   ÚvisionrF   r  r  rÔ  )r\  rD   r¡   rú  Úimage_hidden_statesÚaudio_hidden_statesrh   rÕ   rÔ   rV   ).r×  rÏ  rƒ  rH   r»  rA   ro  Úpad_token_idrÊ  Úget_text_configrÃ  r«  r  rJ  rÖ   rÏ   r  r  r¼  r¹  r×   rÓ   r¶  rÅ   Ú	expand_asr!   Únumelr   Úmasked_scatterrÃ  Úget_audio_featuresrC   r!  rÄ   r  rJ   r“  r›  rc   r   re   r\  rD   r¡   rú  rh   )&rœ   r  rÂ  r¿  rY  rC   rZ  rE   rD   r‘  rB   r  r´  rÀ  r  r£  Ú
image_maskÚ
video_maskÚ
audio_maskÚmultimodal_maskÚllm_input_idsÚpad_embeddingÚllm_inputs_embedsÚimage_featuresÚn_image_tokensÚvideo_featuresÚn_video_tokensÚaudio_outputÚaudio_featuresÚaudio_mask_from_encoderÚn_audio_tokensr$  r%  rZ   ro  Ú	use_bidirrF   r7  s&   &&&&&&&&&&&&&&&,                      rL   r¦   ÚGemma4Model.forwardª  sV  € ðJ ˜Ð -°tÐ";×<Ô<ÜÐYÓZÐZàÒ Ð%5Ò%AÜÐ[Ó\Ð\à-1×-FÑ-FÀyÓ-`Ñ*ˆ
�J 
Ø$ zÕ1°JÕ>ˆð ˆØÒ Ø%ŸO™OÓ-ˆMÜ!ŸKšK¨¸¿¹×9PÑ9P×9]Ñ9]Ð_lÓmˆMØ ×5Ñ5Ô7¸ÓFˆMàÒ#¨¯©×(CÑ(CÓ(E×(a×(aÐ(aØ ×/Ñ/×<Ñ<×CÑCÀDÇKÁK×D[ÑD[×DhÑDhÐjkÐDkÕlˆMØ-×0Ñ0°×1EÑ1EÓFˆOÜ %§¢¨O¸IÕ,FÈ×HZÑHZÐ[\Ð^_ÐacÓHdÐfsÓ tÐØ#×2Ñ2×GÑGÈÐWhÓiÐð Ó#Ø!×4Ñ4°\ÐcgÐ4Óh×vÑvˆNÜ"ŸYšY ~¸1Ô=×@Ñ@À×AUÑAUÐWd×WjÑWjÓkˆNð (Ÿ^™^Ó-ˆNØ#×-Ñ-¨bÓ1×;Ñ;¸MÓJ×MÑMÈm×NbÑNbÓcˆJÜ"Ø˜jÕ)×/Ñ/Ó1°^×5IÑ5IÓ5KÑKØHÈÐHXð YØ"×(Ñ(¨Õ+Ð,ð.ôð *×8Ñ8Ø—‘˜m×2Ñ2Ó3°^×5FÑ5FÀ}×G[ÑG[Ó5\óˆMð Ó*Ø!×4Ñ4Ø#ÀTð 5ó ç‰mð ô #ŸYšY ~¸1Ô=×@Ñ@À×AUÑAUÐWd×WjÑWjÓkˆNð (Ÿ^™^Ó-ˆNØ#×-Ñ-¨bÓ1×;Ñ;¸MÓJ×MÑMÈm×NbÑNbÓcˆJÜ"Ø˜jÕ)×/Ñ/Ó1°^×5IÑ5IÓ5KÑKØHÈÐHXð YØ"×(Ñ(¨Õ+Ð,ð.ôð *×8Ñ8Ø—‘˜m×2Ñ2Ó3°^×5FÑ5FÀ}×G[ÑG[Ó5\óˆMð
 Ó%Ð*=Ó*IØ×2Ñ2°>ÐdhÐ2ÓiˆLØ)×7Ñ7ˆNØ&2×&AÑ&AÐ#ð
 ,Ð,C×,FÑ,FÀ~×G\ÑG\Ó,]Õ^ˆNà'Ÿ^™^Ó-ˆNØ#×-Ñ-¨bÓ1×;Ñ;¸MÓJ×MÑMÈm×NbÑNbÓcˆJÜ"Ø˜jÕ)×/Ñ/Ó1°^×5IÑ5IÓ5KÑKØHÈÐHXð YØ"×(Ñ(¨Õ+¨n×.BÑ.BÀ1Õ.EÕEÐFðHôð *×8Ñ8Ø—‘˜m×2Ñ2Ó3°^×5FÑ5FÀ}×G[ÑG[Ð]j×]pÑ]pÓ5qóˆMð
 ÒØCRÒC^˜×=Ñ=Ô?ÐdeÐÜ Ÿ<š<¨×(;Ñ(;¸AÕ(>À}×G[ÑG[Ô\Ð_oÕoˆLØ'×1Ñ1°!Ó4ˆLä°Ð?Ð-Ä×FÒFà˜$Ÿ+™+×5Ñ5Ó7Ø Ø  .Ø! ?Ø ðˆKð Ÿ+™+×5Ñ5Ó7ˆKØ#×?Ñ?À8ÑKˆIçÐ.Ò:Ü%DÐEV×_sÑ_sÔ%tÐ"Ü&Cñ 'Ø'9ð'à!ñ'Ñ#ô '@Ñ&NÀ+Ñ&NÐ#à×%Ò%ñ 	
Ø-ð	
à.ð	
ð &ð	
ð ,ð		
ð
 (ð	
ð  ð	
ð ð	
ð ñ	
ˆô )Ø%×7Ñ7Ø#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø2>Ò2J¡ÐPTØ2@Ò2L¡ÐRVØ$×5Ñ5ô
ð 	
rN   zPProjects the last hidden state from the audio encoder into language model space.c          	      óz   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[,          RS[S[,          /# )r@   rY  rZ  r£  rG   )rH   rI   r   r   rk   r�   )rK   rl   s   "€rL   rM   rŸ  U  sG   ø€ ÷ ñ áŸ™ðñ #Ÿ\™\ðñ Ñ+Õ,ð	ñ
 
Ñ'Õ	'ñrN   c                ó¤   € V P                   f   \        R4      hV P                   ! W3RR/VB pV P                  VP                  R7      Vn        V# )a  
input_features (`torch.FloatTensor` of shape `(num_images, seq_length, num_features)`):
    The tensors corresponding to the input audio.
input_features_mask (`torch.FloatTensor` of shape `(num_images, seq_length)`):
    The attention mask for the input audio.
z•Audio features were requested, but the model was initialized without an audio_config. Cannot process audio without an audio tower and audio embedder.rÔ  Tr·  )r¦  r×  r§  r\  r¹  )rœ   rY  rZ  r£  Úaudio_outputss   &&&, rL   rÝ  ÚGemma4Model.get_audio_featuresS  sc   € ð ×ÑÒ#ÜðRóð ð
 ×(Ò(¨ÑiÐZ^ÐiÐbhÑiˆØ&*×&6Ñ&6À]×EdÑEdÐ&6Ó&eˆÔ#àÐrN   )r¦  r§  r¤  r£  r¤   )NN)NNNNNNNNNNNNNN)ro   rp   rq   rr   r‘   r­  r±  r   r   r¼  rÃ  rÏ  r#   r¦   rÝ  ru   rv   r©   rª   s   @@rL   r�  r�  (  sË   ù‡ € ÷
ó 
ò:ò;ð ÙÐ!rÔs÷ñ ó tó ðð2 ÙÐ!tÔu÷ñ ó vó ð÷8+Jò +JðZ  ØØ÷d
ñ d
ó ó ó  ðd
ðL ÙÐ!sÔt÷ó uó ÷ð rN   r�  z…
    The base Gemma 4 model comprising a vision backbone, an audio backbone, a language model, and a language modeling
    head.
    c                   óœ   a a€ ] tR tRt oRtR tR tRV3R lR llt]RV3R lR ll4       t	]
RV3R	 lR
 ll4       tRV 3R lltRtVtV ;t# )ÚGemma4ForConditionalGenerationim  r*  c                ó6   € V P                   P                  4       # r¤   )r*  r­  r¬  s   &rL   r­  Ú=Gemma4ForConditionalGeneration.get_per_layer_input_embeddingsv  s   € Ø�z‰z×8Ñ8Ó:Ð:rN   c                ó<   € V P                   P                  V4       R # r¤   )r*  r±  r°  s   &&rL   r±  Ú=Gemma4ForConditionalGeneration.set_per_layer_input_embeddingsy  s   € Ø�
‰
×1Ñ1°%Ö8rN   c          $      ó�  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[S[ P                  ,          RS[ P                  R,          RS[S[,          RS[	/# )r@   r  NrÂ  r¿  rY  rC   rZ  rE   r´  rÀ  rD   r‘  rB   r,  r  r-  r  r£  rG   )
rH   r/  rF  rI   r   r  rŠ   r   r   ry   )rK   rl   s   "€rL   rM   Ú+Gemma4ForConditionalGeneration.__annotate__|  ss  ø€ ÷ N
ñ N
á×#Ñ# dÕ*ðN
ñ ×'Ñ'¨$Õ.ðN
ñ #×.Ñ.°Õ5ð	N
ñ
 ×)Ñ)¨DÕ0ðN
ñ Ÿ™ tÕ+ðN
ñ #Ÿ\™\¨DÕ0ðN
ñ ×&Ñ&¨Õ-ðN
ñ "×,Ñ,¨tÕ3ðN
ñ "×,Ñ,¨tÕ3ðN
ñ  �ðN
ñ !×+Ñ+¨dÕ2ðN
ñ ×(Ñ(¨4Õ/ðN
ñ × Ñ  4Õ'ðN
ñ ˜$•;ðN
ñ  ™eŸl™lÕ*ð!N
ñ"  Ÿ,™,¨Õ-ð#N
ñ$ Ñ+Õ,ð%N
ñ& 
&ñ'N
rN   c                óÔ  € V P                   ! R/ RVbRVbRVbRVbRVbRVbRVbRV
bR	VbR
VbRVbRVbRVbRVbRV	bRRbVB pVP                  p\        V\        4      '       d   \	        V) R4      MTpV P                  VRVR3,          4      pV P                  P                  4       P                  ;pe)   VV,          p\        P                  ! V4      pVV,          pRpVe7   V P                  ! VWÐP                  P                  4       P                  3/ VB p\        VVVP                  VP                  VP                   VP"                  VP$                  VP&                  R7      # )rÓ  r  rÂ  r¿  rY  rC   rZ  rE   rD   r‘  rB   r  r,  r  r´  rÀ  rÔ  TNr  )r0  r1  rD   r¡   rú  rÖ  r×  rh   rV   )r*  r\  r  rŠ   r2  r3  rA   rÙ  r4  rH   r   r5  r6  ry   rD   r¡   rú  rÖ  r×  rh   )rœ   r  rÂ  r¿  rY  rC   rZ  rE   r´  rÀ  rD   r‘  rB   r,  r  r-  r  r£  r7  r¡   r8  r1  r4  r0  s   &&&&&&&&&&&&&&&&&,      rL   r¦   Ú&Gemma4ForConditionalGeneration.forward|  s¹  € ðH —*’*ò 
Ùð
á%ð
ñ !4ð
ñ *ð	
ñ
 *ð
ñ !4ð
ñ &ð
ñ ,ð
ñ 0ð
ñ (ð
ñ .ð
ñ ð
ñ  ð
ñ  2ð
ñ  2ð
ñ  Øñ#
ˆð(  ×1Ñ1ˆä8BÀ>ÔSV×8WÒ8Wœ˜~˜o¨tÔ4Ð]kˆØ—‘˜m¨A¨}¸aÐ,?Õ@ÓAˆØ'+§{¡{×'BÑ'BÓ'D×'\Ñ'\Ð\Ð#ÒiØÐ5Õ5ˆFÜ—Z’Z Ó'ˆFØÐ5Õ5ˆFàˆØÒØ×%Ò% f¨f·k±k×6QÑ6QÓ6S×6^Ñ6^ÑiÐbhÑiˆDä+ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø '× ;Ñ ;Ø '× ;Ñ ;Ø$×5Ñ5ô	
ð 		
rN   c                ór   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          /# )r@   rÂ  r´  Nr£  )rH   rF  r/  r   r   )rK   rl   s   "€rL   rM   rú  Í  sE   ø€ ÷ Yñ Yá×'Ñ'ðYñ "×,Ñ,¨tÕ3ðYñ Ñ+Õ,ñ	YrN   c                ó<   € V P                   P                  ! W3/ VB # )a  
image_position_ids (`torch.LongTensor` of shape `(batch_size, max_patches, 2)`, *optional*):
    2D patch position coordinates from the image processor, with `(-1, -1)` indicating padding.
    Passed through to the vision encoder for positional embedding computation.
)r*  r¼  )rœ   rÂ  r´  r£  s   &&&,rL   r¼  Ú1Gemma4ForConditionalGeneration.get_image_featuresÌ  s   € ð �z‰z×,Ò,¨\ÑXÐQWÑXÐXrN   c                óà   <€ V ^8„  d   QhRS[ RS[P                  RS[P                  R,          RS[R,          RS[P                  R,          RS[P                  R,          RS[R,          R	S[/# )
r@   rA   rB   rC   NrD   rE   r‘  Úis_first_iterationrG   )r   rH   rI   r   r  rJ   )rK   rl   s   "€rL   rM   rú  Û  s€   ø€ ÷ 8ñ 8Ù ð8á—|‘|ð8ñ Ÿ™ tÕ+ð8ñ  �ð	8ñ
 —l‘l TÕ)ð8ñ !Ÿ<™<¨$Õ.ð8ñ ! 4�Kð8ñ 
ñ8rN   c           
     óê   € R V P                  4       RVRVRVRV/pV P                  4       p	\        V	RR4      R8H  p
V
'       d(   Ve$   \        WQP                  R7      p\	        R
R	V/VB # \        R
/ VB # )rA   rB   rC   rD   rE   r“  NrÕ  rÎ   rF   rV   )rÙ  rW   r›  rÏ   rc   r   )rA   rB   rC   rD   rE   r‘  r  r£  rZ   ro  rí  rF   s   &&&&&&&,    rL   r   Ú8Gemma4ForConditionalGeneration.create_masks_for_generateÚ  sš   € ð �f×,Ñ,Ó.Ø˜]Ø˜nØ˜Ø˜Lð
ˆð ×,Ñ,Ó.ˆÜ˜KÐ)FÈÓMÐQYÑYˆ	çÐ*Ò6Ü!@ÐAR×[oÑ[oÔ!pÐÜ0ñ Ø#5ðàñð ô
 )Ñ7¨;Ñ7Ð7rN   c                ó�   <€ \         SV `  ! V3R VRV/VB pV'       g   V'       d   RVR&   V'       g   VP                  RR4      pV# )r  r  Nr‘  r  )r�   Úprepare_inputs_for_generationr"  )rœ   r  r  r  r£  Úmodel_inputsr^   r�   s   &&&&,  €rL   r  Ú<Gemma4ForConditionalGeneration.prepare_inputs_for_generationù  s[   ø€ Ü‘wÒ<Øñ
Ø!*ð
Ø?Qð
ØU[ñ
ˆ÷ #¯)à04ˆLÐ,Ñ-ç!Ø× Ñ Ð!3°TÓ:ˆAàÐrN   rV   )NNNNNNNNNNNNNNr   Nr¤   )NF)TF)ro   rp   rq   rr   r:  r­  r±  r¦   r   r¼  Ústaticmethodr   r  ru   rv   r©   rª   s   @@rL   rô  rô  m  sc   ù‡ € ð  Ðò;ò9÷N
ò N
ð` ÷Yñ Yó ðYð ÷8ñ 8ó ð8÷<÷ rN   rô  )r@   )r<  r)  rô  r�  rØ  rø  rè  )‡rÀ   Úcollectionsr   Úcollections.abcr   Údataclassesr   Ú	functoolsr   rH   r   Útorch.nnr   r  Ú r	   rÝ  Úactivationsr
   Úcache_utilsr   r   Úconfiguration_utilsr   Úmasking_utilsr   r   r   r   r   r   r   r   Úmodeling_flash_attention_utilsr   Úmodeling_outputsr   r   Úmodeling_rope_utilsr   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr   r   r   r    r!   Úutils.genericr"   r#   r$   Úutils.output_capturingr%   r&   Úauto.modeling_autor'   Úgemma3.modeling_gemma3r(   r)   r*   r+   r,   r-   r.   Úgemma3n.modeling_gemma3nr/   r0   r1   r2   r3   r4   r5   r6   r7   Úmixtral.modeling_mixtralr8   Ú0moonshine_streaming.modeling_moonshine_streamingr9   Úsam3.modeling_sam3r:   Úconfiguration_gemma4r;   r<   r=   r>   Ú
get_loggerro   Úloggerrc   re   ry   r}   r�   rw  r†   r¬   r°   rà   r4  rM  r_  ÚConv1drw  rƒ  r–  r§  rÈ  rê  r  r  r!  r=  rN  r`  rk  r‹  rŸ  r©  r½  rÖ  rØ  rø  r)  r<  rè  rl  r�  r›  r�  rô  Ú__all__rV   rN   rL   Ú<module>r&     s‘  ðó Ý  Ý $Ý !Ý %ã Ý Ý $å &Ý !ß .Ý 3÷	÷ 	ó 	õ Cß SÝ 6ß FÝ &÷õ ÷ ^Ñ ]ß EÝ *÷÷ ñ ÷
÷ 
õ 
õ 6Ý [Ý 7ß gÓ gð 
×	Ò	˜HÓ	%€õ<ô~QÐ :ô Qô*QÐ#@ô Qð2 ô
QÐ$;ó 
Qó ð
Qð Ø
ô3Ð7ó 3ó ó ð3ô˜BŸI™Iô ô:	�Nô 	ô7 r§y¡yô 7ô>i)˜2Ÿ9™9ô i)ôX#¨b¯i©iô #ô8;¨¯©ô ;ô< ˜RŸY™Yô  ôH"˜bŸi™iô "ôB&˜RŸY™Yô &ôR0�r—y‘yô 0ôl*3 §	¡	ô *3ôZ@0˜Ÿ™ô @0ôFa�iô a÷5&ôrCÐ"8ô Cð< ô:)˜Oó :)ó ð:)ô|"Ð1ô "ôJ)H˜"Ÿ)™)ô )Hô^^�Iô ^ôUÐ 5ô UôBq)˜"Ÿ)™)ô q)ôh7˜ô 7ô"@�r—y‘yô "@ôJOÐ/ô Oôd	Ð$Aô 	ô1)Ð2ô 1)ñh Ð`ÔaôW
�oó W
ó bðW
ñt Ð]Ô^ôJ
Ð)ó J
ó _ðJ
ôZScÐ,ô ScôlAHÐ-ô AHôH6Ð8ô 6õ>õ:	ñ ðôô|�,ó |óð|ñ~	 ðôôQÐ%Dó QóðQòh‚rN   