Ë
    T^(hIS ã                   óL  — d dl Z d dlmZ d dlmZmZmZmZmZ d dl	Z	d dl
mZ d dlmc mZ d dlZ	d dlmZ ddlmZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1  e,«       rd dl2m3Z3 ddl4m5Z5  e-jl                  e7«      Z8dZ9dZ: G d„ dejv                  «      Z< G d„ dejv                  «      Z= G d„ de	j                  jv                  «      Z> G d„ dejv                  «      Z? G d„ dejv                  «      Z@ G d „ d!ejv                  «      ZAd"e	j„                  d#e	j„                  d$e	j„                  d%ee	j„                  e	j„                  f   fd&„ZCd'e	j„                  d(eDd%e	j„                  fd)„ZE	 d]d*ejv                  d+e	j„                  d,e	j„                  d-e	j„                  d.ee	j„                     d/eFd0eFfd1„ZG G d2„ d3ejv                  «      ZH G d4„ d5ejv                  «      ZId6ZJ e*d7eJ«       G d8„ d9e&«      «       ZKd:ZL e*d7eJ«       G d;„ d<eK«      «       ZM G d=„ d>eKe«      ZNe G d?„ d@e!«      «       ZO G dA„ dBe	j                  jv                  «      ZP G dC„ dDejv                  «      ZQdE„ ZR G dF„ dGejv                  «      ZSdHZTdIe	j„                  d+e	j„                  fdJ„ZUd+e	j„                  d,e	j„                  dIe	j„                  d%ee	j„                  e	j„                  f   fdK„ZV G dL„ dMejv                  «      ZW G dN„ dOejv                  «      ZX G dP„ dQejv                  «      ZY G dR„ dSejv                  «      ZZ G dT„ dUejv                  «      Z[ G dV„ dWejv                  «      Z\ G dX„ dYeK«      Z] G dZ„ d[eKe«      Z^g d\¢Z_y)^é    N)Ú	dataclass)ÚCallableÚListÚOptionalÚTupleÚUnion)ÚLlama4VisionConfigé   )ÚACT2FN)ÚCacheÚHybridChunkedCache)ÚGenerationMixin)ÚAttentionMaskConverter)ÚFlashAttentionKwargs)ÚBaseModelOutputÚBaseModelOutputWithPastÚCausalLMOutputWithPastÚModelOutput)ÚROPE_INIT_FUNCTIONS)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)Úadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚis_torch_flex_attn_availableÚloggingÚreplace_return_docstringsé   )ÚLlama4ConfigÚLlama4TextConfig)Ú	BlockMask)Úmake_flex_block_causal_maskzmeta-ai/Llama-4-17Br   c                   ó\   ‡ — e Zd Zdefˆ fd„Zdej                  dej                  fd„Zˆ xZS )ÚLlama4TextExpertsÚconfigc                 ó  •— t         ‰| �  «        |j                  | _        |j                  | _        |j
                  | _        | j                  | _        t        j                  t        j                  | j                  | j
                  d| j                  z  «      «      | _        t        j                  t        j                  | j                  | j                  | j
                  f«      «      | _        t        |j                     | _        y ©Né   )ÚsuperÚ__init__Únum_local_expertsÚnum_expertsÚintermediate_sizeÚhidden_sizeÚ
expert_dimÚnnÚ	ParameterÚtorchÚemptyÚgate_up_projÚ	down_projr   Ú
hidden_actÚact_fn©Úselfr%   Ú	__class__s     €úh/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/llama4/modeling_llama4.pyr*   zLlama4TextExperts.__init__>   s¿   ø€ Ü‰ÑÔØ!×3Ñ3ˆÔØ!'×!9Ñ!9ˆÔØ!×-Ñ-ˆÔØ×0Ñ0ˆŒÜŸL™L¬¯©°T×5EÑ5EÀt×GWÑGWÐYZÐ]a×]lÑ]lÑYlÓ)mÓnˆÔÜŸ™¤e§k¡k°4×3CÑ3CÀTÇ_Á_ÐVZ×VfÑVfÐ2gÓ&hÓiˆŒÜ˜V×.Ñ.Ñ/ˆ�ó    Úhidden_statesÚreturnc                 ó\  — |j                  | j                  d| j                  «      }t        j                  || j
                  «      }|j                  dd¬«      \  }}t        j                  || j                  |«      z  | j                  «      }|j                  d| j                  «      }|S )a2  
        This should really not be run on a single machine, as we are reaching compute bound:
        - the inputs are expected to be "sorted" per expert already.
        - the weights are viewed with another dim, to match num_expert, 1, shape * num_tokens, shape

        Args:
            hidden_states (torch.Tensor): (batch_size * token_num, hidden_size)
            selected_experts (torch.Tensor): (batch_size * token_num, top_k)
            routing_weights (torch.Tensor): (batch_size * token_num, top_k)
        Returns:
            torch.Tensor
        éÿÿÿÿr(   ©Údim)	Úviewr,   r.   r2   Úbmmr4   Úchunkr7   r5   )r9   r=   Úgate_upÚgateÚupÚnext_statess         r;   ÚforwardzLlama4TextExperts.forwardH   s�   € ð &×*Ñ*¨4×+;Ñ+;¸RÀ×AQÑAQÓRˆÜ—)‘)˜M¨4×+<Ñ+<Ó=ˆØ—=‘= ¨�=Ó+‰ˆˆbÜ—i‘i  d§k¡k°$Ó&7Ñ!7¸$¿.¹.ÓIˆØ!×&Ñ& r¨4×+;Ñ+;Ó<ˆØÐr<   )	Ú__name__Ú
__module__Ú__qualname__r   r*   r2   ÚTensorrJ   Ú__classcell__©r:   s   @r;   r$   r$   =   s*   ø„ ð0˜|õ 0ð U§\¡\ð °e·l±l÷ r<   r$   c                   ó&   ‡ — e Zd Zdˆ fd„	Zd„ Zˆ xZS )ÚLlama4TextMLPc                 óf  •— t         ‰| �  «        |€|j                  }|| _        t	        j
                  |j                  |d¬«      | _        t	        j
                  |j                  |d¬«      | _        t	        j
                  ||j                  d¬«      | _	        t        |j                     | _        y ©NF©Úbias)r)   r*   r-   r%   r0   ÚLinearr.   Ú	gate_projÚup_projr5   r   r6   Úactivation_fn)r9   r%   r-   r:   s      €r;   r*   zLlama4TextMLP.__init___   s‹   ø€ Ü‰ÑÔàÐ$Ø &× 8Ñ 8ÐàˆŒÜŸ™ 6×#5Ñ#5Ð7HÈuÔUˆŒÜ—y‘y ×!3Ñ!3Ð5FÈUÔSˆŒÜŸ™Ð#4°f×6HÑ6HÈuÔUˆŒÜ# F×$5Ñ$5Ñ6ˆÕr<   c                 óˆ   — | j                  | j                  |«      «      | j                  |«      z  }| j                  |«      S ©N)rZ   rX   rY   r5   )r9   Úxr5   s      r;   rJ   zLlama4TextMLP.forwardk   s7   € Ø×&Ñ& t§~¡~°aÓ'8Ó9¸D¿L¹LÈ»OÑKˆ	Ø�~‰~˜iÓ(Ð(r<   r\   ©rK   rL   rM   r*   rJ   rO   rP   s   @r;   rR   rR   ^   s   ø„ õ
7ö)r<   rR   c                   ó8   ‡ — e Zd Zddefˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )ÚLlama4TextL2NormÚepsc                 ó0   •— t         ‰| �  «        || _        y r\   )r)   r*   ra   )r9   ra   r:   s     €r;   r*   zLlama4TextL2Norm.__init__q   s   ø€ Ü‰ÑÔØˆ�r<   c                 óŒ   — |t        j                  |j                  d«      j                  dd¬«      | j                  z   «      z  S ©Nr(   r@   T)Úkeepdim©r2   ÚrsqrtÚpowÚmeanra   ©r9   r]   s     r;   Ú_normzLlama4TextL2Norm._normu   ó4   € Ø”5—;‘;˜qŸu™u Q›xŸ}™}¨R¸˜}Ó>ÀÇÁÑIÓJÑJÐJr<   c                 ó^   — | j                  |j                  «       «      j                  |«      S r\   )rk   ÚfloatÚtype_asrj   s     r;   rJ   zLlama4TextL2Norm.forwardx   s"   € Ø�z‰z˜!Ÿ'™'›)Ó$×,Ñ,¨QÓ/Ð/r<   c                 ó    — d| j                   › �S )Nzeps=©ra   ©r9   s    r;   Ú
extra_reprzLlama4TextL2Norm.extra_repr{   s   € Ø�d—h‘h�ZÐ Ð r<   )g�íµ ÷Æ°>)	rK   rL   rM   rn   r*   rk   rJ   rs   rO   rP   s   @r;   r`   r`   p   s   ø„ ñ˜Eõ òKò0ö!r<   r`   c                   ó2   ‡ — e Zd Zdˆ fd„	Zd„ Zd„ Zd„ Zˆ xZS )ÚLlama4TextRMSNormc                 óŠ   •— t         ‰| �  «        || _        t        j                  t        j                  |«      «      | _        y)z<
        Llama4RMSNorm is equivalent to T5LayerNorm
        N)r)   r*   ra   r0   r1   r2   ÚonesÚweight)r9   r.   ra   r:   s      €r;   r*   zLlama4TextRMSNorm.__init__€   s0   ø€ ô 	‰ÑÔØˆŒÜ—l‘l¤5§:¡:¨kÓ#:Ó;ˆ�r<   c                 óŒ   — |t        j                  |j                  d«      j                  dd¬«      | j                  z   «      z  S rd   rf   rj   s     r;   rk   zLlama4TextRMSNorm._normˆ   rl   r<   c                 ó|   — | j                  |j                  «       «      j                  |«      }|| j                  z  S r\   )rk   rn   ro   rx   )r9   r]   Úoutputs      r;   rJ   zLlama4TextRMSNorm.forward‹   s0   € Ø—‘˜AŸG™G›IÓ&×.Ñ.¨qÓ1ˆØ˜Ÿ™Ñ#Ð#r<   c                 ó^   — t        | j                  j                  «      › d| j                  › �S )Nz, eps=)Útuplerx   Úshapera   rr   s    r;   rs   zLlama4TextRMSNorm.extra_repr�   s'   € Ü˜Ÿ™×)Ñ)Ó*Ð+¨6°$·(±(°Ð<Ð<r<   )gñhãˆµøä>)rK   rL   rM   r*   rk   rJ   rs   rO   rP   s   @r;   ru   ru      s   ø„ õ<òKò$ö=r<   ru   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLlama4TextMoec                 ó*  •— t         ‰| �  «        |j                  | _        |j                  | _        |j                  | _        t        |«      | _	        t        j                  |j                  |j                  d¬«      | _        t        |«      | _        y rT   )r)   r*   Únum_experts_per_tokÚtop_kr.   Ú
hidden_dimr+   r,   r$   Úexpertsr0   rW   ÚrouterrR   Úshared_expertr8   s     €r;   r*   zLlama4TextMoe.__init__”   sp   ø€ Ü‰ÑÔØ×/Ñ/ˆŒ
Ø ×,Ñ,ˆŒØ!×3Ñ3ˆÔÜ(¨Ó0ˆŒÜ—i‘i × 2Ñ 2°F×4LÑ4LÐSXÔYˆŒÜ*¨6Ó2ˆÕr<   c                 ó,  — |j                   \  }}}|j                  d| j                  «      }| j                  |«      j	                  dd«      }||z  }t        j                  |j	                  dd«      | j                  d¬«      \  }}t        j                  |j	                  dd«      t        d«      «      j                  d||«      j	                  dd«      }	t        j                  ||j                  ¬«      j                  dd«      j                  |	j                  d«      d«      }t        j                  |	j                  «       «      j!                  |j"                  «      }	|j%                  dd«      j                  d|«      }t        j&                  |d|¬«      j!                  |j                  «      }
|
|	j%                  dd«      z  }
| j)                  |
«      }| j+                  |«      }|j-                  d||j                  d|«      ¬«       ||	fS )	Nr@   r   r   rA   z-inf©Údevice)ÚinputrB   Úindex)rB   rŒ   Úsrc)r~   rC   r„   r†   Ú	transposer2   Útopkrƒ   Ú	full_likern   Úscatter_ÚarangerŠ   ÚexpandÚsizeÚsigmoidÚtoÚdtypeÚreshapeÚgatherr…   r‡   Úscatter_add_)r9   r=   ÚbatchÚseq_lenr„   Úrouter_logitsÚtokens_per_expertÚrouter_top_valueÚrouter_indicesÚrouter_scoresÚ	routed_inÚ
routed_outÚouts                r;   rJ   zLlama4TextMoe.forward�   sÙ  € Ø%2×%8Ñ%8Ñ"ˆˆw˜
Ø%×*Ñ*¨2¨t¯©Ó?ˆØŸ™ MÓ2×<Ñ<¸QÀÓBˆØ! G™OÐä+0¯:©:°m×6MÑ6MÈaÐQRÓ6SÐUY×U_ÑU_ÐefÔ+gÑ(Ð˜.ä�O‰O˜M×3Ñ3°A°qÓ9¼5À»=ÓIß‰X�a˜Ð)9Ó:ß‰Y�q˜!‹_ð 	ô �L‰LÐ*°=×3GÑ3GÔH×MÑMÈaÐQSÓT×[Ñ[Ð\i×\nÑ\nÐopÓ\qÐsuÓvð 	ô Ÿ™ m×&9Ñ&9Ó&;Ó<×?Ñ?À×@SÑ@SÓTˆà'×/Ñ/°°AÓ6×=Ñ=¸bÀ*ÓMˆÜ—L‘LØØØ ô
÷ ‰"ˆ]×!Ñ!Ó
"ð	 	ð  × 5Ñ 5°b¸!Ó <Ñ<ˆ	Ø—\‘\ )Ó,ˆ
Ø× Ñ  Ó/ˆð 	×Ñ˜Q n¸*¿/¹/È"ÈjÓ:YÐÔZØ�MÐ!Ð!r<   r^   rP   s   @r;   r€   r€   “   s   ø„ ô3ö!"r<   r€   c                   óZ   ‡ — e Zd Zddefˆ fd„Zd„ Z ej                  «       d„ «       Zˆ xZ	S )ÚLlama4TextRotaryEmbeddingr%   c                 ó`  •— t         ‰| �  «        |j                  �dnd| _        |j                  | _        |j                  | _        || _        t        | j                     | _	        | j                  | j                  |«      \  }| _
        | j                  d|d¬«       | j                  | _        y )NÚllama3ÚdefaultÚinv_freqF©Ú
persistent)r)   r*   Úrope_scalingÚ	rope_typeÚmax_position_embeddingsÚmax_seq_len_cachedÚoriginal_max_seq_lenr%   r   Úrope_init_fnÚattention_scalingÚregister_bufferrª   Úoriginal_inv_freq)r9   r%   rŠ   rª   r:   s       €r;   r*   z"Llama4TextRotaryEmbedding.__init__Â   s•   ø€ Ü‰ÑÔà%+×%8Ñ%8Ð%D™È)ˆŒà"(×"@Ñ"@ˆÔØ$*×$BÑ$BˆÔ!àˆŒÜ/°·±Ñ?ˆÔà+/×+<Ñ+<¸T¿[¹[È&Ó+QÑ(ˆ�$Ô(Ø×Ñ˜Z¨¸eÐÔDØ!%§¡ˆÕr<   c                 óÆ  — t        j                  |«      dz   }|| j                  kD  rA| j                  | j                  ||¬«      \  }| _        | j                  d|d¬«       || _        || j                  k  rj| j                  | j                  kD  rP| j                  j                  |«      | _        | j                  d| j                  d¬«       | j                  | _        yyy)a  
        dynamic RoPE layers should recompute `inv_freq` in the following situations:
        1 - growing beyond the cached sequence length (allow scaling)
        2 - the current sequence length is in the original scale (avoid losing precision with small sequences)
        r   )rœ   rª   Fr«   N)
r2   Úmaxr°   r²   r%   r³   r´   r±   rµ   r–   )r9   Úposition_idsrŠ   rœ   rª   s        r;   Ú_dynamic_frequency_updatez3Llama4TextRotaryEmbedding._dynamic_frequency_updateÑ   sÕ   € ô —)‘)˜LÓ)¨AÑ-ˆØ�T×,Ñ,Ò,Ø/3×/@Ñ/@ÀÇÁÈfÐ^eÐ/@Ó/fÑ,ˆH�dÔ,Ø× Ñ  ¨XÀ%Ð ÔHØ&-ˆDÔ#à�T×.Ñ.Ò.°4×3JÑ3JÈT×MfÑMfÒ3fð &*×%;Ñ%;×%>Ñ%>¸vÓ%FˆDÔ"Ø× Ñ  ¨T×-CÑ-CÐPUÐ ÔVØ&*×&?Ñ&?ˆDÕ#ð 4gÐ.r<   c                 ó’  — d| j                   v r| j                  ||j                  ¬«       | j                  d d d …d f   j	                  «       j                  |j                  d   dd«      }|d d …d d d …f   j	                  «       }|j                  j                  }t        |t        «      r|dk7  r|nd}t        j                  |d¬	«      5  |j                  |j                  «      |z  j                  dd
«      }t        j                  t        j                  |«      |«      }d d d «       | j                   z  }|S # 1 sw Y   ŒxY w)NÚdynamicr‰   r   r@   r   ÚmpsÚcpuF)Údevice_typeÚenabledr(   )r®   r¹   rŠ   rª   rn   r“   r~   ÚtypeÚ
isinstanceÚstrr2   Úautocastr–   rŽ   ÚpolarÚ	ones_liker³   )r9   r]   r¸   Úinv_freq_expandedÚposition_ids_expandedr¾   ÚfreqsÚ	freqs_ciss           r;   rJ   z!Llama4TextRotaryEmbedding.forwardä   s!  € à˜Ÿ™Ñ&Ø×*Ñ*¨<ÀÇÁÐ*ÔIà ŸM™M¨$²°4¨-Ñ8×>Ñ>Ó@×GÑGÈ×HZÑHZÐ[\ÑH]Ð_aÐcdÓeÐØ ,ªQ°²a¨ZÑ 8× >Ñ >Ó @Ðà—h‘h—m‘mˆÜ%/°¼SÔ%AÀkÐUZÒFZ‘kÐ`eˆÜ�^‰^¨¸UÔCñ 	CØ&×)Ñ)¨!¯(©(Ó3Ð6KÑK×VÑVÐWXÐZ[Ó\ˆEÜŸ™¤E§O¡O°EÓ$:¸EÓBˆI÷	Cð
  × 6Ñ 6Ñ6ˆ	ØÐ÷	Cð 	Cús   ÃAD=Ä=Er\   )
rK   rL   rM   r    r*   r¹   r2   Úno_gradrJ   rO   rP   s   @r;   r¦   r¦   Á   s2   ø„ ñ/Ð/õ /ò@ð& €U‡]�]ƒ_ñó ôr<   r¦   ÚxqÚxkrÉ   r>   c           	      ó&  — t        j                   | j                  «       j                  g | j                  d d ¢d‘d‘­Ž «      }t        j                   |j                  «       j                  g |j                  d d ¢d‘d‘­Ž «      }t        j
                  ||d d …d d …d d d …f   z  «      j                  d«      }t        j
                  ||d d …d d …d d d …f   z  «      j                  d«      }|j                  | «      |j                  |«      fS )Nr@   r(   r
   )r2   Úview_as_complexrn   r˜   r~   Úview_as_realÚflattenro   )rË   rÌ   rÉ   Úxq_Úxk_Úxq_outÚxk_outs          r;   Úapply_rotary_embrÕ   ÷   sñ   € ô
 ×
Ñ
Ð 2 §¡£
× 2Ñ 2Ð I°B·H±H¸S¸b°MÐ IÀ2Ð IÀqÒ IÓ
J€CÜ
×
Ñ
Ð 2 §¡£
× 2Ñ 2Ð I°B·H±H¸S¸b°MÐ IÀ2Ð IÀqÒ IÓ
J€CÜ×Ñ  i²²1°dºA°Ñ&>Ñ >Ó?×GÑGÈÓJ€FÜ×Ñ  i²²1°dºA°Ñ&>Ñ >Ó?×GÑGÈÓJ€FØ�>‰>˜"Ó˜vŸ~™~¨bÓ1Ð1Ð1r<   r=   Ún_repc                 óª   — | j                   \  }}}}|dk(  r| S | dd…dd…ddd…dd…f   j                  |||||«      } | j                  |||z  ||«      S )zÔ
    This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
    num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
    r   N)r~   r“   r˜   )r=   rÖ   r›   Únum_key_value_headsÚslenÚhead_dims         r;   Ú	repeat_kvrÛ     so   € ð
 2?×1DÑ1DÑ.€EÐ  hØ�‚zØÐØ!¢!¢Q¨ªa²Ð"2Ñ3×:Ñ:¸5ÐBUÐW\Ð^bÐdlÓm€MØ× Ñ  Ð(;¸eÑ(CÀTÈ8ÓTÐTr<   ÚmoduleÚqueryÚkeyÚvalueÚattention_maskÚscalingÚdropoutc                 óŒ  — t        || j                  «      }t        || j                  «      }	t        j                  ||j	                  dd«      «      t        j                  | j                  «      z  }
|�#|d d …d d …d d …d |j                  d   …f   }|
|z   }
t        j                  j                  |
j                  «       d¬«      j                  |j                  «      }
t        j                  j                  |
|| j                   ¬«      }
t        j                  |
|	«      }|j	                  dd«      j#                  «       }||
fS )Nr(   r
   éþÿÿÿr@   rA   ©ÚpÚtrainingr   )rÛ   Únum_key_value_groupsr2   ÚmatmulrŽ   ÚmathÚsqrtrÚ   r~   r0   Ú
functionalÚsoftmaxrn   r–   r—   râ   rç   Ú
contiguous)rÜ   rÝ   rÞ   rß   rà   rá   râ   ÚkwargsÚ
key_statesÚvalue_statesÚattn_weightsÚcausal_maskÚattn_outputs                r;   Úeager_attention_forwardrõ     s  € ô ˜3 × ;Ñ ;Ó<€JÜ˜U F×$?Ñ$?Ó@€LÜ—<‘<  z×';Ñ';¸A¸qÓ'AÓBÄTÇYÁYÈvÏÉÓE_Ñ_€LØÐ!Ø$¢Qªª1Ð.D°
×0@Ñ0@ÀÑ0DÐ.DÐ%DÑEˆØ# kÑ1ˆä—=‘=×(Ñ(¨×);Ñ);Ó)=À2Ð(ÓF×IÑIÈ%Ï+É+ÓV€LÜ—=‘=×(Ñ(¨¸È6Ï?É?Ð(Ó[€LÜ—,‘,˜|¨\Ó:€KØ×'Ñ'¨¨1Ó-×8Ñ8Ó:€Kà˜Ð$Ð$r<   c                   ó2  ‡ — e Zd ZdZdefˆ fd„Z	 	 ddej                  deej                  ej                  f   de	ej                     de	e
   de	ej                     d	ee   d
eej                  e	ej                     e	eej                        f   fd„Zˆ xZS )ÚLlama4TextAttentionz=Multi-headed attention from 'Attention Is All You Need' paperr%   c                 ó¼  •— t         ‰| �  «        || _        || _        t	        |d|j
                  |j                  z  «      | _        |j                  | _        |j                  |j                  z  | _	        |j                  | _        | j                  dz  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        d| _        t!        |dz   dz  dk7  «      | _        t%        j&                  |j
                  |j                  | j                  z  |j(                  ¬«      | _        t%        j&                  |j
                  |j                  | j                  z  |j(                  ¬«      | _        t%        j&                  |j
                  |j                  | j                  z  |j(                  ¬«      | _        t%        j&                  |j                  | j                  z  |j
                  |j(                  ¬«      | _        | j                  j2                  r(| j"                  rt5        |j6                  «      | _        y y y )NrÚ   ç      à¿Tr   é   r   rU   )r)   r*   r%   Ú	layer_idxÚgetattrr.   Únum_attention_headsrÚ   rØ   rè   rá   Ú
attn_scaleÚfloor_scaleÚattn_temperature_tuningÚattention_dropoutÚ	is_causalÚintÚuse_roper0   rW   Úattention_biasÚq_projÚk_projÚv_projÚo_projÚuse_qk_normr`   Úrms_norm_epsÚqk_norm©r9   r%   rû   r:   s      €r;   r*   zLlama4TextAttention.__init__+  sÛ  ø€ Ü‰ÑÔØˆŒØ"ˆŒÜ ¨
°F×4FÑ4FÈ&×JdÑJdÑ4dÓeˆŒØ#)×#=Ñ#=ˆÔ Ø$*×$>Ñ$>À&×B\ÑB\Ñ$\ˆÔ!Ø#)×#=Ñ#=ˆÔ Ø—}‘} dÑ*ˆŒØ ×+Ñ+ˆŒØ!×-Ñ-ˆÔØ'-×'EÑ'EˆÔ$Ø!'×!9Ñ!9ˆÔØˆŒÜ˜Y¨™]¨aÑ/°1Ñ4Ó5ˆŒÜ—i‘iØ×Ñ × :Ñ :¸T¿]¹]Ñ JÐQW×QfÑQfô
ˆŒô —i‘iØ×Ñ × :Ñ :¸T¿]¹]Ñ JÐQW×QfÑQfô
ˆŒô —i‘iØ×Ñ × :Ñ :¸T¿]¹]Ñ JÐQW×QfÑQfô
ˆŒô —i‘iØ×&Ñ&¨¯©Ñ6¸×8JÑ8JÐQW×QfÑQfô
ˆŒð �;‰;×"Ò" t§}¢}Ü+¨F×,?Ñ,?Ó@ˆD�Lð (5Ð"r<   r=   Úposition_embeddingsrà   Úpast_key_valueÚcache_positionrï   r>   c                 óì  — |j                   d d }g |¢d‘| j                  ‘­}| j                  |«      j                  |«      }	 | j	                  |«      j                  g |¢d‘| j                  ‘­Ž }
| j                  |«      j                  |«      j                  dd«      }| j                  r)t        |	|
|j                  |	j                  «      «      \  }	}
t        | d«      r"| j                  |	«      }	| j                  |
«      }
| j                  r±| j                  s¥t        j                  t        j                   |j#                  «       dz   | j$                  z  «      dz   «      | j&                  z  dz   }|j                  d|d   ddf«      j)                  g |¢d‘d‘­«      }|	|z  j                  |	j*                  «      }	|	j                  dd«      }	|
j                  dd«      }
|�%d|i}|j-                  |
|| j.                  |«      \  }
}t0        }| j2                  j4                  dk7  r^| j2                  j4                  dk(  r(|j7                  d	d
«      rt8        j;                  d«       nt<        | j2                  j4                     } || |	|
||f| j>                  sdn| j@                  | jB                  dœ|¤Ž\  }} |jD                  g |¢d‘­Ž jG                  «       }| jI                  |«      }||fS )Nr@   r   r(   r  ç      ð?r  ÚeagerÚsdpaÚoutput_attentionsFúã`torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to eager attention. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.ç        )râ   rá   )%r~   rÚ   r  rC   r  r  rŽ   r  rÕ   r–   rŠ   Úhasattrr  r   r2   ÚlogÚfloorrn   rÿ   rþ   r“   r—   Úupdaterû   rõ   r%   Ú_attn_implementationÚgetÚloggerÚwarning_oncer   rç   r  rá   r˜   rî   r	  )r9   r=   r  rà   r  r  rï   Úinput_shapeÚhidden_shapeÚquery_statesrð   rñ   Úattn_scalesÚcache_kwargsÚattention_interfacerô   rò   s                    r;   rJ   zLlama4TextAttention.forwardI  så  € ð $×)Ñ)¨#¨2Ð.ˆØ8˜Ð8 bÐ8¨$¯-©-Ñ8ˆà—{‘{ =Ó1×6Ñ6°|ÓDˆØ4�T—[‘[ Ó/×4Ñ4ÐU°kÐUÀ2ÐUÀtÇ}Á}ÒUˆ
Ø—{‘{ =Ó1×6Ñ6°|ÓD×NÑNÈqÐRSÓTˆà�=Š=Ü'7Ø˜jÐ*=×*@Ñ*@À×ATÑATÓ*Uó(Ñ$ˆL˜*ô �4˜Ô#ØŸ<™<¨Ó5ˆLØŸ™ jÓ1ˆJð ×'Ò'°·²ä—	‘	œ%Ÿ+™+ ~×';Ñ';Ó'=ÀÑ'CÀt×GWÑGWÑ&WÓXÐ[^Ñ^Ó_Ðbf×bqÑbqÑqÐtwÑwð ð &×*Ñ*¨A¨{¸2©ÀÀ1Ð+EÓF×MÑMÐNbÐP[ÐNbÐ]^ÐNbÐ`aÑNbÓcˆKØ(¨;Ñ6×:Ñ:¸<×;MÑ;MÓNˆLà#×-Ñ-¨a°Ó3ˆØ×)Ñ)¨!¨QÓ/ˆ
àÐ%à,¨nÐ=ˆLØ'5×'<Ñ'<¸ZÈÐW[×WeÑWeÐgsÓ'tÑ$ˆJ˜ä(?ÐØ�;‰;×+Ñ+¨wÒ6Ø�{‰{×/Ñ/°6Ò9¸f¿j¹jÐI\Ð^cÔ>dÜ×#Ñ#ðLõô
 '>¸d¿k¹k×>^Ñ>^Ñ&_Ð#Ù$7ØØØØØð	%
ð  $Ÿ}š}‘C°$×2HÑ2HØ—L‘Lñ	%
ð ñ	%
Ñ!ˆ�\ð *�k×)Ñ)Ð;¨;Ð;¸Ò;×FÑFÓHˆØ—k‘k +Ó.ˆØ˜LÐ(Ð(r<   ©NN)rK   rL   rM   Ú__doc__r    r*   r2   rN   r   r   r   Ú
LongTensorr   r   rJ   rO   rP   s   @r;   r÷   r÷   (  sÂ   ø„ ÙGðAÐ/õ AðF +/Ø59ñ?)à—|‘|ð?)ð # 5§<¡<°·±Ð#=Ñ>ð?)ð ! §¡Ñ.ð	?)ð
 ! ™ð?)ð ! ×!1Ñ!1Ñ2ð?)ð Ð-Ñ.ð?)ð 
ˆu�|‰|˜X e§l¡lÑ3°X¸eÀEÇLÁLÑ>QÑ5RÐRÑ	S÷?)r<   r÷   c                   ó¬  ‡ — e Zd Zˆ fd„Z	 	 	 	 	 	 	 	 	 ddej
                  deej
                     deej
                     deej                     deeej
                        dee	   dee	   d	ee	   d
eej                     deeej
                  ej
                  f      de
e   deej                  eeej                  ej                  f      f   fd„Zˆ xZS )ÚLlama4TextDecoderLayerc                 óÖ  •— t         ‰| �  «        |j                  | _        t        ||«      | _        t        |dz   dz  dk7  «      | _        ||j                  v | _        | j                  rt        |«      | _
        nt        ||j                  ¬«      | _
        t        |j                  |j                  ¬«      | _        t        |j                  |j                  ¬«      | _        || _        y )Nr   rú   r   )r-   rq   )r)   r*   r.   r÷   Ú	self_attnr  Úuse_chunked_attentionÚ
moe_layersÚis_moe_layerr€   Úfeed_forwardrR   Úintermediate_size_mlpru   r  Úinput_layernormÚpost_attention_layernormrû   r  s      €r;   r*   zLlama4TextDecoderLayer.__init__Œ  sÁ   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔÜ,¨V°YÓ?ˆŒÜ%(¨)°a©-¸1Ñ)<ÀÑ)AÓ%BˆÔ"Ø%¨×):Ñ):Ð:ˆÔØ×ÒÜ -¨fÓ 5ˆDÕä -¨fÈ×HdÑHdÔ eˆDÔä0°×1CÑ1CÈ×I\ÑI\Ô]ˆÔÜ(9¸&×:LÑ:LÐRX×ReÑReÔ(fˆÔ%à"ˆ�r<   r=   rà   Úchunk_causal_maskr¸   r  r  Úoutput_router_logitsÚ	use_cacher  r  rï   r>   c                 ób  — |}| j                  |«      }| j                  r|�|} | j                  d||
|||||	dœ|¤Ž\  }}||z   }|}| j                  |«      }| j	                  |«      }| j
                  r|\  }}nd }||j                  |j                  «      z   }|f}|r||fz  }|r||fz  }|S )N)r=   r  rà   r  r  r6  r  © )r2  r-  r,  r3  r0  r/  rC   r~   )r9   r=   rà   r4  r¸   r  r  r5  r6  r  r  rï   ÚresidualÚattention_statesÚself_attn_weightsr�   Úoutputss                    r;   rJ   zLlama4TextDecoderLayer.forwardœ  sÿ   € ð !ˆà×,Ñ,¨]Ó;ˆð ×%Ò%Ð*;Ð*GØ.ˆNð /=¨d¯n©nð 	/
Ø'Ø 3Ø)Ø)Ø/ØØ)ñ	/
ð ñ	/
Ñ+ÐÐ+ð !Ð#3Ñ3ˆð !ˆà×5Ñ5°mÓDˆØ×)Ñ)¨-Ó8ˆØ×ÒØ+8Ñ(ˆM™=à ˆMØ  =×#5Ñ#5°h·n±nÓ#EÑEˆØ Ð"ˆáØÐ)Ð+Ñ+ˆGáØ˜Ð'Ñ'ˆGàˆr<   )	NNNNFFFNN)rK   rL   rM   r*   r2   rN   r   r(  r   Úboolr   r   ÚFloatTensorrJ   rO   rP   s   @r;   r*  r*  ‹  s.  ø„ ô#ð& 26Ø48Ø37Ø8<Ø,1Ø/4Ø$)Ø59ØKOñ5à—|‘|ð5ð ! §¡Ñ.ð5ð $ E§L¡LÑ1ð	5ð
 ˜u×/Ñ/Ñ0ð5ð !  u§|¡|Ñ!4Ñ5ð5ð $ D™>ð5ð ' t™nð5ð ˜D‘>ð5ð ! ×!1Ñ!1Ñ2ð5ð & e¨E¯L©L¸%¿,¹,Ð,FÑ&GÑHð5ð Ð-Ñ.ð5ð 
ˆu× Ñ  (¨5°×1BÑ1BÀE×DUÑDUÐ1UÑ+VÑ"WÐWÑ	X÷5r<   r*  aK  
    This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Parameters:
        config ([`Llama4Config`]):
            Model configuration class with all the parameters of the model. Initializing with a config file does not
            load the weights associated with the model, only the configuration. Check out the
            [`~PreTrainedModel.from_pretrained`] method to load the model weights.
zTThe bare Llama4 Model outputting raw hidden-states without any specific head on top.c                   ó<   — e Zd ZeZdZdgZdZdZdZ	dZ
dZdZdZd„ Zy)ÚLlama4PreTrainedModelTÚpast_key_valuesFc                 ó‚  — t        | j                  d«      r| j                  j                  n| j                  j                  j                  }t	        |t
        j                  «      rY|j                  j                  j                  d|¬«       |j                  �%|j                  j                  j                  «        y y t	        |t
        j                  «      rf|j                  j                  j                  d|¬«       |j                  �2|j                  j                  |j                     j                  «        y y y )NÚinitializer_ranger  )ri   Ústd)r  r%   rC  Útext_configrÁ   r0   rW   rx   ÚdataÚnormal_rV   Úzero_Ú	EmbeddingÚpadding_idx)r9   rÜ   rD  s      r;   Ú_init_weightsz#Llama4PreTrainedModel._init_weightsõ  sî   € ô �t—{‘{Ð$7Ô8ð �K‰K×)Ò)à—‘×(Ñ(×:Ñ:ð 	ô
 �fœbŸi™iÔ(Ø�M‰M×Ñ×&Ñ&¨C°SÐ&Ô9Ø�{‰{Ð&Ø—‘× Ñ ×&Ñ&Õ(ð 'ä˜¤§¡Ô-Ø�M‰M×Ñ×&Ñ&¨C°SÐ&Ô9Ø×!Ñ!Ð-Ø—‘×"Ñ" 6×#5Ñ#5Ñ6×<Ñ<Õ>ð .ð .r<   N)rK   rL   rM   r   Úconfig_classÚsupports_gradient_checkpointingÚ_skip_keys_device_placementÚ_supports_flash_attn_2Ú_supports_sdpaÚ_supports_flex_attnÚ_supports_cache_classÚ_supports_quantized_cacheÚ_supports_static_cacheÚ_supports_attention_backendrK  r8  r<   r;   r@  r@  å  sF   „ ð
  €LØ&*Ð#Ø#4Ð"5ÐØ"ÐØ€NØÐØ ÐØ $ÐØ!ÐØ"&Ðó?r<   r@  a  
    Args:
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
            it.

            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

            - 1 for tokens that are **not masked**,
            - 0 for tokens that are **masked**.

            [What are attention masks?](../glossary#attention-mask)

            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            If `past_key_values` is used, optionally only the last `input_ids` have to be input (see
            `past_key_values`).

            If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
            and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
            information on the default strategy.

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.n_positions - 1]`.

            [What are position IDs?](../glossary#position-ids)
        past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
            Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
            blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
            returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.

            Two formats are allowed:
            - a [`~cache_utils.Cache`] instance, see our
            [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache);
            - Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
            shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
            cache format.

            The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
            legacy cache format will be returned.

            If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
            have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
            of shape `(batch_size, sequence_length)`.
        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
            is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
            model's internal embedding lookup matrix.
        use_cache (`bool`, *optional*):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`).
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
            Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
            this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
            the complete sequence length.
c                   ó¬  ‡ — e Zd ZdgZdZeZdefˆ fd„Zd„ Zd„ Z	 e
e«      	 	 	 	 	 	 	 	 	 	 d"dej                  deej                     d	eej                     d
ee   deej"                     dee   dee   dee   dee   deej                     dee   deeef   fd„«       Zej2                  j5                  d¬«      	 	 	 d#dej                  dej                  dej                  d
edef
d„«       Zdedededej:                  dej                  f
d„Zedej                  dededej@                  dej:                  dej                  d efd!„«       Z!ˆ xZ"S )$ÚLlama4TextModelr*  Úmodelr%   c           	      ó  •— t         ‰| �  |«       |j                  | _        |j                  | _        t        j                  |j                  |j                  | j                  «      | _        t        j                  t        |j                  «      D �cg c]  }t        ||«      ‘Œ c}«      | _        t        |j                  |j                  ¬«      | _        t#        |¬«      | _        d| _        | j)                  «        y c c}w )Nrq   )r%   F)r)   r*   Úpad_token_idrJ  Ú
vocab_sizer0   rI  r.   Úembed_tokensÚ
ModuleListÚrangeÚnum_hidden_layersr*  Úlayersru   r  Únormr¦   Ú
rotary_embÚgradient_checkpointingÚ	post_initr  s      €r;   r*   zLlama4TextModel.__init__Y  sÆ   ø€ Ü‰Ñ˜Ô Ø!×.Ñ.ˆÔØ ×+Ñ+ˆŒäŸL™L¨×):Ñ):¸F×<NÑ<NÐPT×P`ÑP`ÓaˆÔÜ—m‘mÜHMÈf×NfÑNfÓHgÖh¸9Ô# F¨IÕ6Òhó
ˆŒô & f×&8Ñ&8¸f×>QÑ>QÔRˆŒ	Ü3¸6ÔBˆŒØ&+ˆÔ#ð 	�‰Õùò is   ÂDc                 ó   — | j                   S r\   ©r\  rr   s    r;   Úget_input_embeddingsz$Llama4TextModel.get_input_embeddingsi  s   € Ø× Ñ Ð r<   c                 ó   — || _         y r\   rf  ©r9   rß   s     r;   Úset_input_embeddingsz$Llama4TextModel.set_input_embeddingsl  s
   € Ø!ˆÕr<   Ú	input_idsrà   r¸   rA  Úinputs_embedsr6  r  Úoutput_hidden_statesÚreturn_dictr  Úflash_attn_kwargsr>   c                 ó  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|	�|	n| j                   j                  }	|d u |d uz  rt        d«      ‚| j                  r%| j                  r|rt        j                  d«       d}|€>| j                  |j                  | j                  j                  j                  «      «      }|r3|€1t        | j                   |j                  d   |j                  d   «      }|
€F|�|j!                  «       nd}t#        j$                  |||j                  d   z   |j                  ¬«      }
|€|
j'                  d«      }| j)                  |||
|||¬«      \  }}|}| j+                  ||«      }|rdnd }|rdnd }| j,                  d | j                   j.                   D ]k  }|r||fz  }| j                  r2| j                  r&| j1                  |j2                  ||||||d||
|«      }n ||f|||||||
|d	œ|¤Ž}|d   }|sŒc||d   fz  }Œm | j5                  |«      }|r||fz  }t7        ||r|nd ||¬
«      }|	r|S |j9                  «       S )Nú:You must specify exactly one of input_ids or inputs_embedszX`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.Fr   r   r‰   )r6  r8  )rà   r4  r¸   r  r  r6  r  r  )Úlast_hidden_staterA  r=   Ú
attentions)r%   r  rm  r6  Úuse_return_dictÚ
ValueErrorrc  rç   r  r  r\  r–   rx   rŠ   r   r~   Úget_seq_lengthr2   r’   Ú	unsqueezeÚ_update_causal_maskrb  r`  r_  Ú_gradient_checkpointing_funcÚ__call__ra  r   Úto_tuple)r9   rk  rà   r¸   rA  rl  r6  r  rm  rn  r  ro  Úpast_seen_tokensró   r4  r=   Úfreq_cisÚall_hidden_statesÚall_self_attnsÚdecoder_layerÚlayer_outputsr{   s                         r;   rJ   zLlama4TextModel.forwardo  sö  € ð 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð "+Ð!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø%0Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆà˜Ð -°tÐ";Ò<ÜÐYÓZÐZà×&Ò&¨4¯=ª=¹YÜ×ÑØjôð ˆIàÐ Ø ×-Ñ-¨i¯l©l¸4×;LÑ;L×;SÑ;S×;ZÑ;ZÓ.[Ó\ˆMá˜Ð0Ü0°·±¸m×>QÑ>QÐRSÑ>TÐVc×ViÑViÐjkÑVlÓmˆOàÐ!ØCRÐC^˜×=Ñ=Ô?ÐdeÐÜ"Ÿ\™\Ø Ð"2°]×5HÑ5HÈÑ5KÑ"KÐTa×ThÑThôˆNð ÐØ)×3Ñ3°AÓ6ˆLà)-×)AÑ)AØ˜M¨>¸?ÐL]Ðirð *Bó *
Ñ&ˆÐ&ð &ˆð —?‘? =°,Ó?ˆñ #7™B¸DÐÙ0™°dˆà!Ÿ[™[Ð)H¨4¯;©;×+HÑ+HÐIò #	6ˆMÙ#Ø! mÐ%5Ñ5Ð!à×*Ò*¨t¯}ª}Ø $× AÑ AØ!×*Ñ*Ø!ØØ%Ø Ø#Ø%ØØØ"Øó!‘ñ !.Ø!ð!à#.Ø&7Ø!-Ø#2Ø&7Ø'Ø#1Ø(0ñ!ð (ñ!�ð *¨!Ñ,ˆMâ Ø =°Ñ#3Ð"5Ñ5‘ðG#	6ðJ Ÿ	™	 -Ó0ˆñ  Ø -Ð!1Ñ1Ðä(Ø+Ù/8™O¸dØ+Ø%ô	
ˆñ %ˆvÐ;¨&¯/©/Ó*;Ð;r<   F)Ú	recursiveÚinput_tensorc           
      ó2  — | j                   j                  dk(  r|�|dk(  j                  «       r||fS y| j                   j                  dvry|j                  d   }|j	                  | j
                  «      }| j                   j                  }	|d   }
|�|j                  «       xs |}n|�|j                  d   n|}|
|	k\  }|
|	k  |
|z   |	kD  z  }|r5t        j                  ||	|z   dz
  t        j                  ||
|z   |	«      «      n|}| j                   j                  dk(  r{t        |t        j                  «      rM|
t        |
|	z
  dz   d«      f}t        || j                   j                  |||¬	«      }t        ||||
df¬
«      }||fS t        |t        «      r||fS |j                  |j
                  }}| j!                  ||t        ||	«      ||||j                  d   ¬«      }|| j                   j                  kD  �r?t        |
|	z
  dz   d«      }||z   }| j#                  | j                   j                  |||¬«      }|d d …||…f   }|j                  d   |	k  }|r2t$        j&                  j)                  |d|	|j                  d   z
  f«      }|s|d d | d …d d …f   }n|d d |d d …f   }|j+                  |j                  d   ddd«      }||d d …d d d d …f   z  }| j                   j                  dk(  rHt        j,                  |«      j.                  }t        j                  |dk(  |d«      j	                  |«      }| j                   j                  dk(  r`|�^|j
                  j0                  dv rF|j2                  dk(  r7|s5t        j,                  |«      j.                  }t5        j6                  ||«      }| j                   j                  dk(  rG|�E|j9                  «       }|j9                  «       }t5        j:                  |||
| j<                  ¬«      rd }||fS )NÚflash_attention_2r  r&  )r  Úflex_attentionr  r   r   r@   r†  )Úoffsets)Úquery_lengthÚ
key_lengthr‡  )Úsequence_lengthÚtarget_lengthr—   rŠ   r  Ú
batch_size)ÚstartÚendrŠ   r  r  )ÚcudaÚxpurú   )rl  Úpast_key_values_lengthÚis_training)r%   r  Úanyr~   r–   rŠ   Úattention_chunk_sizeÚget_max_cache_shaper2   ÚwhererÁ   rN   r·   r"   r!   r—   Ú5_prepare_4d_causal_attention_mask_with_cache_positionÚcreate_chunked_attention_maskr0   rì   Úpadr“   ÚfinfoÚminrÀ   Úndimr   Ú_unmask_unattendedr=  Ú_ignore_causal_mask_sdparç   )r9   rà   rƒ  r  rA  r  Úchunked_attention_maskr6  rŠ  r”  Úfirst_cache_positionÚfull_cache_lengthÚcond1Úcond2r‰  r‡  r—   rŠ   ró   Ú	start_idxÚend_idxÚlocal_attention_maskÚrequires_paddingÚ	min_dtypes                           r;   rx  z#Llama4TextModel._update_causal_maskÝ  s‡  € ð �;‰;×+Ñ+Ð/BÒBØÐ)¨~ÀÑ/D×.IÑ.IÔ.KØ% ~Ð5Ð5Øà�;‰;×+Ñ+Ð3VÑVØà&×,Ñ,¨QÑ/ˆØ'×*Ñ*¨4¯;©;Ó7ˆØ#Ÿ{™{×?Ñ?Ðà-¨aÑ0ÐàÐ&Ø /× CÑ CÓ EÒ XÈÑà<JÐ<V × 4Ñ 4°RÒ 8Ð\kÐà$Ð(<Ñ<ˆØ%Ð(<Ñ<Ø  ?Ñ2Ð5IÑIñ
ˆñ ô �K‰KØØ$ Ñ6¸Ñ:Ü—‘˜EÐ#7¸/Ñ#IÐK_Ó`ôð #ð 	ð �;‰;×+Ñ+Ð/?Ò?Ü˜.¬%¯,©,Ô7Ø/´Ð5IÐL`Ñ5`ÐcdÑ5dÐfgÓ1hÐi�Ü)DØ" D§K¡K×$DÑ$DÀoÐWaÐkrô*Ð&ô "=Ø"Ø!0Ø0Ø1°1Ð5ô	"�ð &Ð'=Ð=Ð=Ü˜.¬)Ô4Ø%Ð'=Ð=Ð=ð %×*Ñ*¨L×,?Ñ,?ˆvˆØ×PÑPØØ+ÜÐ/Ð1EÓFØØØ)Ø#×)Ñ)¨!Ñ,ð Qó 
ˆð ˜tŸ{™{×?Ñ?Ó?ÜÐ0Ð3GÑGÈ!ÑKÈQÓOˆIØ *Ñ,ˆGØ%)×%GÑ%GØ—‘×0Ñ0ØØØð	 &Hó &Ð"ð $2²!°Y¸wÐ5FÐ2FÑ#GÐ à3×9Ñ9¸"Ñ=Ð@TÑTÐÙÜ')§}¡}×'8Ñ'8Ø(¨1Ð.BÐEY×E_ÑE_Ð`bÑEcÑ.cÐ*dó(Ð$ñ $Ø)?ÀÀdÈ_ÐL\ÑL]Ò_`Ð@`Ñ)aÑ&à)?ÀÀdÈNÒ\]Ð@]Ñ)^Ð&à%;×%BÑ%BÀ<×CUÑCUÐVWÑCXÐZ\Ð^`ÐbdÓ%eÐ"Ø%;Ð>RÒSTÐVZÐ\`ÒbcÐScÑ>dÑ%dÐ"Ø�{‰{×/Ñ/°7Ò:Ü!ŸK™K¨Ó.×2Ñ2�	Ü).¯©Ð5KÈqÑ5PÐR[Ð]`Ó)a×)dÑ)dÐejÓ)kÐ&ð �K‰K×,Ñ,°Ò6ØÐ*Ø×%Ñ%×*Ñ*¨oÑ=Ø×#Ñ# qÒ(Ù%ô
 Ÿ™ EÓ*×.Ñ.ˆIÜ0×CÑCÀKÐQZÓ[ˆKð �;‰;×+Ñ+¨vÒ5Ð:PÐ:\Ø%;×%@Ñ%@Ó%BÐ"Ø%×*Ñ*Ó,ˆKÜ%×>Ñ>ØØ*Ø';Ø ŸM™Mõ	ð #�ØÐ2Ð2Ð2r<   r”  r�  rŽ  rŠ   c                 ó(  — t        j                  |||¬«      }t        j                  |j                  d«      |z  |j                  d«      |z  z
  «      }|j                  d«      |j                  d«      z
  }|dk(  |dk  z  }|j	                  |«      S )uâ  
        Generate the following:

        'What'      :  0 â–  â¬š â¬š â¬š â¬š â¬š    |
        'â–�is'       :  1 â–  â–  â¬š â¬š â¬š â¬š     |
        'â–�ch'       :  2 â–  â–  â–  â¬š â¬š â¬š     |
        'unked'     :  3 â¬š â¬š â¬š â–  â¬š â¬š    |
        'â–�attention':  4 â¬š â¬š â¬š â–  â–  â¬š    |
        '?'         :  5 â¬š â¬š â¬š â–  â–  â–      |

        If the chunk size is 3.
        This can just be appplied over the already created attention mask
        r‰   r   r   )r2   r’   Úabsrw  r–   )	r9   r”  r�  rŽ  rŠ   Úarange_vectorÚ	block_posÚ	token_posÚmasks	            r;   r˜  z-Llama4TextModel.create_chunked_attention_mask[  s‘   € ô  Ÿ™ U¨C¸Ô?ˆÜ—I‘IØ×#Ñ# AÓ&Ð*>Ñ>À×AXÑAXÐYZÓA[Ð_sÑAsÑsó
ˆ	ð "×+Ñ+¨AÓ.°×1HÑ1HÈÓ1KÑKˆ	Ø˜Q‘ 9°¡>Ñ2ˆØ�w‰w�v‹Ðr<   rŠ  r‹  r—   rŒ  c                 ó¢  — | �| j                  «       dk(  r| }|S t        j                  |«      j                  }	t        j                  ||f|	||¬«      }|dk7  rt        j
                  |d¬«      }|t        j                  ||¬«      |j                  |«      j                  dd«      kD  z  }|dddd…dd…f   j                  |ddd«      }| �‚|j                  «       }| j                  d   }
|dd…dd…dd…d|
…f   | dd…dddd…f   j                  |«      z   }|dk(  }|dd…dd…dd…d|
…f   j                  ||	«      |dd…dd…dd…d|
…f<   |S )	a°  
        Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
        `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.

        Args:
            attention_mask (`torch.Tensor`):
                A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
                `(batch_size, 1, query_length, key_value_length)`.
            sequence_length (`int`):
                The sequence length being processed.
            target_length (`int`):
                The target length: when generating with static cache, the mask should be as long as the static cache,
                to account for the 0 padding, the part of the cache that is not filled yet.
            dtype (`torch.dtype`):
                The dtype to use for the 4D attention mask.
            device (`torch.device`):
                The device to plcae the 4D attention mask on.
            cache_position (`torch.Tensor`):
                Indices depicting the position of the input sequence tokens in the sequence.
            batch_size (`torch.Tensor`):
                Batch size.
        Nrú   ©Ú
fill_valuer—   rŠ   r   ©Údiagonalr‰   r@   r   )rB   r2   rš  r›  ÚfullÚtriur’   r–   r˜   r“   Úcloner~   Úmasked_fill©rà   rŠ  r‹  r—   rŠ   r  rŒ  rï   ró   r¨  Úmask_lengthÚpadding_masks               r;   r—  zELlama4TextModel._prepare_4d_causal_attention_mask_with_cache_positions  sx  € ðB Ð%¨.×*<Ñ*<Ó*>À!Ò*Cà(ˆKð& Ðô# Ÿ™ EÓ*×.Ñ.ˆIÜŸ*™*Ø  -Ð0¸YÈeÐ\bôˆKð  !Ò#Ü#Ÿj™j¨¸qÔA�Øœ5Ÿ<™<¨¸fÔEÈ×HYÑHYÐZ`ÓHa×HiÑHiÐjlÐnoÓHpÑpÑpˆKØ% d¨D²!²QÐ&6Ñ7×>Ñ>¸zÈ1ÈbÐRTÓUˆKØÐ)Ø)×/Ñ/Ó1�Ø,×2Ñ2°2Ñ6�Ø*ª1ªa²°L°[°LÐ+@ÑAÀNÒSTÐVZÐ\`ÒbcÐScÑDd×DgÑDgÐhnÓDoÑo�Ø+¨qÑ0�Ø5@ÂÂAÂqÈ,È;È,ÐAVÑ5W×5cÑ5cØ  )ó6�šAšq¢! \ k \Ð1Ñ2ð Ðr<   )
NNNNNNNNNN)FNT)#rK   rL   rM   Ú_no_split_modulesÚbase_model_prefixr    rL  r*   rg  rj  r   ÚLLAMA4_INPUTS_DOCSTRINGr2   r(  r   rN   r   r>  r=  r   r   r   r   r   rJ   ÚcompilerÚdisablerx  r  rŠ   r˜  Ústaticmethodr—   r—  rO   rP   s   @r;   rW  rW  P  sU  ø„ ð
 2Ð2ÐØÐØ#€LðÐ/õ ò !ò"ñ +Ð+BÓCð '+Ø15Ø37Ø+/Ø59Ø$(Ø,0Ø/3Ø&*Ø59ñk<à×#Ñ#ðk<ð ! §¡Ñ.ðk<ð ˜u×/Ñ/Ñ0ð	k<ð
 " %™ðk<ð   × 1Ñ 1Ñ2ðk<ð ˜D‘>ðk<ð $ D™>ðk<ð ' t™nðk<ð ˜d‘^ðk<ð ! ×!1Ñ!1Ñ2ðk<ð $Ð$8Ñ9ðk<ð 
ˆuÐ-Ð-Ñ	.òk<ó Dðk<ðZ ‡^�^×Ñ eÐÓ,ð #(Ø#Øñ{3àŸ™ð{3ð —l‘lð{3ð Ÿ™ð	{3ð
 ð{3ð  ò{3ó -ð{3ðzØ$'ðØ03ðØ:=ðØGLÇ|Á|ðà	�‰óð0 ð5ØŸ™ð5àð5ð ð5ð �{‰{ð	5ð
 —‘ð5ð Ÿ™ð5ð ò5ó ô5r<   rW  c                   óä  ‡ — e Zd ZdZdgZddiZeZdefˆ fd„Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Z ee«       eee¬«      	 	 	 	 	 	 	 	 	 	 	 	 ddej*                  deej.                     deej*                     deeeeej6                     f      deej6                     deej*                     dee   dee   dee   dee   deej*                     deeej.                  f   deeef   fd„«       «       Zˆ xZ S )ÚLlama4ForCausalLMÚlanguage_modelzlm_head.weightÚlm_headÚcolwise_repr%   c                 óè   •— t         ‰| �  |«       t        |«      | _        |j                  | _        t        j                  |j                  |j                  d¬«      | _        | j                  «        y rT   )
r)   r*   rW  rX  r[  r0   rW   r.   rÄ  rd  r8   s     €r;   r*   zLlama4ForCausalLM.__init__²  sU   ø€ Ü‰Ñ˜Ô Ü$ VÓ,ˆŒ
Ø ×+Ñ+ˆŒÜ—y‘y ×!3Ñ!3°V×5FÑ5FÈUÔSˆŒð 	�‰Õr<   c                 ó.   — | j                   j                  S r\   ©rX  r\  rr   s    r;   rg  z&Llama4ForCausalLM.get_input_embeddings»  s   € Ø�z‰z×&Ñ&Ð&r<   c                 ó&   — || j                   _        y r\   rÈ  ri  s     r;   rj  z&Llama4ForCausalLM.set_input_embeddings¾  s   € Ø"'ˆ�
‰
Õr<   c                 ó   — | j                   S r\   ©rÄ  rr   s    r;   Úget_output_embeddingsz'Llama4ForCausalLM.get_output_embeddingsÁ  s   € Ø�|‰|Ðr<   c                 ó   — || _         y r\   rË  ©r9   Únew_embeddingss     r;   Úset_output_embeddingsz'Llama4ForCausalLM.set_output_embeddingsÄ  s	   € Ø%ˆ�r<   c                 ó   — || _         y r\   ©rX  ©r9   Údecoders     r;   Úset_decoderzLlama4ForCausalLM.set_decoderÇ  s	   € Øˆ�
r<   c                 ó   — | j                   S r\   rÒ  rr   s    r;   Úget_decoderzLlama4ForCausalLM.get_decoderÊ  s   € Ø�z‰zÐr<   ©Úoutput_typerL  rk  rà   r¸   rA  rl  Úlabelsr6  r  rm  rn  r  Úlogits_to_keepr>   c                 ó8  — |�|n| j                   j                  }|	�|	n| j                   j                  }	|
�|
n| j                   j                  }
 | j                  d||||||||	|
|dœ
|¤Ž}|d   }t        |t        «      rt        | d«      n|}| j                  |dd…|dd…f   «      }d}|�* | j                  d||| j                   j                  dœ|¤Ž}|
s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  |j                  ¬«      S )a>  
        Args:
            labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
                Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
                config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
                (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.

            logits_to_keep (`int` or `torch.Tensor`, *optional*):
                If an `int`, compute logits for the last `logits_to_keep` tokens. If `0`, calculate logits for all
                `input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
                token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
                If a `torch.Tensor`, must be 1D corresponding to the indices to keep in the sequence length dimension.
                This is useful when using packed tensor format (single dimension for batch and sequence length).

        Returns:

        Example:

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

        >>> model = Llama4ForCausalLM.from_pretrained("meta-llama4/Llama4-2-7b-hf")
        >>> tokenizer = AutoTokenizer.from_pretrained("meta-llama4/Llama4-2-7b-hf")

        >>> prompt = "Hey, are you conscious? Can you talk to me?"
        >>> 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]
        "Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
        ```N)
rk  rà   r¸   rA  rl  r6  r  rm  rn  r  r   )ÚlogitsrÚ  r[  r   )ÚlossrÝ  rA  r=   rs  r8  )r%   r  rm  rt  rX  rÁ   r  ÚslicerÄ  Úloss_functionr[  r   rA  r=   rs  )r9   rk  rà   r¸   rA  rl  rÚ  r6  r  rm  rn  r  rÛ  rï   r<  r=   Úslice_indicesrÝ  rÞ  r{   s                       r;   rJ   zLlama4ForCausalLM.forwardÍ  s`  € ðd 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð �$—*‘*ð 
ØØ)Ø%Ø+Ø'ØØ/Ø!5Ø#Ø)ñ
ð ñ
ˆð   ™
ˆä8BÀ>ÔSVÔ8Wœ˜~˜o¨tÔ4Ð]kˆØ—‘˜mªA¨}ºaÐ,?Ñ@ÓAˆØˆØÐØ%�4×%Ñ%Ðp¨V¸FÈtÏ{É{×OeÑOeÑpÐioÑpˆDáØ�Y ¨¨ Ñ,ˆFØ'+Ð'7�D�7˜VÑ#ÐC¸VÐCä%ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)ô
ð 	
r<   )NNNNNNNNNNNr   )!rK   rL   rM   r¼  Ú_tied_weights_keysÚ_tp_planr    rL  r*   rg  rj  rÌ  rÐ  rÕ  r×  r   r½  r   r   Ú_CONFIG_FOR_DOCr2   r(  r   rN   r   r   r   r>  r=  r  r   rJ   rO   rP   s   @r;   rÂ  rÂ  ¬  s¬  ø„ Ø(ÐØ*Ð+ÐØ˜=Ð)€HØ#€LðÐ/õ ò'ò(òò&òòñ +Ð+BÓCÙÐ+AÐP_Ô`ð '+Ø15Ø37ØKOØ59Ø-1Ø$(Ø,0Ø/3Ø&*Ø59Ø34ñW
à×#Ñ#ðW
ð ! §¡Ñ.ðW
ð ˜u×/Ñ/Ñ0ð	W
ð
 " %¨¨t°E×4EÑ4EÑ/FÐ(FÑ"GÑHðW
ð   × 1Ñ 1Ñ2ðW
ð ˜×)Ñ)Ñ*ðW
ð ˜D‘>ðW
ð $ D™>ðW
ð ' t™nðW
ð ˜d‘^ðW
ð ! ×!1Ñ!1Ñ2ðW
ð ˜c 5§<¡<Ð/Ñ0ðW
ð 
ˆuÐ,Ð,Ñ	-òW
ó aó DôW
r<   rÂ  c                   ó  — e Zd ZU dZdZeej                     ed<   dZ	ej                  ed<   dZ
eeej                        ed<   dZeeej                        ed<   dZeeej                        ed<   dZeej                     ed<   y)	ÚLlama4CausalLMOutputWithPastaœ  
    Base class for Llava causal language model (or autoregressive) outputs.

    Args:
        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.vocab_size)`):
            Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
        past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
            Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
            `(batch_size, num_heads, sequence_length, embed_size_per_head)`)

            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.
        hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
            Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
            one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.

            Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
        attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
            Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
            sequence_length)`.

            Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
            heads.
        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.
    NrÞ  rÝ  rA  r=   rs  Úimage_hidden_states)rK   rL   rM   r'  rÞ  r   r2   r>  Ú__annotations__rÝ  rA  r   r=   r   rs  rç  r8  r<   r;   ræ  ræ  )  s’   … ñð< )-€Dˆ(�5×$Ñ$Ñ
%Ó,Ø $€FˆE×ÑÓ$Ø9=€O�X˜d 5×#4Ñ#4Ñ5Ñ6Ó=Ø8<€M�8˜E %×"3Ñ"3Ñ4Ñ5Ó<Ø59€J�˜˜u×0Ñ0Ñ1Ñ2Ó9Ø7;Ð˜ %×"3Ñ"3Ñ4Ô;r<   ræ  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLlama4VisionMLP2c                 ó~  •— t         ‰| �  «        |j                  | _        |j                  | _        t	        j
                  | j                  |j                  d¬«      | _        t	        j
                  |j                  |j                  d¬«      | _	        t	        j                  «       | _        |j                  | _        y rT   )r)   r*   r.   r-   r0   rW   Úprojector_input_dimÚfc1Úprojector_output_dimÚfc2ÚGELUrZ   Úprojector_dropoutrâ   r8   s     €r;   r*   zLlama4VisionMLP2.__init__R  s‡   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔØ!'×!9Ñ!9ˆÔÜ—9‘9˜T×3Ñ3°V×5OÑ5OÐV[Ô\ˆŒÜ—9‘9˜V×8Ñ8¸&×:UÑ:UÐ\aÔbˆŒÜŸW™W›YˆÔØ×/Ñ/ˆ�r<   c                 óÞ   — | j                  |«      }| j                  |«      }t        j                  || j                  | j                  ¬«      }| j                  | j                  |«      «      S )Nrå   )rí  rZ   ÚFrâ   rç   rï  ©r9   r=   s     r;   rJ   zLlama4VisionMLP2.forward[  sT   € ØŸ™ Ó/ˆØ×*Ñ*¨=Ó9ˆÜŸ	™	 -°4·<±<È$Ï-É-ÔXˆØ×!Ñ! $§(¡(¨=Ó"9Ó:Ð:r<   r^   rP   s   @r;   rê  rê  Q  s   ø„ ô0ö;r<   rê  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLlama4MultiModalProjectorc                 ó¬   •— t         ‰| �  «        t        j                  |j                  j
                  |j                  j                  d¬«      | _        y rT   )	r)   r*   r0   rW   Úvision_configÚvision_output_dimrE  r.   Úlinear_1r8   s     €r;   r*   z"Llama4MultiModalProjector.__init__c  s?   ø€ Ü‰ÑÔÜŸ	™	Ø× Ñ ×2Ñ2Ø×Ñ×*Ñ*Øô
ˆ�r<   c                 ó(   — | j                  |«      }|S r\   )rú  )r9   Úimage_featuresr=   s      r;   rJ   z!Llama4MultiModalProjector.forwardk  s   € ØŸ™ nÓ5ˆØÐr<   r^   rP   s   @r;   rö  rö  b  s   ø„ ô
ör<   rö  c           
      óJ  — | j                   \  }}}t        t        j                  |«      «      }| j	                  |||d«      } | j                  «       \  }}}}| j	                  ||t        ||z  «      t        ||z  «      «      }|j                  dddd«      j                  «       }|j	                  |t        ||z  «      t        ||z  «      t        ||dz  z  «      «      }|j                  dddd«      j                  «       }|j	                  |d|j                   d   «      }	|	S )Nr@   r   r(   r   r
   )r~   r  rê   rë   rC   r”   Úpermuterî   )
rƒ  Úshuffle_ratiorŒ  Únum_patchesÚchannelsÚ
patch_sizeÚheightÚwidthÚreshaped_tensorÚoutput_tensors
             r;   Úpixel_shuffler  p  s%  € à(4×(:Ñ(:Ñ%€J�˜XÜ”T—Y‘Y˜{Ó+Ó,€Jà×$Ñ$ Z°¸ZÈÓL€LØ*6×*;Ñ*;Ó*=Ñ'€J�˜˜xà"×'Ñ'¨
°F¼CÀÈÑ@UÓ<VÔX[Ð\dÐgtÑ\tÓXuÓv€OØ%×-Ñ-¨a°°A°qÓ9×DÑDÓF€Oà%×*Ñ*Ø”C˜ Ñ.Ó/´°U¸]Ñ5JÓ1KÌSÐQYÐ]jÐlmÑ]mÑQnÓMoó€Oð &×-Ñ-¨a°°A°qÓ9×DÑDÓF€Oà#×(Ñ(¨°R¸×9NÑ9NÈrÑ9RÓS€MØÐr<   c                   óV   ‡ — e Zd Zˆ fd„Zdej
                  dej
                  fd„Zˆ xZS )ÚLlama4VisionPixelShuffleMLPc                 óÚ   •— t         ‰| �  «        |j                  | _        t        |j                  | j                  dz  z  «      | _        |j                  | _        t        |«      | _	        y r'   )
r)   r*   Úpixel_shuffle_ratior  rì  Ú	inner_dimrî  Ú
output_dimrê  Úmlpr8   s     €r;   r*   z$Llama4VisionPixelShuffleMLP.__init__…  sX   ø€ Ü‰ÑÔØ#)×#=Ñ#=ˆÔ Ü˜V×7Ñ7¸D×<TÑ<TÐVWÑ<WÑXÓYˆŒØ ×5Ñ5ˆŒÜ# FÓ+ˆ�r<   Úencoded_patchesr>   c                 óP   — t        || j                  «      }| j                  |«      S r\   )r  r  r  )r9   r  s     r;   rJ   z#Llama4VisionPixelShuffleMLP.forwardŒ  s#   € Ü'¨¸×9QÑ9QÓRˆØ�x‰x˜Ó(Ð(r<   ©rK   rL   rM   r*   r2   rN   rJ   rO   rP   s   @r;   r	  r	  „  s#   ø„ ô,ð) u§|¡|ð )¸¿¹÷ )r<   r	  ac  
    This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Parameters:
        config ([`LlavaConfig`] or [`LlavaVisionConfig`]):
            Model configuration class with all the parameters of the model. Initializing with a config file does not
            load the weights associated with the model, only the configuration. Check out the
            [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Úfreqs_cic                 ó°   — |j                   }t        |j                  «      D ��cg c]  \  }}|dk(  s||dz
  k(  r|nd‘Œ }}} | j                  |Ž S c c}}w )Nr   )rœ  Ú	enumerater~   rC   )r  rÝ   rœ  ÚiÚdr~   s         r;   Úreshape_for_broadcastr  £  sW   € Ø�:‰:€DÜ=FÀuÇ{Á{Ó=S×T±T°Q¸�!�q’&˜A ¨¡šM‰Q¨qÑ0ÐT€EÑTØˆ8�=‰=˜%Ð Ð ùó Us   ¥Ac                 óB  — t        j                   | j                  «       j                  g | j                  d d ¢d‘d‘­Ž «      }t        j                   |j                  «       j                  g |j                  d d ¢d‘d‘­Ž «      }t        ||¬«      }|j                  |j                  «      }t        j                  ||z  «      j                  d«      }t        j                  ||z  «      j                  d«      }|j                  | «      |j                  |«      fS )Nr@   r(   )r  rÝ   r
   )r2   rÎ   rn   r˜   r~   r  r–   rŠ   rÏ   rÐ   ro   )rÝ   rÞ   r  Úquery_Úkey_Ú	query_outÚkey_outs          r;   Úvision_apply_rotary_embr  ©  sø   € ô
 ×"Ñ"Ð#8 5§;¡;£=×#8Ñ#8Ð#R¸%¿+¹+ÀcÀrÐ:JÐ#RÈBÐ#RÐPQÒ#RÓS€FÜ× Ñ Ð!4 §¡£×!4Ñ!4Ð!L°c·i±iÀÀ°nÐ!LÀbÐ!LÈ!Ò!LÓM€DÜ$¨h¸fÔE€HØ�{‰{˜6Ÿ=™=Ó)€HÜ×"Ñ" 6¨HÑ#4Ó5×=Ñ=¸aÓ@€IÜ× Ñ  ¨¡Ó1×9Ñ9¸!Ó<€GØ×Ñ˜UÓ# W§_¡_°SÓ%9Ð9Ð9r<   c                   óò   ‡ — e Zd Zdefˆ fd„Z	 	 d
dej                  dej                  deej                     dee   de	e
   deej                  eej                     eeej                        f   fd	„Zˆ xZS )ÚLlama4VisionAttentionr%   c                 óÐ  •— t         ‰| �  «        || _        |j                  | _        |j
                  | _        |j                  |j
                  z  | _        d| _        |j                  | _	        t        j                  | j                  | j                  | j                  z  d¬«      | _        t        j                  | j                  | j                  | j                  z  d¬«      | _        t        j                  | j                  | j                  | j                  z  d¬«      | _        t        j                  | j                  | j                  z  | j                  d¬«      | _        y )Nr   TrU   )r)   r*   r%   r.   Ú	embed_dimrý   Ú	num_headsrÚ   rè   r  r0   rW   r  r  r  r	  r8   s     €r;   r*   zLlama4VisionAttention.__init__¸  sõ   ø€ Ü‰ÑÔØˆŒØ×+Ñ+ˆŒØ×3Ñ3ˆŒØ×*Ñ*¨f×.HÑ.HÑHˆŒØ$%ˆÔ!Ø!'×!9Ñ!9ˆÔä—i‘i §¡°·±ÀÇÁÑ0NÐUYÔZˆŒÜ—i‘i §¡°·±ÀÇÁÑ0NÐUYÔZˆŒÜ—i‘i §¡°·±ÀÇÁÑ0NÐUYÔZˆŒÜ—i‘i §¡°·±Ñ >ÀÇÁÐUYÔZˆ�r<   r=   r  rà   r  rï   r>   c                 óR  — |j                   d d }g |¢d‘| j                  ‘­}| j                  |«      j                  |«      }| j	                  |«      j                  |«      }	| j                  |«      j                  |«      }
t        ||	|¬«      \  }}	|j                  dd«      }|	j                  dd«      }	|
j                  dd«      }
t        }| j                  j                  dvr^| j                  j                  dk(  r(|j                  dd«      rt        j                  d	«       nt        | j                  j                     } || ||	|
d f| j                  sd
n| j                   d ddœ|¤Ž\  }} |j"                  g |¢d‘­Ž j%                  «       }| j'                  |«      }||fS )Nr@   )r  r   r(   )r  r†  r  r  Fr  r  )râ   rá   r  )r~   rÚ   r  rC   r  r  r  rŽ   rõ   r%   r  r  r  r  r   rç   r  r˜   rî   r	  )r9   r=   r  rà   r  rï   r   r!  r"  rð   rñ   r%  rô   rò   s                 r;   rJ   zLlama4VisionAttention.forwardÆ  s¬  € ð $×)Ñ)¨#¨2Ð.ˆØ8˜Ð8 bÐ8¨$¯-©-Ñ8ˆà—{‘{ =Ó1×6Ñ6°|ÓDˆØ—[‘[ Ó/×4Ñ4°\ÓBˆ
Ø—{‘{ =Ó1×6Ñ6°|ÓDˆä#:¸<ÈÐ^fÔ#gÑ ˆ�jà#×-Ñ-¨a°Ó3ˆØ×)Ñ)¨!¨QÓ/ˆ
Ø#×-Ñ-¨a°Ó3ˆä(?Ðà�;‰;×+Ñ+Ð3NÑNØ�{‰{×/Ñ/°6Ò9¸f¿j¹jÐI\Ð^cÔ>dÜ×#Ñ#ðLõô
 '>¸d¿k¹k×>^Ñ>^Ñ&_Ð#á$7ØØØØØð
%
ð  $Ÿ}š}‘C°$×2HÑ2HØØñ
%
ð ñ
%
Ñ!ˆ�\ð *�k×)Ñ)Ð;¨;Ð;¸Ò;×FÑFÓHˆØ—k‘k +Ó.ˆØ˜LÐ(Ð(r<   r&  )rK   rL   rM   r	   r*   r2   rN   r   r   r   r   r   rJ   rO   rP   s   @r;   r  r  ·  s›   ø„ ð[Ð1õ [ð$ 26Ø*.ñ.)à—|‘|ð.)ð —,‘,ð.)ð ! §¡Ñ.ð	.)ð
 ! ™ð.)ð Ð-Ñ.ð.)ð 
ˆu�|‰|˜X e§l¡lÑ3°X¸eÀEÇLÁLÑ>QÑ5RÐRÑ	S÷.)r<   r  c                   óV   ‡ — e Zd Zˆ fd„Zdej
                  dej
                  fd„Zˆ xZS )ÚLlama4VisionMLPc                 ó&  •— t         ‰| �  «        || _        t        j                  «       | _        t        j                  |j                  |j                  d¬«      | _	        t        j                  |j                  |j                  d¬«      | _
        y )NTrU   )r)   r*   r%   r0   rð  rZ   rW   r.   r-   rí  rï  r8   s     €r;   r*   zLlama4VisionMLP.__init__ø  se   ø€ Ü‰ÑÔØˆŒÜŸW™W›YˆÔÜ—9‘9˜V×/Ñ/°×1IÑ1IÐPTÔUˆŒÜ—9‘9˜V×5Ñ5°v×7IÑ7IÐPTÔUˆ�r<   r=   r>   c                 ól   — | j                  |«      }| j                  |«      }| j                  |«      }|S r\   )rí  rZ   rï  rô  s     r;   rJ   zLlama4VisionMLP.forwardÿ  s4   € ØŸ™ Ó/ˆØ×*Ñ*¨=Ó9ˆØŸ™ Ó/ˆØÐr<   r  rP   s   @r;   r%  r%  ÷  s$   ø„ ôVð U§\¡\ð °e·l±l÷ r<   r%  c            	       ó„   ‡ — e Zd Zdefˆ fd„Z	 	 ddej                  dej                  deej                     defd„Z	ˆ xZ
S )	ÚLlama4VisionEncoderLayerr%   c                 ó  •— t         ‰| �  «        |j                  | _        t        |«      | _        t        |«      | _        t        j                  |j                  «      | _	        t        j                  |j                  «      | _
        y r\   )r)   r*   r.   r  r,  r%  r  r0   Ú	LayerNormr2  r3  r8   s     €r;   r*   z!Llama4VisionEncoderLayer.__init__  sb   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔä.¨vÓ6ˆŒÜ" 6Ó*ˆŒä!Ÿ|™|¨F×,>Ñ,>Ó?ˆÔÜ(*¯©°V×5GÑ5GÓ(HˆÕ%r<   Úhidden_stater  rà   r  c                 óÌ   — |}| j                  |«      }| j                  |||¬«      \  }}||z   }|}| j                  |«      }| j                  |«      }||z   }|f}|r||fz  }|S )N)r  rà   )r2  r,  r3  r  )r9   r,  r  rà   r  r9  rò   r<  s           r;   rJ   z Llama4VisionEncoderLayer.forward  s�   € ð  ˆà×+Ñ+¨LÓ9ˆà%)§^¡^ØØØ)ð &4ó &
Ñ"ˆ�lð
   ,Ñ.ˆð  ˆØ×4Ñ4°\ÓBˆØ—x‘x Ó-ˆØ ,Ñ.ˆà�/ˆáØ˜�Ñ&ˆGàˆr<   r&  )rK   rL   rM   r	   r*   r2   rN   r   r=  rJ   rO   rP   s   @r;   r)  r)    sV   ø„ ðIÐ1õ Ið 26Ø"&ñà—l‘lðð —,‘,ðð ! §¡Ñ.ð	ð
  ÷r<   r)  c                   ó´   ‡ — e Zd ZdZdefˆ fd„Z	 	 	 	 ddej                  dej                  deej                     dee	   dee	   d	ee	   d
e
eef   fd„Zˆ xZS )ÚLlama4VisionEncoderz½
    Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
    [`Llama4VisionEncoderLayer`].

    Args:
        config: Llama4VisionConfig
    r%   c                 óÞ   •— t         ‰| �  «        || _        t        j                  t        |j                  «      D �cg c]  }t        |«      ‘Œ c}«      | _        d| _	        || _        y c c}w )NF)
r)   r*   r%   r0   r]  r^  r_  r)  r`  rc  )r9   r%   Ú_r:   s      €r;   r*   zLlama4VisionEncoder.__init__;  sW   ø€ Ü‰ÑÔØˆŒÜ—m‘mÌuÐU[×UmÑUmÓOnÖ$oÈ!Ô%=¸fÕ%EÒ$oÓpˆŒØ&+ˆÔ#Øˆ�ùò %ps   ½A*r=   r  rà   r  rm  rn  r>   c                 óê  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|rdnd}|rdnd}| j                  D ]^  }	|r||fz   }| j
                  r,| j                  r | j                  |	j                  ||||«      }
n |	||||¬«      }
|r	||
d   fz   }|
d   }Œ` |r||fz   }|st        d„ |||fD «       «      S t        |||¬«      S )ad  
        Args:
            inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
                Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation.
                This is useful if you want more control over how to convert `input_ids` indices into associated vectors
                than the model's internal embedding lookup matrix.
            attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
                Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

                - 1 for tokens that are **not masked**,
                - 0 for tokens that are **masked**.

                [What are attention masks?](../glossary#attention-mask)
            output_attentions (`bool`, *optional*):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
            output_hidden_states (`bool`, *optional*):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more detail.
            return_dict (`bool`, *optional*):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        Nr8  )r,  rà   r  r  r   r   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wr\   r8  ©Ú.0Úvs     r;   ú	<genexpr>z.Llama4VisionEncoder.forward.<locals>.<genexpr>†  s   è ø€ Òe˜qÐWXÑWdœÑeùó   ‚Š©rr  r=   rs  )r%   r  rm  rt  r`  rc  rç   ry  rz  r}   r   )r9   r=   r  rà   r  rm  rn  Úencoder_statesÚall_attentionsÚencoder_layerr�  s              r;   rJ   zLlama4VisionEncoder.forwardB  s6  € ð> 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆá3™¸ˆÙ0™°dˆà!Ÿ[™[ò 	-ˆMÙ#Ø!/°=Ð2BÑ!B�Ø×*Ò*¨t¯}ª}Ø $× AÑ AØ!×*Ñ*Ø!ØØ"Ø%ó!‘ñ !.Ø!.Ø#1Ø&7Ø%ô	!�ñ !Ø!/°=ÀÑ3CÐ2EÑ!E�à)¨!Ñ,‰Mð-	-ñ0  Ø+¨}Ð.>Ñ>ˆNáÜÑe ]°NÀNÐ$SÔeÓeÐeÜØ+¸>ÐVdô
ð 	
r<   ©NNNN)rK   rL   rM   r'  r	   r*   r2   rN   r   r=  r   r   r   rJ   rO   rP   s   @r;   r/  r/  2  s›   ø„ ñðÐ1õ ð 26Ø,0Ø/3Ø&*ñG
à—|‘|ðG
ð —,‘,ðG
ð ! §¡Ñ.ð	G
ð
 $ D™>ðG
ð ' t™nðG
ð ˜d‘^ðG
ð 
ˆu�oÐ%Ñ	&÷G
r<   r/  c                   óV   ‡ — e Zd Zˆ fd„Zdej
                  dej
                  fd„Zˆ xZS )ÚLlama4UnfoldConvolutionc                 ó<  •— t         ‰| �  «        |j                  }t        |t        «      r||f}t
        j                  j                  ||j                  ¬«      | _        t        j                  |j                  |d   z  |d   z  |j                  d¬«      | _        y )N)Úkernel_sizeÚstrider   r   FrU   )r)   r*   r  rÁ   r  r2   r0   ÚUnfoldÚunfoldrW   Únum_channelsr.   Úlinear)r9   r%   rA  r:   s      €r;   r*   z Llama4UnfoldConvolution.__init__�  s‚   ø€ Ü‰ÑÔØ×'Ñ'ˆÜ�k¤3Ô'Ø&¨Ð4ˆKÜ—h‘h—o‘o°+Àf×FWÑFW�oÓXˆŒÜ—i‘iØ×Ñ +¨a¡.Ñ0°;¸q±>ÑAØ×ÑØô
ˆ�r<   r=   r>   c                 óp   — | j                  |«      }|j                  ddd«      }| j                  |«      }|S )Nr   r(   r   )rD  rþ  rF  rô  s     r;   rJ   zLlama4UnfoldConvolution.forward™  s8   € ØŸ™ MÓ2ˆØ%×-Ñ-¨a°°AÓ6ˆØŸ™ MÓ2ˆØÐr<   r  rP   s   @r;   r?  r?  Œ  s#   ø„ ô

ð U§\¡\ð °e·l±l÷ r<   r?  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLlama4VisionRotaryEmbeddingc                 óÜ  •— t         ‰| �  «        |j                  |j                  z  }t	        j
                  |dz  t        j                  ¬«      j                  |dz  d«      }t	        j                  ||d d gd¬«      }d|d<   ||z  }||z  }|j                  |j                  z  dz  }d|j                  t	        j
                  d|d«      d |dz   j                  «       |z  z  z  }|dz   d	   |d d d d …f   z  j                  dd
¬«      }|dz   d	   |d d d d …f   z  j                  dd
¬«      }	t	        j                  ||	gd
¬«      j                  «       j                  «       dd d d…f   }
|
j                  |j                  d
dd«      dk  d«      }
t	        j                   t	        j"                  t	        j$                  |
«      t	        j&                  |
«      gd
¬«      «      }|| _        y )Nr(   )r—   r   r   rA   rä   )r@   r@   r  ).Nr@   .)r)   r*   Ú
image_sizer  r2   r’   Úint32r˜   Úcatr.   rý   Ú
rope_thetarn   Úrepeat_interleaverî   r·  rÎ   ÚstackÚcosÚsinr  )r9   r%   ÚidxÚimg_idxÚfrequencies_xÚfrequencies_yÚfreq_dimÚ	rope_freqÚfreqs_xÚfreqs_yrÈ   r}  r:   s               €r;   r*   z$Llama4VisionRotaryEmbedding.__init__¡  sÖ  ø€ Ü‰ÑÔØ×Ñ 6×#4Ñ#4Ñ4ˆÜ—,‘,˜s A™v¬U¯[©[Ô9×AÑAÀ#ÀqÁ&È!ÓLˆÜ—)‘)˜W g¨b¨q kÐ2¸Ô:ˆØˆ�‰Ø #™ˆØ 3™ˆØ×%Ñ%¨×)CÑ)CÑCÀqÑHˆØ˜6×,Ñ,´·±¸aÀÈ1Ó1MÐN_ÐQYÐ]^ÑQ^Ð1`×1fÑ1fÓ1hÐksÑ1sÑtÑuˆ	Ø! AÑ% yÑ1°I¸dÀDÊ!¸mÑ4LÑL×_Ñ_Ð`aÐgiÐ_ÓjˆØ! AÑ% yÑ1°I¸dÀDÊ!¸mÑ4LÑL×_Ñ_Ð`aÐgiÐ_ÓjˆÜ—	‘	˜7 GÐ,°"Ô5×;Ñ;Ó=×HÑHÓJÈ3ÑPSÐRSÐPSÈ8ÑTˆØ×!Ñ! '§/¡/°"°a¸Ó";¸aÑ"?ÀÓCˆÜ×(Ñ(¬¯©´e·i±iÀÓ6FÌÏ	É	ÐRWÓHXÐ5YÐ_aÔ)bÓcˆØ ˆ�r<   c                 óL   — | j                   j                  |j                  «      S r\   )r  r–   rŠ   rô  s     r;   rJ   z#Llama4VisionRotaryEmbedding.forward²  s   € Ø�}‰}×Ñ × 4Ñ 4Ó5Ð5r<   r^   rP   s   @r;   rI  rI     s   ø„ ô!ö"6r<   rI  c                   óÊ   ‡ — e Zd ZdZdgZeZdefˆ fd„Zd„ Z	 	 	 	 dde	j                  dee	j                     dee   d	ee   d
ee   deeee	j                  df   f   fd„Zˆ xZS )ÚLlama4VisionModelÚvision_modelr)  r%   c                 ór  •— t         ‰| �  |«       |j                  | _        |j                  | _        |j                  | _        |j
                  | _        | j                  | j                  z  dz  dz   | _        |j                  dz  | _        t        |«      | _	        t        j                  | j                  t        j                  | j                  «      z  «      | _        t        j                  | j                  t        j                  | j                  | j                  «      z  «      | _        t!        |«      | _        t        j$                  | j                  «      | _        t        j$                  | j                  «      | _        t+        |«      | _        t/        |«      | _        | j3                  «        y )Nr(   r   rù   )r)   r*   rK  r  r.   rE  r   Úscaler?  Úpatch_embeddingr0   r1   r2   ÚrandnÚclass_embeddingÚpositional_embedding_vlmrI  Úrotary_embeddingr+  Úlayernorm_preÚlayernorm_postr/  rX  r	  Úvision_adapterrd  r8   s     €r;   r*   zLlama4VisionModel.__init__»  sA  ø€ Ü‰Ñ˜Ô Ø ×+Ñ+ˆŒØ ×+Ñ+ˆŒØ!×-Ñ-ˆÔØ"×/Ñ/ˆÔà ŸO™O¨t¯©Ñ>À1ÑDÀqÑHˆÔØ×'Ñ'¨Ñ-ˆŒ
ä6°vÓ>ˆÔä!Ÿ|™|¨D¯J©J¼¿¹ÀT×EUÑEUÓ9VÑ,VÓWˆÔÜ(*¯©°T·Z±ZÄ%Ç+Á+Èd×N^ÑN^Ð`d×`pÑ`pÓBqÑ5qÓ(rˆÔ%Ü ;¸FÓ CˆÔô  Ÿ\™\¨$×*:Ñ*:Ó;ˆÔÜ Ÿl™l¨4×+;Ñ+;Ó<ˆÔô )¨Ó0ˆŒ
Ü9¸&ÓAˆÔØ�‰Õr<   c                 ó   — | j                   S )zg
        This function is used to fetch the first embedding layer to activate grads on inputs.
        )ra  rr   s    r;   rg  z&Llama4VisionModel.get_input_embeddingsÔ  s   € ð ×#Ñ#Ð#r<   Úpixel_valuesrà   r  rm  rn  r>   .c                 ó  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|j                  \  }}}}	d}
d}| j                  |«      }|j                  \  }}}|j                  ||
z  |z  ||«      }| j                  j                  |j                  d   d|j                  d   «      }t        j                  ||gd¬«      }|dz  }|j                  ||
z  |||«      }| j                  j                  |j                  |j                  ¬«      }||z   }| j                  |«      }|j!                  |d|«      }| j#                  |«      }| j%                  |d|||¬«      }|j&                  }| j)                  |«      }|dd…dd…dd…f   }| j+                  |«      }|r|j,                  nd}|r|d   }nd}|st/        d	„ |||fD «       «      S t1        |||¬
«      S )aÎ  

        Example:

        ```python
        >>> from PIL import Image
        >>> import requests
        >>> from transformers import AutoProcessor, MllamaVisionModel

        >>> checkpoint = "meta-llama/Llama-3.2-11B-Vision"
        >>> model = MllamaVisionModel.from_pretrained(checkpoint)
        >>> processor = AutoProcessor.from_pretrained(checkpoint)

        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> image = Image.open(requests.get(url, stream=True).raw)
        >>> inputs = processor(images=image, return_tensors="pt")

        >>> output = model(**inputs)

        >>> print(output.last_hidden_state.shape)
        torch.Size([1, 1, 4, 1025, 7680])
        ```
        Nr   r   r@   rA   )r—   rŠ   )rà   rm  r  r  r(   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wr\   r8  r4  s     r;   r7  z,Llama4VisionModel.forward.<locals>.<genexpr>3  s   è ø€ Ò_˜qÐQRÑQ^œÑ_ùr8  r9  )r%   r  rm  rt  r~   ra  r˜   rc  r“   r2   rM  rd  r–   r—   rŠ   rf  rC   re  rX  rr  rg  rh  r=   r}   r   )r9   rj  rà   r  rm  rn  Úbatch_size_times_num_tilesrE  r  r  Únum_concurrent_mediaÚ
num_chunksr,  r1  r   r„   rc  Úpositional_embeddingr  r{   r=   rs  s                         r;   rJ   zLlama4VisionModel.forwardÚ  sS  € ð> 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð CO×BTÑBTÑ?Ð" L°&¸%Ø ÐØˆ
Ø×+Ñ+¨LÓ9ˆØ%1×%7Ñ%7Ñ"ˆˆ;˜
ð $×+Ñ+Ø&Ð)=Ñ=À
ÑJÈKÐYcó
ˆð ×.Ñ.×5Ñ5°l×6HÑ6HÈÑ6KÈQÐP\×PbÑPbÐceÑPfÓgˆÜ—y‘y ,°Ð!@ÀaÔHˆØ�qÑˆð $×+Ñ+Ø&Ð)=Ñ=¸zÈ;ÐXbó
ˆð  $×<Ñ<×?Ñ?Àl×FXÑFXÐam×atÑatÐ?ÓuÐØ#Ð&:Ñ:ˆà×)Ñ)¨,Ó7ˆà#×(Ñ(Ð)CÀRÈÓTˆØ×(Ñ(¨Ó6ˆà—‘ØØØ!5Ø/Øð ó 
ˆð ×/Ñ/ˆà×*Ñ*¨<Ó8ˆà#¢A s¨ sªA IÑ.ˆð ×*Ñ*¨<Ó8ˆá0D˜×,Ò,È$ˆáØ ™‰JàˆJáÜÑ_ \°=À*Ð$MÔ_Ó_Ð_äØ*Ø'Ø!ô
ð 	
r<   r=  )rK   rL   rM   r¼  r»  r	   rL  r*   rg  r2   rN   r   r=  r   r   r   rJ   rO   rP   s   @r;   r]  r]  ¶  s®   ø„ Ø&ÐØ3Ð4ÐØ%€LðÐ1õ ò2$ð 26Ø,0Ø/3Ø&*ñ_
à—l‘lð_
ð ! §¡Ñ.ð_
ð $ D™>ð	_
ð
 ' t™nð_
ð ˜d‘^ð_
ð 
ˆ  e§l¡l°CÐ&7Ñ 8Ð8Ñ	9÷_
r<   r]  c            &       óä  ‡ — e Zd Zi ZdZeZdZdefˆ fd„Zd„ Z	d„ Z
d„ Zd„ Zd	„ Zd
„ Zdej                   deeee   f   defd„Z eee¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d&dej2                  dej                   deej6                     deej2                     deeej                         deej                      deeeee   f      dee   deej2                     dee   dee   dee   dee   deej2                     deeej6                  f   dej6                  deeef   f"d„«       Z	 	 	 	 	 	 d'd„Ze dej6                  d ed!ed"ejB                  d#ejD                  dej6                  d$efd%„«       Z#ˆ xZ$S )(ÚLlama4ForConditionalGenerationÚ Tr%   c                 óh  •— t         ‰| �  |«       t        |j                  «      | _        t        |«      | _        t        |j                  «      | _	        |j                  j                  | _
        | j                  j                  �| j                  j                  nd| _        | j                  «        y )Nr@   )r)   r*   r]  rø  r^  rö  Úmulti_modal_projectorrÂ  rE  rÃ  r[  r%   rZ  rd  r8   s     €r;   r*   z'Llama4ForConditionalGeneration.__init__B  s„   ø€ Ü‰Ñ˜Ô Ü-¨f×.BÑ.BÓCˆÔä%>¸vÓ%FˆÔ"Ü/°×0BÑ0BÓCˆÔØ ×,Ñ,×7Ñ7ˆŒØ8<¿¹×8PÑ8PÐ8\˜DŸK™K×4Ò4ÐbdˆÔà�‰Õr<   c                 ó6   — | j                   j                  «       S r\   )rÃ  rg  rr   s    r;   rg  z3Llama4ForConditionalGeneration.get_input_embeddingsM  s   € Ø×"Ñ"×7Ñ7Ó9Ð9r<   c                 ó:   — | j                   j                  |«       y r\   )rÃ  rj  ri  s     r;   rj  z3Llama4ForConditionalGeneration.set_input_embeddingsP  s   € Ø×Ñ×0Ñ0°Õ7r<   c                 ó6   — | j                   j                  «       S r\   )rÃ  rÌ  rr   s    r;   rÌ  z4Llama4ForConditionalGeneration.get_output_embeddingsS  s   € Ø×"Ñ"×8Ñ8Ó:Ð:r<   c                 ó:   — | j                   j                  |«       y r\   )rÃ  rÐ  rÎ  s     r;   rÐ  z4Llama4ForConditionalGeneration.set_output_embeddingsV  s   € Ø×Ñ×1Ñ1°.ÕAr<   c                 ó:   — | j                   j                  |«       y r\   )rÃ  rÕ  rÓ  s     r;   rÕ  z*Llama4ForConditionalGeneration.set_decoderY  s   € Ø×Ñ×'Ñ'¨Õ0r<   c                 ó6   — | j                   j                  «       S r\   )rÃ  r×  rr   s    r;   r×  z*Llama4ForConditionalGeneration.get_decoder\  s   € Ø×"Ñ"×.Ñ.Ó0Ð0r<   rj  Úvision_feature_layerÚvision_feature_select_strategyc                 óØ   — |dvrt        d| j                  › �«      ‚|j                  «       D ��ci c]  \  }}|€Œ	||“Œ }}} | j                  |fddi|¤Ž}|j                  }|S c c}}w )a�  
        Obtains image last hidden states from the vision tower and apply al projection.

        Args:
            pixel_values (`torch.FloatTensor]` of shape `(batch_size, channels, height, width)`)
               The tensors corresponding to the input images.
            vision_feature_layer (`Union[int, List[int]]`):
                The index of the layer to select the vision feature. If multiple indices are provided,
                the vision feature of the corresponding indices will be concatenated to form the
                vision features.
            vision_feature_select_strategy (`str`):
                The feature selection strategy used to select the vision feature from the vision backbone.
                Can be one of `"default"` or `"full"`
        Returns:
            image_features (`torch.Tensor`): Image feature tensor of shape `(num_images, image_length, embed_dim)`).
        )r©   r´  z$Unexpected select feature strategy: rm  F)ru  r}  Úitemsr^  rr  )	r9   rj  r|  r}  rï   Úkr6  Úimage_outputsr,  s	            r;   Úget_image_featuresz1Llama4ForConditionalGeneration.get_image_features_  s€   € ð. *Ð1DÑDÜÐCÀD×DgÑDgÐChÐiÓjÐjØ#)§<¡<£>×C™4˜1˜a°Q±]�!�Q‘$ÐCˆÑCØ)˜×)Ñ)¨,Ñ]ÈUÐ]ÐV\Ñ]ˆØ$×6Ñ6ˆØÐùó Ds
   °
A&»A&rØ  rk  rà   r¸   rA  rl  rÚ  r6  r  rm  rn  r  rÛ  Úimage_sizesr>   c                 óÎ  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  j
                  }|�|n| j                   j                  j                  }|du |duz  rt        d«      ‚|�|�t        d«      ‚|€ | j                  «       |«      }|��b| j                  ||||¬«      }|j                  }|j                  d|j                  d«      «      }| j                  |«      }|| j                   j                  k(  j                  d«      }|j!                  |j"                  «      }|j                  d|j                  d«      «      }|d   j%                  d«      }|j'                  «       }||j                  d«      k7  r t        d|› d	|j                  d«      › �«      ‚|j                  d«      j)                  d|j                  d«      «      }|j+                  ||«      }|j                  |«      } | j,                  d|||||
|||||d
œ
|¤Ž}|d   }d}|	��<|�¥|dd…|j                  d   dz
   d…f   j!                  |j"                  «      }|ddd…dd…f   |j!                  |j"                  «      dk7     j/                  «       }|	ddd…f   |j!                  |	j"                  «      dk7     j/                  «       } n1|ddd…dd…f   j/                  «       }|	ddd…f   j/                  «       } t1        j2                  «       }! |!|j                  d|j                  d«      «      | j                  d«      j!                  |j"                  «      «      }|s|f|dd z   }"|�|f|"z   S |"S t5        |||j6                  |j8                  |j:                  |�¬«      S d¬«      S )aW  
            labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
                Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
                config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
                (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.

            logits_to_keep (`int` or `torch.Tensor`, *optional*):
                If an `int`, compute logits for the last `logits_to_keep` tokens. If `0`, calculate logits for all
                `input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
                token can save memory, which becomes pretty significant for long sequences or large vocabulary size.
                If a `torch.Tensor`, must be 1D corresponding to the indices to keep in the sequence length dimension.
                This is useful when using packed tensor format (single dimension for batch and sequence length).


        Returns:

        Example:

        ```python
        >>> from PIL import Image
        >>> import requests
        >>> from transformers import AutoProcessor, LlavaForConditionalGeneration

        >>> model = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-7b-hf")
        >>> processor = AutoProcessor.from_pretrained("llava-hf/llava-1.5-7b-hf")

        >>> prompt = "USER: <image>\nWhat's the content of the image? ASSISTANT:"
        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> image = Image.open(requests.get(url, stream=True).raw)

        >>> inputs = processor(images=image, text=prompt, return_tensors="pt")

        >>> # Generate
        >>> generate_ids = model.generate(**inputs, max_new_tokens=15)
        >>> processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
        "USER:  \nWhat's the content of the image? ASSISTANT: The image features a busy city street with a stop sign prominently displayed"
        ```Nrq  zdYou cannot specify both pixel_values and inputs_embeds at the same time, and must specify either one)rj  r|  r}  rƒ  r@   ).r   r   zMismatch: final_mask wants z0 embeddings, but multi_modal_projector returned )
rà   r¸   rA  rl  r6  r  rm  rn  r  rÛ  r   .)rÞ  rÝ  rA  r=   rs  rç  r8  )r%   r  rm  rt  rø  r|  r}  ru  rg  r‚  r~   rC   r”   ru  Úimage_token_indexrw  r–   rŠ   r˜   Úsumr“   Úmasked_scatterrÃ  rî   r0   ÚCrossEntropyLossræ  rA  r=   rs  )#r9   rk  rj  rà   r¸   rA  rl  r|  r}  rÚ  r6  r  rm  rn  r  rÛ  rƒ  Ú	lm_kwargsrü  Úoriginal_inputs_embeds_shapeÚvision_flatÚprojected_vision_flatÚspecial_image_maskÚ
final_maskÚfinal_mask_1dÚnum_tokens_to_fillÚexpanded_maskr<  rÝ  rÞ  Úshift_attention_maskÚshift_logitsÚshift_labelsÚloss_fctr{   s#                                      r;   rJ   z&Llama4ForConditionalGeneration.forward}  sa  € ðv 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð $Ð/ñ !à—‘×*Ñ*×?Ñ?ð 	ð .Ð9ñ +à—‘×*Ñ*×IÑIð 	'ð ˜Ð -°tÐ";Ò<ÜÐYÓZÐZàÐ#¨Ð(AÜØvóð ð Ð Ø7˜D×5Ñ5Ó7¸	ÓBˆMàÑ#Ø!×4Ñ4Ø)Ø%9Ø/MØ'ð	 5ó ˆNð ,9×+>Ñ+>Ð(à(×-Ñ-¨b°.×2EÑ2EÀbÓ2IÓJˆKØ$(×$>Ñ$>¸{Ó$KÐ!à"+¨t¯{©{×/LÑ/LÑ"L×!WÑ!WÐXZÓ![ÐØ+×.Ñ.¨}×/CÑ/CÓDˆJØ)×.Ñ.¨r°=×3EÑ3EÀbÓ3IÓJˆMà& vÑ.×6Ñ6°rÓ:ˆMØ!.×!2Ñ!2Ó!4Ðà!Ð%:×%?Ñ%?ÀÓ%BÒBÜ Ø1Ð2DÐ1Eð F:Ø:O×:TÑ:TÐUVÓ:WÐ9XðZóð ð
 *×3Ñ3°BÓ7×>Ñ>¸rÀ=×CUÑCUÐVXÓCYÓZˆMØ)×8Ñ8¸ÐH]Ó^ˆMØ)×.Ñ.Ð/KÓLˆMà%�$×%Ñ%ð 
Ø)Ø%Ø+Ø'ØØ/Ø!5Ø#Ø)Ø)ñ
ð ñ
ˆð ˜‘ˆàˆØÑàÐ)ð (6²a¸6¿<¹<È¹?ÈQÑ;NÐ9OÑ9QÐ6QÑ'R×'UÑ'UÐV\×VcÑVcÓ'dÐ$Ø% c¨3¨B¨3² kÑ2Ð3G×3JÑ3JÈ6Ï=É=Ó3YÐ]^Ñ3^Ñ_×jÑjÓl�Ø% c¨1©2 g™Ð/C×/FÑ/FÀvÇ}Á}Ó/UÐYZÑ/ZÑ[×fÑfÓh‘à% c¨3¨B¨3² kÑ2×=Ñ=Ó?�Ø% c¨1©2 g™×9Ñ9Ó;�ä×*Ñ*Ó,ˆHÙØ×!Ñ! " l×&7Ñ&7¸Ó&;Ó<¸l×>OÑ>OÐPRÓ>S×>VÑ>VÐWc×WjÑWjÓ>kóˆDñ Ø�Y ¨¨ Ñ,ˆFØ'+Ð'7�D�7˜VÑ#ÐC¸VÐCä+ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø2>Ð2J ô
ð 	
ð QUô
ð 	
r<   c           	      óf   —  | j                   j                  |f|||||dœ|¤Ž}	|d   dk(  r||	d<   |	S )N)rA  rl  rà   r  rÛ  r   rj  )rÃ  Úprepare_inputs_for_generation)
r9   rk  rA  rl  rj  rà   r  rÛ  rï   Úmodel_inputss
             r;   r—  z<Llama4ForConditionalGeneration.prepare_inputs_for_generation  s_   € ð I�t×*Ñ*×HÑHØð
à+Ø'Ø)Ø)Ø)ñ
ð ñ
ˆð ˜!Ñ Ò!ð ,8ˆL˜Ñ(àÐr<   rŠ  r‹  r—   rŠ   rŒ  c                 ó˜  — | �| j                  «       dk(  r| }|S t        j                  |«      j                  }	t        j                  ||f|	||¬«      }|dk7  rt        j
                  |d¬«      }|t        j                  ||¬«      |j                  dd«      kD  z  }|dddd…dd…f   j                  |ddd«      }| �Œ|j                  «       }| j                  d   }
|dd…dd…dd…d|
…f   | dd…dddd…f   j                  |j                  «      z   }|dk(  }|dd…dd…dd…d|
…f   j                  ||	«      |dd…dd…dd…d|
…f<   |S )	a°  
        Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
        `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.

        Args:
            attention_mask (`torch.Tensor`):
                A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
                `(batch_size, 1, query_length, key_value_length)`.
            sequence_length (`int`):
                The sequence length being processed.
            target_length (`int`):
                The target length: when generating with static cache, the mask should be as long as the static cache,
                to account for the 0 padding, the part of the cache that is not filled yet.
            dtype (`torch.dtype`):
                The dtype to use for the 4D attention mask.
            device (`torch.device`):
                The device to place the 4D attention mask on.
            cache_position (`torch.Tensor`):
                Indices depicting the position of the input sequence tokens in the sequence.
            batch_size (`torch.Tensor`):
                Batch size.
        Nrú   r°  r   r²  r‰   r@   r   )rB   r2   rš  r›  r´  rµ  r’   r˜   r“   r¶  r~   r–   rŠ   r·  r¸  s               r;   r—  zTLlama4ForConditionalGeneration._prepare_4d_causal_attention_mask_with_cache_position=  sy  € ðB Ð%¨.×*<Ñ*<Ó*>À!Ò*Cà(ˆKð* Ðô' Ÿ™ EÓ*×.Ñ.ˆIÜŸ*™*Ø  -Ð0¸YÈeÐ\bôˆKð  !Ò#Ü#Ÿj™j¨¸qÔA�Øœ5Ÿ<™<¨¸fÔEÈ×H^ÑH^Ð_aÐcdÓHeÑeÑeˆKØ% d¨D²!²QÐ&6Ñ7×>Ñ>¸zÈ1ÈbÐRTÓUˆKØÐ)Ø)×/Ñ/Ó1�Ø,×2Ñ2°2Ñ6�Ø*ª1ªa²°L°[°LÐ+@ÑAÀNÒSTÐVZÐ\`ÒbcÐScÑDd×DgÑDgØ×&Ñ&óEñ  �ð  ,¨qÑ0�Ø5@ÂÂAÂqÈ,È;È,ÐAVÑ5W×5cÑ5cØ  )ó6�šAšq¢! \ k \Ð1Ñ2ð Ðr<   )NNNNNNNNNNNNNNr   N)NNNNNN)%rK   rL   rM   rã  r¼  r   rL  rQ  r*   rg  rj  rÌ  rÐ  rÕ  r×  r2   r>  r   r  r   rÂ   r‚  r   ræ  rä  r(  r   rN   r=  r   rJ   r—  rÀ  r—   rŠ   r—  rO   rP   s   @r;   rr  rr  <  s—  ø„ Ø€HØÐØ€LØÐð	˜|õ 	ò:ò8ò;òBò1ò1ðà×'Ñ'ðð $ C¨¨c© NÑ3ðð ),ó	ñ< Ð+GÐVeÔfð '+Ø*.Ø15Ø37Ø=AØ59Ø@DØ8<Ø-1Ø$(Ø,0Ø/3Ø&*Ø59Ø34Ø$(ñ#_
à×#Ñ#ð_
ð ×'Ñ'ð_
ð ! §¡Ñ.ð	_
ð
 ˜u×/Ñ/Ñ0ð_
ð " $ u×'8Ñ'8Ñ"9Ñ:ð_
ð   × 1Ñ 1Ñ2ð_
ð ' u¨S°$°s±)¨^Ñ'<Ñ=ð_
ð )1°©ð_
ð ˜×)Ñ)Ñ*ð_
ð ˜D‘>ð_
ð $ D™>ð_
ð ' t™nð_
ð ˜d‘^ð_
ð ! ×!1Ñ!1Ñ2ð_
ð  ˜c 5§<¡<Ð/Ñ0ð!_
ð" —\‘\ð#_
ð& 
ˆuÐ2Ð2Ñ	3ò'_
ó gð_
ðH ØØØØØóð< ð7ØŸ™ð7àð7ð ð7ð �{‰{ð	7ð
 —‘ð7ð Ÿ™ð7ð ò7ó ô7r<   rr  )r@  rW  r]  rÂ  rr  )r  )`rê   Údataclassesr   Útypingr   r   r   r   r   r2   Útorch.nnr0   Útorch.nn.functionalrì   ró  Útorch.utils.checkpointÚ/transformers.models.llama4.configuration_llama4r	   Úactivationsr   Úcache_utilsr   r   Ú
generationr   Úmodeling_attn_mask_utilsr   Úmodeling_flash_attention_utilsr   Úmodeling_outputsr   r   r   r   Úmodeling_rope_utilsr   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr   r   r   r   r   Úconfiguration_llama4r   r    Ú!torch.nn.attention.flex_attentionr!   Úintegrations.flex_attentionr"   Ú
get_loggerrK   r  Ú_CHECKPOINT_FOR_DOCrä  ÚModuler$   rR   r`   ru   r€   r¦   rN   rÕ   r  rÛ   rn   rõ   r÷   r*  ÚLLAMA4_START_DOCSTRINGr@  r½  rW  rÂ  ræ  rê  rö  r  r	  ÚLLAVA_START_DOCSTRINGr  r  r  r%  r)  r/  r?  rI  r]  rr  Ú__all__r8  r<   r;   ú<module>r³     s¥  ðó  Ý !ß 9Õ 9ã Ý ß Ð Û å Nå !ß 4Ý )Ý >Ý B÷ó õ 7ß FÝ &÷õ ÷ Añ  Ô!Ý;åJà	ˆ×	Ñ	˜HÓ	%€Ø+Ð Ø €ô˜Ÿ	™	ô ôB)�B—I‘Iô )ô$!�u—x‘x—‘ô !ô=˜Ÿ	™	ô =ô(+"�B—I‘Iô +"ô\3 §	¡	ô 3ðl	2Ø�‰ð	2à�‰ð	2ð �|‰|ð	2ð ˆ5�<‰<˜Ÿ™Ð%Ñ&ó		2ð	U˜UŸ\™\ð 	U°#ð 	U¸%¿,¹,ó 	Uð& ñ%Ø�I‰Ið%à�<‰<ð%ð 
�‰ð%ð �<‰<ð	%ð
 ˜UŸ\™\Ñ*ð%ð ð%ð ó%ô2`)˜"Ÿ)™)ô `)ôFF˜RŸY™Yô FðRÐ ñ" ØZØóô?˜Oó ?ó	ð?ð8HÐ ñV ØZØóôUÐ+ó Uó	ðUôp
z
Ð-¨ô z
ðz ô$< ;ó $<ó ð$<ôN;�u—x‘x—‘ô ;ô" §	¡	ô òô(
) "§)¡)ô 
)ðÐ ð$! E§L¡Lð !¸¿¹ó !ð:Ø�<‰<ð:à	�‰ð:ð �l‰lð:ð ˆ5�<‰<˜Ÿ™Ð%Ñ&ó	:ô=)˜BŸI™Iô =)ô@�b—i‘iô ô)˜rŸy™yô )ôXW
˜"Ÿ)™)ô W
ôt˜bŸi™iô ô(6 "§)¡)ô 6ô,C
Ð-ô C
ôLyÐ%:¸Oô yòx	�r<   