Ë
    T^(hú: ã                   óÐ  — d Z ddlmZ ddlmZmZmZmZmZm	Z	 ddl
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 dd	lmZ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  ddl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z.  e&«       rddl/m0Z0 ddl1m2Z2  e'jf                  e4«      Z5dZ6e G d„ de«      «       Z7e G d„ de«      «       Z8	 	 	 	 d9d„Z9g fd„Z: G d„ dejv                  «      Z< G d„ d ejz                  «      Z> G d!„ d"ej~                  «      Z@ e"j‚                  e@«        G d#„ d$e
j                  j~                  «      ZBd%„ ZCd:d&„ZD G d'„ d(ej~                  «      ZE G d)„ d*ej~                  «      ZF G d+„ d,ej~                  «      ZG G d-„ d.ej~                  «      ZHd/ZI e$d0eI«       G d1„ d2e «      «       ZJd3ZK e$d0eI«       G d4„ d5eJ«      «       ZL G d6„ d7eJe«      ZMg d8¢ZNy);zPyTorch Idefics model.é    )Ú	dataclass)ÚAnyÚDictÚListÚOptionalÚTupleÚUnionN)Únn)ÚCrossEntropyLossé   )ÚACT2FN)ÚCacheÚDynamicCacheÚStaticCache)ÚGenerationMixin)ÚAttentionMaskConverter)ÚModelOutput)ÚPretrainedConfigÚPreTrainedModel)ÚALL_LAYERNORM_LAYERS)Úadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚis_torch_flex_attn_availableÚloggingÚreplace_return_docstringsé   )ÚIdeficsConfig)ÚIdeficsPerceiverResampler)ÚIdeficsVisionTransformer)Ú	BlockMask)Úmake_flex_block_causal_maskr   c                   óø   — e Zd ZU dZdZeej                     ed<   dZ	e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
ej                        ed<   y)ÚIdeficsBaseModelOutputWithPastaæ	  
    Base class for Idefics model's outputs that may also contain a past key/values (to speed up sequential decoding).

    Args:
        last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
            Sequence of hidden-states at the output of the last layer of the model.

            If `past_key_values` is used only the last hidden-state of the sequences of shape `(batch_size, 1,
            hidden_size)` is output.
        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)`) and optionally if
            `config.is_encoder_decoder=True` 2 additional tensors of shape `(batch_size, num_heads,
            encoder_sequence_length, embed_size_per_head)`.

            Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
            `config.is_encoder_decoder=True` in the cross-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 (`tuple(torch.FloatTensor)`, *optional*):
            Tuple of `torch.FloatTensor` (one for the output of the image embeddings, `(batch_size, num_images,
            sequence_length, hidden_size)`.

            image_hidden_states of the model produced by the vision encoder, and optionally by the perceiver
    NÚlast_hidden_stateÚpast_key_valuesÚhidden_statesÚ
attentionsÚimage_hidden_states)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r   ÚtorchÚFloatTensorÚ__annotations__r%   r   r&   r'   r(   © ó    új/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/idefics/modeling_idefics.pyr#   r#   =   sŽ   … ñ"ðH 6:Ð�x × 1Ñ 1Ñ2Ó9ØAE€O�X˜e E¨%×*;Ñ*;Ñ$<Ñ=Ñ>ÓEØ8<€M�8˜E %×"3Ñ"3Ñ4Ñ5Ó<Ø59€J�˜˜u×0Ñ0Ñ1Ñ2Ó9Ø>BÐ˜ %¨×(9Ñ(9Ñ":Ñ;ÔBr1   r#   c                   ó  — e Zd ZU dZdZeej                     ed<   dZ	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ej                        ed<   dZeeej                        ed<   y)	ÚIdeficsCausalLMOutputWithPastaÔ  
    Base class for Idefics 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 (`tuple(torch.FloatTensor)`, *optional*):
            Tuple of `torch.FloatTensor` (one for the output of the image embeddings, `(batch_size, num_images,
            sequence_length, hidden_size)`.

            image_hidden_states of the model produced by the vision encoder, and optionally by the perceiver
    NÚlossÚlogitsr%   r&   r'   r(   )r)   r*   r+   r,   r5   r   r-   r.   r/   r6   r%   r   r&   r   r'   r(   r0   r1   r2   r4   r4   j   s�   … ñð@ )-€Dˆ(�5×$Ñ$Ñ
%Ó,Ø*.€FˆH�U×&Ñ&Ñ'Ó.Ø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Ø>BÐ˜ %¨×(9Ñ(9Ñ":Ñ;ÔBr1   r4   c                 ó  — t        j                  | j                  d   «      j                  dd«      j	                  d|«      j                  d«      j                  | j                  «      }| j                  d|«      } |j                  dd «      |d<   |j                  dd «      |d<   |j                  dd «      |d<   |j                  dd «      |d<   d|v r|d   }|j                  d|«      |d<   |�|j                  d|«      |d	<   |d   �|d   j                  d|«      |d<   |d   �|d   j                  d|«      |d<   | |fS |d   �|d   j                  d|«      |d<   | |fS |d   �|d   j                  d|«      |d<   | |fS )
Nr   éÿÿÿÿr   Úpixel_valuesÚimage_encoder_embeddingsÚperceiver_embeddingsÚimage_attention_maskÚtoken_type_idsÚattention_mask)	r-   ÚarangeÚshapeÚviewÚrepeatÚtoÚdeviceÚindex_selectÚget)Ú	input_idsÚexpand_sizeÚis_encoder_decoderr>   Úencoder_outputsÚmodel_kwargsÚexpanded_return_idxr=   s           r2   Úexpand_inputs_for_generationrM   ”   sû  € ô 	�‰�Y—_‘_ QÑ'Ó(×-Ñ-¨b°!Ó4×;Ñ;¸A¸{ÓK×PÑPÐQSÓT×WÑWÐXa×XhÑXhÓið ð ×&Ñ& qÐ*=Ó>€IØ#/×#3Ñ#3°NÀDÓ#I€L�Ñ Ø/;×/?Ñ/?Ð@ZÐ\`Ó/a€LÐ+Ñ,Ø+7×+;Ñ+;Ð<RÐTXÓ+Y€LÐ'Ñ(Ø+7×+;Ñ+;Ð<RÐTXÓ+Y€LÐ'Ñ(à˜<Ñ'Ø%Ð&6Ñ7ˆØ)7×)DÑ)DÀQÐH[Ó)\ˆÐ%Ñ&àÐ!Ø)7×)DÑ)DÀQÐH[Ó)\ˆÐ%Ñ&àÐ*Ñ+Ð7Ø/;Ð<RÑ/S×/`Ñ/`ØÐ"ó0
ˆÐ+Ñ,ð �NÑ#Ð/Ø'3°NÑ'C×'PÑ'PÐQRÐTgÓ'hˆ�^Ñ$ð �lÐ"Ð"ð 
Ð0Ñ	1Ð	=Ø3?Ð@ZÑ3[×3hÑ3hØÐ"ó4
ˆÐ/Ñ0ð �lÐ"Ð"ð 
Ð,Ñ	-Ð	9Ø/;Ð<RÑ/S×/`Ñ/`ØÐ"ó0
ˆÐ+Ñ,ð �lÐ"Ð"r1   c                 ó2  ‡— t         j                  t         j                  t         j                  dœ}|D �cg c]  }||   ‘Œ	 }}| j	                  «       D ];  Š|r&t        ˆfd„|D «       «      r‰j                  d«       Œ+‰j                  d«       Œ= | S c c}w )N)Ú	LayerNormÚLinearÚ	Embeddingc              3   ó6   •K  — | ]  }t        ‰|«      –— Œ y ­w©N)Ú
isinstance)Ú.0ÚtÚmodules     €r2   ú	<genexpr>zfreeze_model.<locals>.<genexpr>É   s   øè ø€ Ò$]¸q¤Z°¸×%:Ñ$]ùs   ƒTF)r
   rO   rP   rQ   ÚmodulesÚanyÚrequires_grad_)ÚmodelÚmodule_exceptionsÚmappingÚmÚmodule_exceptions_mappedrW   s        @r2   Úfreeze_modelra   Á   s‰   ø€ ä—\‘\Ü—)‘)Ü—\‘\ñ€Gð
 5FÖF¨q ¨£
ÐFÐÐFØ—-‘-“/ò )ˆÙ¤Ó$]ÐD\Ô$]Ô!]Ø×!Ñ! $Õ'à×!Ñ! %Õ(ð	)ð
 €Lùò  Gs   ¶Bc                   óN   ‡ — e Zd ZdZ	 	 	 	 ddee   ddfˆ fd„Zd„ Zdefd„Z	ˆ xZ
S )	ÚIdeficsDecoupledEmbeddinga¿  
    Implements a decoupling of parameters to allow freezing (or not) a subset of the embeddings. In practise, the
    regular `weight` can be trained or frozen (i.e. `partially_freeze=True`), and if `num_additional_embeddings` > 0,
    then it will create `num_additional_embeddings` additional parameters that are always trained. If
    `num_additional_embeddings=0`, then the module defaults back to the regular behavior of `nn.Embedding`.
    NÚpartially_freezeÚreturnc           	      óB  •— |�||kD  rt        d|› d|› �«      ‚t        ‰	| �  d|||||dœ|¤Ž || _        || _        || _        || _        |r| j                  j                  d«       | j
                  dkD  r)t        j                  | j
                  |||¬«      | _        yy)	a)  
        Args:
            num_embeddings (`int`):
                Size of the dictionary of embeddings
            num_additional_embeddings (`int`):
                Number of additional embeddings. Only useful when you `partially_freeze=True`.
            embedding_dim (`int`):
                The size of each embedding vector
            partially_freeze: (`bool`, *optional*, defaults to `False`):
                If `True`, the regular `weight` will be frozen. `additional_weight` is never frozen.
            padding_idx (`int`, *optional*):
                The padding index (needs to be less than num_embeddings)

        Note: there are a lot of other parameters to initialize a standard `nn.Embedding` such as `padding_idx`,
        `max_norm` or `norm_type`. We are not supporting these.
        Nz/padding_idx must be within num_embeddings. Got z and )Únum_embeddingsÚembedding_dimrD   ÚdtypeÚpadding_idxFr   )rg   rh   rD   ri   r0   )Ú
ValueErrorÚsuperÚ__init__rg   rj   Únum_additional_embeddingsrd   Úweightr[   r
   rQ   Úadditional_embedding)
Úselfrg   rn   rh   rd   rD   ri   rj   ÚkwargsÚ	__class__s
            €r2   rm   z"IdeficsDecoupledEmbedding.__init__Ù   sÆ   ø€ ð6 Ð" {°^Ò'CÜÐNÈ{ÈmÐ[`ÐaoÐ`pÐqÓrÐrÜ‰Ñð 	
Ø)Ø'ØØØ#ñ	
ð ò	
ð -ˆÔØ&ˆÔØ)BˆÔ&Ø 0ˆÔáØ�K‰K×&Ñ& uÔ-à×)Ñ)¨AÒ-Ü(*¯©Ø#×=Ñ=Ø+ØØô	)ˆDÕ%ð .r1   c                 ób  — | j                   dk(  r t        j                  || j                  «      S |j	                  «       }t        j                  || j                  k\  «      }||   }| j                  || j                  z
  «      }d||<   t        j                  || j                  «      }|||<   |S )aû  
        we have 2 embeddings, with different indices - one pretrained self.weight and another
        self.additional_embedding.weight that is being trained.

        in order to make a lookup of the input ids, we:
        1. find out the indices of the entries belonging to the 2nd embedding
        2. extract those values while subtracting the size of the first embedding (num_embeddings), since the 2nd
           embedding starts from 0 and not num_embeddings
        3. perform the 2nd embedding lookup
        4. now we handle the 1st embedding, we overwrite indices belonging to the 2nd embedding with a padding index
        5. perform the 1st embedding lookup
        6. now we overwrite the values in the 1st embedding lookup with the values of the 2nd embedding lookup

        note: for the 1st embedding lookup we could have looked up only the low indices and not do the padding, but
        then we have to create a new tensor and populate it with 2 tensors that are spread out across various indices -
        i.e. not a simple concat - I haven't benchmarked the complex case if it's any faster, given that seqlens are
        usually relatively short it's probably not faster or if faster not by much - but might be a good idea to
        measure.

        r   )	rn   ÚFÚ	embeddingro   Úcloner-   Úwhererg   rp   )rq   rG   Úadditional_vocab_indicesÚinput_ids_additional_vocabÚadditional_embeddingsÚfull_vectors         r2   Úforwardz!IdeficsDecoupledEmbedding.forward  s®   € ð* ×)Ñ)¨QÒ.Ü—;‘;˜y¨$¯+©+Ó6Ð6ð —O‘OÓ%ˆ	Ü#(§;¡;¨y¸D×<OÑ<OÑ/OÓ#PÐ Ø%.Ð/GÑ%HÐ"Ø $× 9Ñ 9Ð:TÐW[×WjÑWjÑ:jÓ kÐð /0ˆ	Ð*Ñ+Ü—k‘k )¨T¯[©[Ó9ˆð 1FˆÐ,Ñ-àÐr1   c                 óz   — dj                  | j                  | j                  | j                  | j                  «      S )NzVnum_embeddings={}, num_additional_embeddings={}, embedding_dim={}, partially_freeze={})Úformatrg   rn   rh   rd   ©rq   s    r2   Ú
extra_reprz$IdeficsDecoupledEmbedding.extra_repr5  s9   € Øg×nÑnØ×ÑØ×*Ñ*Ø×ÑØ×!Ñ!ó	
ð 	
r1   )FNNN)r)   r*   r+   r,   r   Úboolrm   r}   Ústrr�   Ú__classcell__©rs   s   @r2   rc   rc   Ð   sF   ø„ ñð ,1ØØØñ3ð
 # 4™.ð3ð 
õ3òj%ðN
˜C÷ 
r1   rc   c                   óŒ   ‡ — e Zd ZdZ	 	 	 	 	 ddedededededdfˆ fd	„Zd
ej                  dej                  fd„Z	de
fd„Zˆ xZS )ÚIdeficsDecoupledLinearaÄ  
    Implements a decoupling of parameters to allow freezing (or not) a subset of the parameters. In practise, the
    regular `weight` can be trained or frozen (i.e. `partially_freeze=True`), and if `out_additional_features` > 0,
    then it will create `out_additional_features * in_features` additional parameters that are always trained. If
    `out_additional_features=0`, then the module defaults back to the regular behavior of `nn.Linear`.
    NÚin_featuresÚout_featuresÚout_additional_featuresÚbiasrd   re   c                 ó"  •— t         ‰| �  |||||«       || _        || _        || _        || _        |r8| j                  j                  d«       |r| j                  j                  d«       |dkD  r t        j                  |||||¬«      | _        yy)aG  
        out_additional_features: int. Number of additional trainable dimensions. Only makes sense when
        `partially_freeze=True`. partially_freeze: bool. If True, the regular `weight` will be frozen and extra
        parameters (if any) will be trainable. If False, default to the regular behavior of nn.Linear.
        Fr   )rˆ   r‰   r‹   rD   ri   N)rl   rm   rŠ   rd   rˆ   r‰   ro   r[   r‹   r
   rP   Úadditional_fc)	rq   rˆ   r‰   rŠ   r‹   rd   rD   ri   rs   s	           €r2   rm   zIdeficsDecoupledLinear.__init__G  s‘   ø€ ô 	‰Ñ˜ l°D¸&À%ÔHØ'>ˆÔ$Ø 0ˆÔà&ˆÔØ(ˆÔáØ�K‰K×&Ñ& uÔ-ÙØ—	‘	×(Ñ(¨Ô/à" QÒ&Ü!#§¡Ø'Ø4ØØØô"ˆDÕð 'r1   Úinputc                 óÌ   — t        j                  || j                  | j                  «      }| j                  dkD  r)| j                  |«      }t        j                  ||fd«      }|S )Nr   r8   )ru   Úlinearro   r‹   rŠ   r�   r-   Úcat)rq   rŽ   ÚoutputÚadditional_featuress       r2   r}   zIdeficsDecoupledLinear.forwardk  sV   € Ü—‘˜% §¡¨d¯i©iÓ8ˆà×'Ñ'¨!Ò+Ø"&×"4Ñ"4°UÓ";ÐÜ—Y‘Y Ð(;Ð<¸bÓAˆFàˆr1   c                 ó”   — dj                  | j                  | j                  | j                  | j                  du| j
                  «      S )z=Overwriting `nn.Linear.extra_repr` to include new parameters.zYin_features={}, out_features={}, out_additional_features={}, bias={}, partially_freeze={}N)r   rˆ   r‰   rŠ   r‹   rd   r€   s    r2   r�   z!IdeficsDecoupledLinear.extra_reprt  sE   € àj×qÑqØ×ÑØ×ÑØ×(Ñ(Ø�I‰I˜TÐ!Ø×!Ñ!ó
ð 	
r1   )r   TTNN)r)   r*   r+   r,   Úintr‚   rm   r-   ÚTensorr}   rƒ   r�   r„   r…   s   @r2   r‡   r‡   >  s€   ø„ ñð ()ØØ!%ØØñ"àð"ð ð"ð "%ð	"ð
 ð"ð ð"ð 
õ"ðH˜UŸ\™\ð ¨e¯l©ló ð
˜C÷ 
r1   r‡   c                   ó,   ‡ — e Zd Zdˆ fd„	Zd„ Zd„ Zˆ xZS )ÚIdeficsRMSNormc                 óŠ   •— t         ‰| �  «        t        j                  t	        j
                  |«      «      | _        || _        y)z=
        IdeficsRMSNorm is equivalent to T5LayerNorm
        N)rl   rm   r
   Ú	Parameterr-   Úonesro   Úvariance_epsilon)rq   Úhidden_sizeÚepsrs   s      €r2   rm   zIdeficsRMSNorm.__init__�  s1   ø€ ô 	‰ÑÔÜ—l‘l¤5§:¡:¨kÓ#:Ó;ˆŒØ #ˆÕr1   c                 óž  — |j                  t        j                  «      j                  d«      j	                  dd¬«      }|t        j
                  || j                  z   «      z  }| j                  j                  t        j                  t        j                  fv r%|j                  | j                  j                  «      }| j                  |z  S )Né   r8   T)Úkeepdim)rC   r-   Úfloat32ÚpowÚmeanÚrsqrtrœ   ro   ri   Úfloat16Úbfloat16)rq   r&   Úvariances      r2   r}   zIdeficsRMSNorm.forward‰  s™   € Ø ×#Ñ#¤E§M¡MÓ2×6Ñ6°qÓ9×>Ñ>¸rÈ4Ð>ÓPˆØ%¬¯©°H¸t×?TÑ?TÑ4TÓ(UÑUˆð �;‰;×Ñ¤§¡´·±Ð ?Ñ?Ø)×,Ñ,¨T¯[©[×->Ñ->Ó?ˆMà�{‰{˜]Ñ*Ð*r1   c                 ó^   — t        | j                  j                  «      › d| j                  › �S )Nz, eps=)Útuplero   r@   rœ   r€   s    r2   r�   zIdeficsRMSNorm.extra_repr“  s*   € Ü˜Ÿ™×)Ñ)Ó*Ð+¨6°$×2GÑ2GÐ1HÐIÐIr1   )g�íµ ÷Æ°>)r)   r*   r+   rm   r}   r�   r„   r…   s   @r2   r˜   r˜   €  s   ø„ õ$ò+öJr1   r˜   c                   ó.   ‡ — e Zd Zdˆ fd„	Zd„ Zdd„Zˆ xZS )ÚIdeficsEmbeddingc                 óÂ  •— t         ‰| �  «        || _        || _        || _        d| j                  t        j                  d| j                  dt
        j                  ¬«      j                  |t
        j                  ¬«      | j                  z  z  z  }| j                  d|d¬«       | j                  || j                  j                  t        j                  «       ¬	«       y )
Ng      ð?r   r    ©ri   ©rD   ri   Úinv_freqF©Ú
persistent©Úseq_lenrD   ri   )rl   rm   ÚdimÚmax_position_embeddingsÚbaser-   r?   Úint64rC   ÚfloatÚregister_bufferÚ_set_cos_sin_cacher°   rD   Úget_default_dtype)rq   rµ   r¶   r·   rD   r°   rs   s         €r2   rm   zIdeficsEmbedding.__init__œ  s¿   ø€ Ü‰ÑÔàˆŒØ'>ˆÔ$ØˆŒ	ØØ�I‰IÜ—‘˜Q §¡¨!´5·;±;Ô?×BÑBÈ&ÔX]×XcÑXcÐBÓdÐgk×goÑgoÑoñqñ
ˆð 	×Ñ˜Z¨¸eÐÔDð 	×ÑØ+°D·M±M×4HÑ4HÔPU×PgÑPgÓPið 	 õ 	
r1   c                 óÜ  — || _         t        j                  | j                   |t        j                  ¬«      j	                  | j
                  «      }t        j                  d|| j
                  «      }t        j                  ||fd¬«      }| j                  d|j                  «       j                  |«      d¬«       | j                  d|j                  «       j                  |«      d¬«       y )	Nr¯   zi,j->ijr8   ©rµ   Ú
cos_cachedFr±   Ú
sin_cached)Úmax_seq_len_cachedr-   r?   r¸   Útype_asr°   Úeinsumr‘   rº   ÚcosrC   Úsin)rq   r´   rD   ri   rV   ÚfreqsÚembs          r2   r»   z#IdeficsEmbedding._set_cos_sin_cache­  sª   € Ø")ˆÔÜ�L‰L˜×0Ñ0¸ÄuÇ{Á{ÔS×[Ñ[Ð\`×\iÑ\iÓjˆä—‘˜Y¨¨4¯=©=Ó9ˆä�i‰i˜ ˜¨BÔ/ˆØ×Ñ˜\¨3¯7©7«9¯<©<¸Ó+>È5ÐÔQØ×Ñ˜\¨3¯7©7«9¯<©<¸Ó+>È5ÐÕQr1   c                 ó  — || j                   kD  r(| j                  ||j                  |j                  ¬«       | j                  d | j                  |j                  ¬«      | j                  d | j                  |j                  ¬«      fS )Nr³   r®   )rÁ   r»   rD   ri   r¿   rC   rÀ   )rq   Úxr´   s      r2   r}   zIdeficsEmbedding.forward·  sy   € à�T×,Ñ,Ò,Ø×#Ñ#¨G¸A¿H¹HÈAÏGÉGÐ#ÔTð �O‰O˜H˜WÐ%×(Ñ(¨q¯w©wÐ(Ó7Ø�O‰O˜H˜WÐ%×(Ñ(¨q¯w©wÐ(Ó7ð
ð 	
r1   )i   i'  NrS   )r)   r*   r+   rm   r»   r}   r„   r…   s   @r2   r¬   r¬   ›  s   ø„ õ
ò"R÷
r1   r¬   c                 óš   — | dd| j                   d   dz  …f   }| d| j                   d   dz  d…f   }t        j                  | |fd¬«      S )z*Rotates half the hidden dims of the input..Nr8   r    r¾   )r@   r-   r‘   )rÉ   Úx1Úx2s      r2   Úrotate_halfrÍ   Â  sZ   € à	
ˆ3Ð"�!—'‘'˜"‘+ Ñ"Ð"Ð"Ñ	#€BØ	
ˆ3�—‘˜‘˜qÑ Ñ"Ð"Ñ	#€BÜ�9‰9�r�c˜2�Y BÔ'Ð'r1   c                 óª   — ||   j                  |«      }||   j                  |«      }| |z  t        | «      |z  z   }||z  t        |«      |z  z   }||fS )an  Applies Rotary Position Embedding to the query and key tensors.

    Args:
        q (`torch.Tensor`): The query tensor.
        k (`torch.Tensor`): The key tensor.
        cos (`torch.Tensor`): The cosine part of the rotary embedding.
        sin (`torch.Tensor`): The sine part of the rotary embedding.
        position_ids (`torch.Tensor`):
            The position indices of the tokens corresponding to the query and key tensors. For example, this can be
            used to pass offsetted position ids when working with a KV-cache.
        unsqueeze_dim (`int`, *optional*, defaults to 1):
            The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
            sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
            that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
            k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
            cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
            the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
    Returns:
        `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
    )Ú	unsqueezerÍ   )ÚqÚkrÄ   rÅ   Úposition_idsÚunsqueeze_dimÚq_embedÚk_embeds           r2   Úapply_rotary_pos_embrÖ   É  sg   € ð* ˆlÑ
×
%Ñ
% mÓ
4€CØ
ˆlÑ
×
%Ñ
% mÓ
4€CØ�3‰wœ; q›>¨CÑ/Ñ0€GØ�3‰wœ; q›>¨CÑ/Ñ0€GØ�GÐÐr1   c                   ó2   ‡ — e Zd Zdededefˆ fd„Zd„ Zˆ xZS )Ú
IdeficsMLPr�   Úintermediate_sizeÚ
hidden_actc                 óì   •— t         ‰| �  «        t        j                  ||d¬«      | _        t        j                  ||d¬«      | _        t        j                  ||d¬«      | _        t        |   | _        y )NF©r‹   )	rl   rm   r
   rP   Ú	gate_projÚ	down_projÚup_projr   Úact_fn)rq   r�   rÙ   rÚ   rs   s       €r2   rm   zIdeficsMLP.__init__ç  s[   ø€ ô 	‰ÑÔÜŸ™ ;Ð0AÈÔNˆŒÜŸ™Ð#4°kÈÔNˆŒÜ—y‘y Ð.?ÀeÔLˆŒÜ˜ZÑ(ˆ�r1   c                 ó„   — | j                  | j                  | j                  |«      «      | j                  |«      z  «      S rS   )rÞ   rà   rÝ   rß   )rq   rÉ   s     r2   r}   zIdeficsMLP.forwardó  s0   € Ø�~‰~˜dŸk™k¨$¯.©.¸Ó*;Ó<¸t¿|¹|ÈA»ÑNÓOÐOr1   )r)   r*   r+   r•   rƒ   rm   r}   r„   r…   s   @r2   rØ   rØ   æ  s*   ø„ ð
)àð
)ð ð
)ð õ	
)öPr1   rØ   c                   ó¬  ‡ — e Zd ZdZ	 	 	 	 	 ddededededededee   fˆ fd	„Z	d
e
j                  dede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dedee
j                     dee
j                  ee
j                     eee
j                        f   fd„Zˆ xZS )ÚIdeficsAttentionz=Multi-headed attention from 'Attention Is All You Need' paperr�   Ú	num_headsÚdropoutÚis_cross_attentionÚconfigÚqk_layer_normsÚ	layer_idxc                 ó¼  •— t         ‰	| �  «        || _        || _        ||z  | _        || _        d| _        || _        |€-t        j                  d| j                  j                  › d�«       | j                  |z  | j                  k7  rt        d| j                  › d|› d�«      ‚|| _        t        t        j                   d«      st        d«      ‚| j                  rÁt        |j"                  d	«      s| j                  n|j"                  j$                  }t        j&                  | j                  || j                  z  d
¬«      | _        t        j&                  ||| j                  z  d
¬«      | _        t        j&                  ||| j                  z  d
¬«      | _        nœt        j&                  | j                  || j                  z  d
¬«      | _        t        j&                  | j                  || j                  z  d
¬«      | _        t        j&                  | j                  || j                  z  d
¬«      | _        t        j&                  || j                  z  |d
¬«      | _        t1        | j                  «      | _        || _        | j4                  rMt7        | j                  |j8                  ¬«      | _        t7        | j                  |j8                  ¬«      | _        y y )NTzInstantiating z¹ without passing a `layer_idx` is not recommended and will lead to errors during the forward call if caching is used. Please make sure to provide a `layer_idx` when creating this class.z?hidden_size must be divisible by num_heads (got `hidden_size`: z and `num_heads`: z).Úscaled_dot_product_attentionz)this model requires pytorch 2.0 or higherÚ	embed_dimFrÜ   ©rž   )rl   rm   r�   rä   Úhead_dimrå   Ú	is_causalré   ÚloggerÚwarning_oncers   r)   rk   ræ   Úhasattrr
   Ú
functionalÚvision_configrì   rP   Úq_projÚk_projÚv_projÚo_projr¬   Ú
rotary_embrè   r˜   Úrms_norm_epsÚq_layer_normÚk_layer_norm)
rq   r�   rä   rå   ræ   rç   rè   ré   Úkv_input_dimrs   s
            €r2   rm   zIdeficsAttention.__init__û  su  ø€ ô 	‰ÑÔØ&ˆÔØ"ˆŒØ# yÑ0ˆŒØˆŒØˆŒà"ˆŒØÐÜ×ÑØ  §¡×!8Ñ!8Ð 9ð :,ð ,ôð �M‰M˜IÑ%¨$×*:Ñ*:Ò:ÜØQÐRV×RbÑRbÐQcØ$ Y K¨rð3óð ð
 #5ˆÔä”r—}‘}Ð&DÔEÜÐHÓIÐIà×"Ò"ä(/°×0DÑ0DÀkÔ(R�× Ò ÐX^×XlÑXl×XvÑXvð ô Ÿ)™)Ø× Ñ Ø˜DŸM™MÑ)ØôˆDŒKô
 Ÿ)™) L°)¸d¿m¹mÑ2KÐRWÔXˆDŒKÜŸ)™)ØØ˜DŸM™MÑ)ØôˆD�Kô Ÿ)™)Ø× Ñ Ø˜DŸM™MÑ)ØôˆDŒKô
 Ÿ)™)Ø× Ñ Ø˜DŸM™MÑ)ØôˆDŒKô
 Ÿ)™)Ø× Ñ Ø˜DŸM™MÑ)ØôˆDŒKô
 —i‘iØ˜Ÿ™Ñ%ØØô
ˆŒô
 +¨4¯=©=Ó9ˆŒà,ˆÔØ×ÒÜ .¨t¯}©}À&×BUÑBUÔ VˆDÔÜ .¨t¯}©}À&×BUÑBUÔ VˆDÕð r1   Útensorr´   Úbszc                 óŽ   — |j                  ||| j                  | j                  «      j                  dd«      j	                  «       S )Nr   r    )rA   rä   rî   Ú	transposeÚ
contiguous)rq   rþ   r´   rÿ   s       r2   Ú_shapezIdeficsAttention._shapeJ  s7   € Ø�{‰{˜3 ¨¯©¸¿¹ÓG×QÑQÐRSÐUVÓW×bÑbÓdÐdr1   r&   Úkey_value_statesr>   rÒ   Úpast_key_valueÚoutput_attentionsÚ	use_cacheÚcache_positionre   c	                 óœ  — | j                   xs |d u}	|j                  «       \  }
}}| j                  |«      j                  |
|| j                  | j
                  «      j                  dd«      }|	s�| j                  |«      j                  |
|| j                  | j
                  «      j                  dd«      }| j                  |«      j                  |
|| j                  | j
                  «      j                  dd«      }n¢|j                  «       \  }}}| j                  |«      j                  |
|| j                  | j
                  «      j                  dd«      }| j                  |«      j                  |
|| j                  | j
                  «      j                  dd«      }|j                  d   }|�||d   z  }|	s2| j                  |t        ||«      ¬«      \  }}t        |||||«      \  }}|�%d|i}|j                  ||| j                  |«      \  }}| j                  r"| j!                  |«      }| j#                  |«      }|}|�|d d …d d …d d …d |j                  d   …f   }|j$                  j&                  dk(  r2|�0|j)                  «       }|j)                  «       }|j)                  «       }| j*                  r	|€|dkD  rdnd	}t,        j.                  j0                  j3                  ||||| j4                  r| j6                  nd
|¬«      }|j                  «       |
| j                  || j
                  fk7  r7t9        d|
| j                  || j
                  f› d|j                  «       › �«      ‚|j                  dd«      }|j;                  |
|| j<                  «      }| j?                  |«      }d }|rt@        jC                  d«       |||fS )Nr   r    éþÿÿÿr   )r´   r  ÚcudaTFç        )Ú	attn_maskÚ	dropout_prï   z `attn_output` should be of size z	, but is z^attn_weights are not extracted in scaled_dot_product_attention. The model returns None instead)"ræ   Úsizerõ   rA   rä   rî   r  rö   r÷   r@   rù   ÚmaxrÖ   Úupdateré   rè   rû   rü   rD   Útyper  rï   r-   r
   ró   rë   Útrainingrå   rk   Úreshaper�   rø   rð   rñ   )rq   r&   r  r>   rÒ   r  r  r  r  ræ   rÿ   Úq_lenÚ_Úquery_statesÚ
key_statesÚvalue_statesÚkv_lenÚ
kv_seq_lenrÄ   rÅ   Úcache_kwargsÚcausal_maskrï   Úattn_outputÚattn_weightss                            r2   r}   zIdeficsAttention.forwardM  sÀ  € ð "×4Ñ4ÒTÐ8HÐPTÐ8TÐà%×*Ñ*Ó,‰ˆˆU�Aà—{‘{ =Ó1×6Ñ6°s¸EÀ4Ç>Á>ÐSW×S`ÑS`Óa×kÑkÐlmÐopÓqˆÙ!ØŸ™ ]Ó3×8Ñ8¸¸eÀTÇ^Á^ÐUY×UbÑUbÓc×mÑmÐnoÐqrÓsˆJØŸ;™; }Ó5×:Ñ:¸3ÀÀtÇ~Á~ÐW[×WdÑWdÓe×oÑoÐpqÐstÓu‰Là+×0Ñ0Ó2‰LˆAˆv�qØŸ™Ð%5Ó6×;Ñ;¸CÀÈÏÉÐY]×YfÑYfÓg×qÑqÐrsÐuvÓwˆJà—‘Ð,Ó-×2Ñ2°3¸ÀÇÁÐPT×P]ÑP]Ó^×hÑhÐijÐlmÓnð ð  ×%Ñ% bÑ)ˆ
ØÐ%Ø˜.¨Ñ+Ñ+ˆJá!Ø—‘ |¼SÀÈUÓ=S�ÓT‰HˆC�Ü';¸LÈ*ÐVYÐ[^Ð`lÓ'mÑ$ˆL˜*ð Ð%à,¨nÐ=ˆLØ'5×'<Ñ'<¸ZÈÐW[×WeÑWeÐgsÓ'tÑ$ˆJ˜à×ÒØ×,Ñ,¨\Ó:ˆLØ×*Ñ*¨:Ó6ˆJà$ˆØÐ%Ø%¢aªªAÐ/E°×1AÑ1AÀ"Ñ1EÐ/EÐ&EÑFˆKð ×Ñ×#Ñ# vÒ-°.Ð2LØ'×2Ñ2Ó4ˆLØ#×.Ñ.Ó0ˆJØ'×2Ñ2Ó4ˆLð
 !ŸNšN¨{Ð/BÀuÈqÂy‘DÐV[ˆ	ä—h‘h×)Ñ)×FÑFØØØØ!Ø&*§m¢m�d—l’l¸Øð Gó 
ˆð ×ÑÓ # t§~¡~°u¸d¿m¹mÐ!LÒLÜØ2°C¸¿¹ÈÐPT×P]ÑP]Ð3^Ð2_ð `Ø×$Ñ$Ó&Ð'ð)óð ð
 "×+Ñ+¨A¨qÓ1ˆØ!×)Ñ)¨#¨u°d×6FÑ6FÓGˆà—k‘k +Ó.ˆàˆÙÜ×ÑØpôð ˜L¨.Ð8Ð8r1   )r  FNFN©NNNNFFN)r)   r*   r+   r,   r•   r¹   r‚   r   r   rm   r-   r–   r  Ú
LongTensorr   r}   r„   r…   s   @r2   rã   rã   ø  sv  ø„ ÙGð Ø#(Ø#'Ø$Ø#'ñMWàðMWð ðMWð ð	MWð
 !ðMWð !ðMWð ðMWð ˜C‘=õMWð^e˜UŸ\™\ð e°Cð e¸có eð 48Ø15Ø37Ø8<Ø"'ØØ59ñW9à—|‘|ðW9ð # 5§<¡<Ñ0ðW9ð ! §¡Ñ.ð	W9ð
 ˜u×/Ñ/Ñ0ðW9ð !  u§|¡|Ñ!4Ñ5ðW9ð  ðW9ð ðW9ð ! ×!1Ñ!1Ñ2ðW9ð 
ˆu�|‰|˜X e§l¡lÑ3°X¸eÀEÇLÁLÑ>QÑ5RÐRÑ	S÷W9r1   rã   c                   óJ  ‡ — e Zd Zddedee   fˆ fd„Z	 	 	 	 	 	 ddej                  deej                     deej                     dee
ej                        dee   d	ee   d
eej                     de
ej                  ee
ej                  ej                  f      f   fd„Zˆ xZS )ÚIdeficsDecoderLayerrç   ré   c                 óÆ  •— t         ‰| �  «        |j                  | _        t        | j                  |j                  |j
                  ||¬«      | _        t        | j                  |j                  |j                  ¬«      | _
        t        |j                  |j                  ¬«      | _        t        |j                  |j                  ¬«      | _        |j
                  | _        y )N)r�   rä   rå   rç   ré   ©r�   rÙ   rÚ   rí   )rl   rm   r�   rã   Únum_attention_headsrå   Ú	self_attnrØ   rÙ   rÚ   Úmlpr˜   rú   Úinput_layernormÚpost_attention_layernorm©rq   rç   ré   rs   s      €r2   rm   zIdeficsDecoderLayer.__init__©  s³   ø€ Ü‰ÑÔØ!×-Ñ-ˆÔÜ)Ø×(Ñ(Ø×0Ñ0Ø—N‘NØØô
ˆŒô Ø×(Ñ(Ø$×6Ñ6Ø×(Ñ(ô
ˆŒô
  .¨f×.@Ñ.@Àf×FYÑFYÔZˆÔÜ(6°v×7IÑ7IÈv×ObÑObÔ(cˆÔ%Ø—~‘~ˆ�r1   r&   r>   rÒ   r  r  r  r  re   c           	      ó¾  — |}| j                  |«      }| j                  |||||||¬«      \  }}	}
t        j                  j	                  || j                  | j
                  ¬«      }||z   }|}| j                  |«      }| j                  |«      }t        j                  j	                  || j                  | j
                  ¬«      }||z   }|f}|r||	fz  }|r||
fz  }|S )a]  
        Args:
            hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
            attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative 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.
            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`).
            past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
        )r&   r>   rÒ   r  r  r  r  ©Úpr  )r)  r'  r
   ró   rå   r  r*  r(  )rq   r&   r>   rÒ   r  r  r  r  ÚresidualÚself_attn_weightsÚpresent_key_valueÚoutputss               r2   r}   zIdeficsDecoderLayer.forward¼  s  € ð0 !ˆà×,Ñ,¨]Ó;ˆð ?C¿n¹nØ'Ø)Ø%Ø)Ø/ØØ)ð ?Mó ?
Ñ;ˆÐ(Ð*;ô Ÿ™×-Ñ-¨m¸t¿|¹|ÐVZ×VcÑVcÐ-ÓdˆØ  =Ñ0ˆð !ˆØ×5Ñ5°mÓDˆØŸ™ Ó/ˆÜŸ™×-Ñ-¨m¸t¿|¹|ÐVZ×VcÑVcÐ-ÓdˆØ  =Ñ0ˆà Ð"ˆáØÐ)Ð+Ñ+ˆGáØÐ)Ð+Ñ+ˆGàˆr1   rS   )NNNFFN)r)   r*   r+   r   r   r•   rm   r-   r–   r!  r   r‚   r.   r}   r„   r…   s   @r2   r#  r#  ¨  så   ø„ ñ&˜}ð &¸À#¹õ &ð, 26Ø37Ø8<Ø,1Ø$)Ø59ñ8à—|‘|ð8ð ! §¡Ñ.ð8ð ˜u×/Ñ/Ñ0ð	8ð
 !  u§|¡|Ñ!4Ñ5ð8ð $ D™>ð8ð ˜D‘>ð8ð ! ×!1Ñ!1Ñ2ð8ð 
ˆu× Ñ  (¨5°×1BÑ1BÀE×DUÑDUÐ1UÑ+VÑ"WÐWÑ	X÷8r1   r#  c                   ój  ‡ — e Zd Zddedee   fˆ fd„Z	 	 	 	 	 	 	 ddej                  deej                     deej                     deej                     deej                     d	ee	   d
ee	   dee
ej                        de
ej                  ee
ej                  ej                  f      f   fd„Zˆ xZS )ÚIdeficsGatedCrossAttentionLayerrç   ré   c           	      óª	  •— t         ‰| �  «        |j                  | _        t        | j                  |j                  d|j
                  ||j                  |¬«      | _        t        | j                  |j                  |j                  ¬«      | _        t        |j                  |j                  ¬«      | _        t        |j                  |j                  ¬«      | _        |j
                  | _        t#        j$                  «       | _        t#        j$                  «       | _        |j*                  dk(  �r|j,                  dk(  rtt#        j.                  t1        j2                  dd| j                  «      «      | _        t#        j.                  t1        j2                  dd| j                  «      «      | _        �nþ|j,                  dk(  r\t#        j.                  t1        j2                  d«      «      | _        t#        j.                  t1        j2                  d«      «      | _        �n“t9        d	|j,                  › d
�«      ‚|j*                  dk(  �r|j,                  dk(  rtt#        j.                  t1        j:                  dd| j                  «      «      | _        t#        j.                  t1        j:                  dd| j                  «      «      | _        �nç|j,                  dk(  r\t#        j.                  t1        j:                  d«      «      | _        t#        j.                  t1        j:                  d«      «      | _        �n|t9        d	|j,                  › d
�«      ‚|j*                  dv �r;|j,                  dk(  r�t#        j.                  t1        j<                  d|j>                  dd| j                  f¬«      «      | _        t#        j.                  t1        j<                  d|j>                  dd| j                  f¬«      «      | _        n¶|j,                  dk(  rut#        j.                  t1        j<                  d|j>                  d¬«      «      | _        t#        j.                  t1        j<                  d|j>                  d¬«      «      | _        n2t9        d	|j,                  › d
�«      ‚tA        d|j*                  › d�«      ‚tC        | d«      rtC        | d«      st9        d«      ‚y )NT)r�   rä   ræ   rå   rç   rè   ré   r%  rí   ÚzerosÚvectorr   r¹   z Unknown value for `alpha_type` (ú)r›   >   ÚnormalÚrandomÚgaussianr  )r¤   Ústdr  zAlpha initialization scheme z not yet implemented!Úalpha_cross_attnÚalpha_densez+Alpha parameters not initialized correctly!)"rl   rm   r�   rã   r&  rå   rè   Ú
cross_attnrØ   rÙ   rÚ   r(  r˜   rú   r)  r*  rç   r
   ÚTanhÚact_cross_attnÚ	act_denseÚalpha_initializerÚ
alpha_typerš   r-   r6  r=  r>  rk   r›   r9  Úalphas_initializer_rangeÚNotImplementedErrorrò   r+  s      €r2   rm   z(IdeficsGatedCrossAttentionLayer.__init__ø  sª  ø€ Ü‰ÑÔØ!×-Ñ-ˆÔÜ*Ø×(Ñ(Ø×0Ñ0Ø#Ø—N‘NØØ!×0Ñ0Øô
ˆŒô Ø×(Ñ(Ø$×6Ñ6Ø×(Ñ(ô
ˆŒô
  .¨f×.@Ñ.@Àf×FYÑFYÔZˆÔÜ(6°v×7IÑ7IÈv×ObÑObÔ(cˆÔ%Ø—n‘nˆŒä Ÿg™g›iˆÔÜŸ™›ˆŒà×#Ñ# wÓ.Ø× Ñ  HÒ,Ü(*¯©´U·[±[ÀÀAÀt×GWÑGWÓ5XÓ(Y�Ô%Ü#%§<¡<´·±¸A¸qÀ$×BRÑBRÓ0SÓ#T�Ö Ø×"Ñ" gÒ-Ü(*¯©´U·[±[À³^Ó(D�Ô%Ü#%§<¡<´·±¸A³Ó#?�Ö ä Ð#CÀF×DUÑDUÐCVÐVWÐ!XÓYÐYà×%Ñ%¨Ó/Ø× Ñ  HÒ,Ü(*¯©´U·Z±ZÀÀ1Àd×FVÑFVÓ5WÓ(X�Ô%Ü#%§<¡<´·
±
¸1¸aÀ×AQÑAQÓ0RÓ#S�Ö Ø×"Ñ" gÒ-Ü(*¯©´U·Z±ZÀ³]Ó(C�Ô%Ü#%§<¡<´·
±
¸1³Ó#>�Ö ä Ð#CÀF×DUÑDUÐCVÐVWÐ!XÓYÐYà×%Ñ%Ð)IÒIØ× Ñ  HÒ,Ü(*¯©Ü—L‘L c¨v×/NÑ/NÐVWÐYZÐ\`×\lÑ\lÐUmÔnó)�Ô%ô $&§<¡<Ü—L‘L c¨v×/NÑ/NÐVWÐYZÐ\`×\lÑ\lÐUmÔnó$�Õ ð ×"Ñ" gÒ-Ü(*¯©Ü—L‘L c¨v×/NÑ/NÐVWÔYó)�Ô%ô $&§<¡<´·±À#È6×KjÑKjÐrsÔ0uÓ#v�Õ ä Ð#CÀF×DUÑDUÐCVÐVWÐ!XÓYÐYô &Ð(DÀV×E]ÑE]ÐD^Ð^sÐ&tÓuÐuä˜Ð0Ô1´g¸dÀMÔ6RÜÐJÓKÐKð 7Sr1   r&   r>   r(   r<   Úcross_attention_gater  r  r  re   c	                 ó´  — |€t        d«      ‚|€t        d«      ‚|�t        d«      ‚|}	| j                  |«      }| j                  ||||¬«      \  }}
}t        j
                  j                  || j                  | j                  ¬«      }|j                  |dk(  dd…dd…df   d«      }|	| j                  | j                  «      |z  z   }|}	| j                  |«      }| j                  |«      }t        j
                  j                  || j                  | j                  ¬«      }|	| j                  | j                  «      |z  z   }|f}|r||
fz  }|r||fz  }|S )	aí  
        Args:
            hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
            attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            image_attention_mask (`torch.FloatTensor`, *optional*): image attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            cross_attention_gate (`torch.FloatTensor`, *optional*):
                gate of size `(batch, seq_len)` used to zero-out cross-attention output for tokens attending no images.
            output_attentions (`bool`, *optional*):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
            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`).
            past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
        Nzt`image_hidden_states` is required for Idefics cross attention module which are visual features to be conditioned on.z‹`cross_attention_gate` is required for Idefics cross attention module to zero-out the cross-attention hidden_states attending to no images.zMPast key value states are not implemented for Idefics cross attention module.)r&   r  r>   r  r-  r   r  )rk   rF  r)  r?  r
   ró   rå   rç   r  Úmasked_fillrA  r=  r*  r(  rB  r>  )rq   r&   r>   r(   r<   rG  r  r  r  r/  r0  r1  r2  s                r2   r}   z'IdeficsGatedCrossAttentionLayer.forward:  s“  € ð8 Ð&Üð#óð ð
  Ð'Üð ^óð ð Ð%Ü%Ð&uÓvÐvà ˆà×,Ñ,¨]Ó;ˆð ?C¿o¹oØ'Ø0Ø/Ø/ð	 ?Nó ?
Ñ;ˆÐ(Ð*;ô Ÿ™×-Ñ-¨m¸t¿{¹{ÐUY×UbÑUbÐ-Ócˆà%×1Ñ1Ð3GÈ1Ñ3LÊaÒQRÐTXÈjÑ2YÐ[^Ó_ˆØ  4×#6Ñ#6°t×7LÑ7LÓ#MÐP]Ñ#]Ñ]ˆð !ˆØ×5Ñ5°mÓDˆØŸ™ Ó/ˆÜŸ™×-Ñ-¨m¸t¿{¹{ÐUY×UbÑUbÐ-ÓcˆØ  4§>¡>°$×2BÑ2BÓ#CÀmÑ#SÑSˆà Ð"ˆáØÐ)Ð+Ñ+ˆGáØÐ)Ð+Ñ+ˆGàˆr1   rS   r   )r)   r*   r+   r   r   r•   rm   r-   r–   r‚   r   r.   r}   r„   r…   s   @r2   r4  r4  ÷  s  ø„ ñ@L˜}ð @L¸À#¹õ @LðJ 26Ø6:Ø7;Ø7;Ø,1Ø$)Ø8<ñIà—|‘|ðIð ! §¡Ñ.ðIð & e§l¡lÑ3ð	Ið
 ' u§|¡|Ñ4ðIð ' u§|¡|Ñ4ðIð $ D™>ðIð ˜D‘>ðIð !  u§|¡|Ñ!4Ñ5ðIð 
ˆu× Ñ  (¨5°×1BÑ1BÀE×DUÑDUÐ1UÑ+VÑ"WÐWÑ	X÷Ir1   r4  aL  
    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 ([`IdeficsConfig`]):
            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.
zSThe bare LLaMA Model outputting raw hidden-states without any specific head on top.c                   ó2   — e Zd ZeZdZdZddgZdZdZ	dZ
d„ Zy)ÚIdeficsPreTrainedModelr\   Tr#  r4  Fc                 ó  — | 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 )Nr  )r¤   r<  )rç   Úinitializer_rangerT   r
   rP   ro   ÚdataÚnormal_r‹   Úzero_rQ   rj   )rq   rW   r<  s      r2   Ú_init_weightsz$IdeficsPreTrainedModel._init_weights¤  sÅ   € ð �k‰k×+Ñ+ˆÜ�fœbŸi™iÔ(Ø�M‰M×Ñ×&Ñ&¨C°SÐ&Ô9Ø�{‰{Ð&Ø—‘× Ñ ×&Ñ&Õ(ð 'ä˜¤§¡Ô-Ø�M‰M×Ñ×&Ñ&¨C°SÐ&Ô9Ø×!Ñ!Ð-Ø—‘×"Ñ" 6×#5Ñ#5Ñ6×<Ñ<Õ>ð .ð .r1   N)r)   r*   r+   r   Úconfig_classÚbase_model_prefixÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_supports_sdpaÚ_supports_cache_classÚ_supports_static_cacherQ  r0   r1   r2   rK  rK  —  s7   „ ð
 !€LØÐØ&*Ð#Ø.Ð0QÐRÐØ€NØ ÐØ"Ðó?r1   rK  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 `decoder_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 (`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)`) and 2 additional tensors of shape
            `(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.

            Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
            blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.

            If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
            don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
            `decoder_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Zdefˆ fd„Zd"d„Zg fd„Zg fd„Zd„ Z	d„ Z
 ee«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#d	eej                     d
eej                      deej                     deeej$                        deej$                     deej$                     deej$                     deej$                     deej                      dee   dee   dee   dee   dee   deej                     deeef   f d„«       Z	 d$d
ej                   dej                   dej                   dedef
d„Zed
ej                   dededej8                  dej:                  dej                   d efd!„«       Zˆ xZS )%ÚIdeficsModelzŸ
    Transformer decoder consisting of `config.num_hidden_layers` layers. Each layer is a [`IdeficsDecoderLayer`]

    Args:
        config: IdeficsConfig
    rç   c           	      ój  •— t         ‰| �  |«       || _        |j                  | _        |j
                  | _        t        |j
                  |j                  |j                  |j                  | j                  ¬«      | _
        |j                  j                  | _        |j                  | _        t        |j                  «      | _        |j                  r]|j                   }t#        ||j                  j$                  |j&                  |j(                  |j*                  |j,                  «      | _        t1        j2                  t5        |j6                  «      D �cg c]  }t9        ||¬«      ‘Œ c}«      | _        |j<                  | _        |j6                  | j<                  z  }t1        j2                  t5        |«      D �cg c]  }t?        ||¬«      ‘Œ c}«      | _         d| _!        tE        |j                  |jF                  ¬«      | _$        | jK                  «        | jM                  |«       y c c}w c c}w )N)rg   rn   rh   rd   rj   )ré   Frí   )'rl   rm   rç   Úpad_token_idrj   Ú
vocab_sizerc   Úadditional_vocab_sizer�   Úfreeze_text_layersÚembed_tokensrô   Ú
image_sizer   Úvision_modelÚuse_resamplerÚperceiver_configr   rì   Úresampler_depthÚresampler_n_headsÚresampler_head_dimÚresampler_n_latentsÚperceiver_resamplerr
   Ú
ModuleListÚrangeÚnum_hidden_layersr#  ÚlayersÚcross_layer_intervalr4  Úgated_cross_attn_layersÚgradient_checkpointingr˜   rú   ÚnormÚ	post_initÚfreeze_relevant_params)rq   rç   rd  ÚiÚnum_cross_layersrs   s        €r2   rm   zIdeficsModel.__init__  sÍ  ø€ Ü‰Ñ˜Ô ØˆŒØ!×.Ñ.ˆÔØ ×+Ñ+ˆŒä5Ø!×,Ñ,Ø&,×&BÑ&BØ ×,Ñ,Ø#×6Ñ6Ø×(Ñ(ô
ˆÔð !×.Ñ.×9Ñ9ˆŒØ#×1Ñ1ˆÔÜ4°V×5IÑ5IÓJˆÔð ×ÒØ%×6Ñ6ÐÜ'@ØØ×$Ñ$×.Ñ.Ø ×0Ñ0Ø ×2Ñ2Ø ×3Ñ3Ø ×4Ñ4ó(ˆDÔ$ô —m‘mÜ?DÀV×E]ÑE]Ó?^Ö_¸!Ô  °1Ö5Ò_ó
ˆŒð %+×$?Ñ$?ˆÔ!Ø!×3Ñ3°t×7PÑ7PÑPÐÜ')§}¡}ÜKPÐQaÓKbÖcÀaÔ,¨V¸qÖAÒcó(
ˆÔ$ð ',ˆÔ#ä" 6×#5Ñ#5¸6×;NÑ;NÔOˆŒ	ð 	�‰Ôà×#Ñ# FÕ+ùò `ùò ds   ÅH+Æ<H0c                 óÊ   — |€| j                   }|j                  r| j                  |j                  «       |j                  r"t	        | j
                  |j                  ¬«       y y ©N)r]   )rç   r_  Úfreeze_text_module_exceptionsÚfreeze_vision_layersra   rb  Úfreeze_vision_module_exceptions)rq   rç   s     r2   rs  z#IdeficsModel.freeze_relevant_params1  sQ   € Øˆ>Ø—[‘[ˆFà×$Ò$Ø×#Ñ# F×$HÑ$HÔIà×&Ò&Ü˜×*Ñ*¸f×>dÑ>dÖeð 'r1   c                 óX   — | j                   | j                  fD ]  }t        ||¬«       Œ y rw  )rm  rq  ra   )rq   r]   rW   s      r2   r_  zIdeficsModel.freeze_text_layers;  s+   € Ø—{‘{ D§I¡IÐ.ò 	FˆFÜ˜Ð3DÖEñ	Fr1   c                 ó2   — t        | j                  |¬«       y rw  )ra   rb  )rq   r]   s     r2   ry  z!IdeficsModel.freeze_vision_layers?  s   € Ü�T×&Ñ&Ð:KÖLr1   c                 ó   — | j                   S rS   ©r`  r€   s    r2   Úget_input_embeddingsz!IdeficsModel.get_input_embeddingsB  s   € Ø× Ñ Ð r1   c                 ó   — || _         y rS   r~  ©rq   Úvalues     r2   Úset_input_embeddingsz!IdeficsModel.set_input_embeddingsE  s
   € Ø!ˆÕr1   rG   r>   rÒ   r%   Úinputs_embedsr9   r:   r;   r<   r  r  Úoutput_hidden_statesÚinterpolate_pos_encodingÚreturn_dictr  re   c                 ó  — |�|j                   n|j                   }|�|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                  |«      }d}|
rIt        |t        «      s9d}|€t        «       }n*t        j                  |«      }t        j                  d«       |j                   \  }}}|�|j#                  «       nd}||z   }|€2t%        j&                  |||j                   d   z   |j                   ¬«      }|�F|€D|j)                  «       j+                  d	«      dz
  }|j-                  |dk(  d«       |d d …| d …f   }n|€|j/                  d«      }t1        |||fD �cg c]  }|d u ‘Œ c}«      d
k7  rt        d«      ‚|�~|j3                  | j4                  |¬«      }|j                   d d
 \  }} |j7                  «       j8                  ||z  g|j                   d
d  ¢­Ž }| j;                  ||¬«      j<                  }nJ|�H|j?                  «       \  }}}}|j3                  | j4                  |¬«      }|j9                  ||z  ||«      }| j                  j@                  rN|€4| jC                  «      }|j?                  d«      |j?                  d
«      }}n|j?                  «       \  }}}}|}n0|€#j?                  d«      |j?                  d
«      }}nt        d«      ‚|j9                  ||z  |«      }|	j?                  d«      }|	j/                  d	«      }	|	jE                  ddd|«      }	|	j9                  ||||z  «      }	|�C|j?                  «       \  }}}||f}|	€t%        jF                  ||¬«      }	| jI                  |	«      }	nd }	|	dk(  jK                  d	¬«      j3                  | j4                  ¬«      jM                  d¬«      j3                  |«      } |€2t%        jF                  ||ft$        jN                  |j                   ¬«      }| jQ                  |||||«      }|}!|rdnd }"|rdnd }#d }$tS        | jT                  «      D ]½  \  }%}&|r|"|!fz  }"d„ }'| j                  r[| j                  rOd }|
rt        j                  d«       d}
| jW                  |'|&|!|||||	| ||
|%| jX                  | jZ                  |«      }(n* |'|&|!|||||	| ||
|%| jX                  | jZ                  |¬«      }(|(d   }!|
r	|(|rd
nd   }$|sŒµ|#|(d   fz  }#Œ¿ | j]                  |!«      }!|r|"|!fz  }"|
r|$nd })|r|)j_                  «       })|j9                  ||||«      }|sta        d„ |!|)|"|#|fD «       «      S tc        |!|)|"|#|¬«      S c c}w )Nz:You must specify exactly one of input_ids or inputs_embedszX`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`.FTzÿWe detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class (https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)r   r   ©rD   r8   r    z_Exactly 1 of pixel_values, image_encoder_embeddings or perceiver_embeddings has to be not-None.)ri   rD   )r9   r†  zBIf `perceiver_embeddings` are passed, use_resampler should be Truer  r¾   r®   r0   c           
      ón   — |
|z  dk(  r||
|z     } ||||||||	d ¬«      }|d   } | ||||||	|¬«      }|S )Nr   )r>   r(   r<   rG  r  r  r  )r>   rÒ   r  r  r  r  r0   )Ú
main_blockr&   r>   rÒ   r  r(   r<   rG  r  r  ré   rn  ro  r  Úxblockr2  Úlayer_outputss                    r2   Úvblockz$IdeficsModel.forward.<locals>.vblockà  sv   € ð" Ð3Ñ3°qÒ8Ø4°YÐBVÑ5VÑW�FÙ$Ø%Ø'5Ø,?Ø-AØ-AØ*;Ø"+Ø'+ô	�Gð %,¨A¡J�Má *Ø!Ø#1Ø!-Ø#1Ø&7Ø'Ø#1ô!�ð %Ð$r1   zZ`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...)r>   rÒ   r  r(   r<   rG  r  r  ré   rn  ro  r  c              3   ó$   K  — | ]  }|�|–— Œ
 y ­wrS   r0   )rU   Úvs     r2   rX   z'IdeficsModel.forward.<locals>.<genexpr>I  s   è ø€ ò àØ�=ô ñùs   ‚)r$   r%   r&   r'   r(   )2rD   rç   r  r…  r  Úuse_return_dictrk   rp  r  rð   rñ   r`  rT   r   r   Úfrom_legacy_cacher@   Úget_seq_lengthr-   r?   ÚlongÚcumsumÚmasked_fill_rÏ   ÚsumrC   ri   r  rA   rb  r$   r  rc  ri  rB   r›   Úinvert_attention_maskrZ   Úsqueezer‚   Ú_update_causal_maskÚ	enumeraterm  Ú_gradient_checkpointing_funcrn  ro  rq  Úto_legacy_cacherª   r#   )*rq   rG   r>   rÒ   r%   r„  r9   r:   r;   r<   r  r  r…  r†  r‡  r  rD   Úreturn_legacy_cacheÚ
batch_sizeÚ
seq_lengthr  Úpast_key_values_lengthÚseq_length_with_pastrÉ   Ú
num_imagesr(   Úimage_seq_lenÚimage_hidden_sizeÚtext_seq_lenÚimage_batch_sizeÚimage_sequence_lengthÚimage_hidden_shaperG  r&   Úall_hidden_statesÚall_self_attnsÚnext_decoder_cacheÚidxÚdecoder_layerrŽ  r�  Ú
next_caches*                                             r2   r}   zIdeficsModel.forwardH  s  € ð& &/Ð%:�×!Ò!À×@TÑ@Tˆà1BÐ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Ó8ˆMð $ÐÙœZ¨¼Ô?Ø"&ÐØÐ&Ü".£.‘ä".×"@Ñ"@ÀÓ"Q�Ü×#Ñ#ð^ôð %2×$7Ñ$7Ñ!ˆ
�J ØETÐE` ×!?Ñ!?Ô!AÐfgÐØ)Ð,BÑBÐàÐ!Ü"Ÿ\™\Ø&Ð(>À×ATÑATÐUVÑAWÑ(WÐ`m×`tÑ`tôˆNð Ð%¨,Ð*>à)×.Ñ.Ó0×7Ñ7¸Ó;¸aÑ?ˆLØ×%Ñ% n¸Ñ&9¸1Ô=Ø'ª¨J¨;©<¨Ñ8‰LØÐ!Ø)×3Ñ3°AÓ6ˆLä LÐ2JÐL`Ð#aÖb˜a��T’	ÒbÓcÐghÒhÜØqóð ð Ð%Ø'Ÿ?™?°·±ÀF˜?ÓKˆLØ%1×%7Ñ%7¸¸Ð%;Ñ"ˆJ˜
Ø9˜<×2Ñ2Ó4×9Ñ9¸*ÀzÑ:QÐkÐT`×TfÑTfÐghÐgiÐTjÒkˆLð #'×"3Ñ"3Ø)ÐD\ð #4ó #çÑñ  ð &Ð1ØG_×GdÑGdÓGfÑDˆJ˜
 MÐ3DØ":×"=Ñ"=ÀDÇJÁJÐW]Ð"=Ó"^ÐØ"5×":Ñ":¸:È
Ñ;RÐTaÐctÓ"uÐà�;‰;×$Ò$Ø#Ð+Ø'+×'?Ñ'?Ð@SÓ'TÐ$Ø3G×3LÑ3LÈQÓ3OÐQe×QjÑQjÐklÓQmÐ0‘àK_×KdÑKdÓKfÑH�
˜J¨Ð7HØ"6ÑØ!Ð)Ø/B×/GÑ/GÈÓ/JÐL_×LdÑLdÐefÓLgÐ,‰MäÐaÓbÐbà1×6Ñ6°zÀ:ÐP]ÑC]Ð_pÓqÐð ,×0Ñ0°Ó3ˆØ3×=Ñ=¸bÓAÐØ3×:Ñ:¸1¸aÀÀMÓRÐØ3×8Ñ8¸À\ÐS]Ð`mÑSmÓnÐàÐ*Ø9L×9QÑ9QÓ9SÑ6ÐÐ3°QØ"2Ð4IÐ!JÐØ#Ð+Ü',§z¡zÐ2DÈVÔ'TÐ$Ø#'×#=Ñ#=Ð>RÓ#SÑ à#'Ð ð $8¸3Ñ#>×"CÑ"CÈÐ"CÓ"K×!OÑ!OÐVZ×V`ÑV`Ð!OÓ!a× jÑ jÐopÐ jÓ q×uÑuØó 
Ðð
 Ð!Ü"ŸZ™ZØÐ1Ð2¼%¿*¹*È]×MaÑMaôˆNð ×1Ñ1Ø˜M¨>¸?ÐL]ó
ˆð &ˆñ #7™B¸DÐÙ0™°dˆØ!Ðä"+¨D¯K©KÓ"8ò `	6ÑˆC�Ù#Ø! mÐ%5Ñ5Ð!ò)%ðV ×*Ò*¨t¯}ª}Ø"&�ÙÜ×'Ñ'Øtôð !&�Ià $× AÑ AØØ!Ø!Ø"Ø Ø#Ø'Ø(Ø(Ø%ØØØ×-Ñ-Ø×0Ñ0Ø"ó!‘ñ$ !'Ø!Ø!Ø#1Ø!-Ø#2Ø(;Ø)=Ø)=Ø&7Ø'Ø!Ø)-×)BÑ)BØ,0×,HÑ,HØ#1ô!�ð" *¨!Ñ,ˆMáØ%2Ñ8I±1ÈqÑ%QÐ"â Ø =°Ñ#3Ð"5Ñ5‘ðA`	6ðD Ÿ	™	 -Ó0ˆñ  Ø -Ð!1Ñ1Ðá+4Ñ'¸$ˆ
ÙØ#×3Ñ3Ó5ˆJØ1×6Ñ6°zÀ:È}Ð^oÓpÐÙÜñ à'¨Ð5FÈÐXkÐlôó ð ô
 .Ø+Ø&Ø+Ø%Ø 3ô
ð 	
ùò} cs   Ç,W=Úinput_tensorc           
      óÆ  — | j                   j                  dk(  r|�|dk(  j                  «       r|S y | j                   j                  dk(  r7t        |t        j
                  «      rt        |«      }t        |t        «      r|S |�|j                  «       nd}t        |t        «      }| j                   j                  dk(  r(|s&|s$t        j                  |||| j                  ¬«      ry |j                  |j                  }	}|j                  d   }
|r|j!                  «       }n1t        |t        j
                  «      r|j                  d   n||
z   dz   }| j#                  ||
|||	||j                  d   ¬	«      }| j                   j                  dk(  rQ|�O|j                  j$                  d
v r7|s5t	        j&                  |«      j(                  }t        j*                  ||«      }|S )NÚflash_attention_2r  Úflex_attentionr   Úsdpa)r„  r¡  Úis_trainingr   r8   )Úsequence_lengthÚtarget_lengthri   rD   r  rŸ  )r  Úxpu)rç   Ú_attn_implementationrZ   rT   r-   r–   r!   r    r“  r   r   Ú_ignore_causal_mask_sdpar  ri   rD   r@   Úget_max_cache_shapeÚ5_prepare_4d_causal_attention_mask_with_cache_positionr  ÚfinfoÚminÚ_unmask_unattended)rq   r>   r°  r  r%   r  Úpast_seen_tokensÚusing_static_cacheri   rD   r¶  r·  r  Ú	min_dtypes                 r2   rš  z IdeficsModel._update_causal_maskW  sÖ  € ð �;‰;×+Ñ+Ð/BÒBØÐ)¨~ÀÑ/D×.IÑ.IÔ.KØ%Ð%ØØ�;‰;×+Ñ+Ð/?Ò?Ü˜.¬%¯,©,Ô7Ü!<¸^Ó!L�Ü˜.¬)Ô4Ø%Ð%ð
 @OÐ?Z˜?×9Ñ9Ô;Ð`aÐÜ'¨¼ÓEÐð �;‰;×+Ñ+¨vÒ5Ñ>PÑYjÜ%×>Ñ>ØØ*Ø'7Ø ŸM™Mõ	ð à$×*Ñ*¨L×,?Ñ,?ˆvˆØ&×,Ñ,¨QÑ/ˆÙØ+×?Ñ?ÓA‰Mô ˜n¬e¯l©lÔ;ð ×$Ñ$ RÒ(à%¨Ñ7¸!Ñ;ð ð ×PÑPØØ+Ø'ØØØ)Ø#×)Ñ)¨!Ñ,ð Qó 
ˆð �K‰K×,Ñ,°Ò6ØÐ*Ø×%Ñ%×*Ñ*¨oÑ=Ù%ô
 Ÿ™ EÓ*×.Ñ.ˆIÜ0×CÑCÀKÐQZÓ[ˆKàÐr1   r¶  r·  ri   rD   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.
        Né   )Ú
fill_valueri   rD   r   )Údiagonalr‰  r8   r   )rµ   r-   r½  r¾  ÚfullÚtriur?   r  Úexpandrw   r@   rC   rD   rI  )r>   r¶  r·  ri   rD   r  rŸ  rr   r  rÂ  Úmask_lengthÚpadding_masks               r2   r¼  zBIdeficsModel._prepare_4d_causal_attention_mask_with_cache_position�  sy  € ðD Ð%¨.×*<Ñ*<Ó*>À!Ò*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ð Ðr1   rS   )NNNNNNNNNNNNFNN©F) r)   r*   r+   r,   r   rm   rs  r_  ry  r  rƒ  r   ÚLLAMA_INPUTS_DOCSTRINGr   r-   r!  r–   r   r.   r‚   r	   r   r#   r}   r   rš  Ústaticmethodr•   ri   rD   r¼  r„   r…   s   @r2   rZ  rZ  õ  sw  ø„ ñ
ð.,˜}õ .,ó`fð 46ó Fð 68ó Mò!ò"ñ +Ð+AÓBð 15Ø15Ø37Ø=AØ59Ø48Ø@DØ<@Ø7;Ø$(Ø,0Ø/3Ø38Ø&*Ø59ñ!K
à˜E×,Ñ,Ñ-ðK
ð ! §¡Ñ.ðK
ð ˜u×/Ñ/Ñ0ð	K
ð
 " $ u×'8Ñ'8Ñ"9Ñ:ðK
ð   × 1Ñ 1Ñ2ðK
ð ˜u×0Ñ0Ñ1ðK
ð #+¨5×+<Ñ+<Ñ"=ðK
ð ' u×'8Ñ'8Ñ9ðK
ð ' u§|¡|Ñ4ðK
ð ˜D‘>ðK
ð $ D™>ðK
ð ' t™nðK
ð #+¨4¡.ðK
ð ˜d‘^ðK
ð  ! ×!1Ñ!1Ñ2ð!K
ð" 
ˆuÐ4Ð4Ñ	5ò#K
ó CðK
ðh #(ñDàŸ™ðDð —l‘lðDð Ÿ™ð	Dð
 ðDð  óDðL ð7ØŸ™ð7àð7ð ð7ð �{‰{ð	7ð
 —‘ð7ð Ÿ™ð7ð ò7ó ô7r1   rZ  c            '       ó¤  ‡ — e Zd ZdgZddgZd$ˆ fd„	Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Z ee«       eee¬«      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%deej(                     deej*                     deej(                     deeej.                        deej.                     deej.                     deej.                     deej.                     deej*                     deej(                     dee   dee   dee   dee   dee   deej(                     deeef   f"d„«       «       Z	 	 	 	 	 	 	 	 	 d&ˆ fd„	Z	 d'ded eee f   d!edeee f   fˆ fd"„Z!e"d#„ «       Z#ˆ xZ$S )(ÚIdeficsForVisionText2Textzlm_head.weightzmodel.embed_tokens.weightc                 óÞ   •— t         ‰| �  |«       t        |«      | _        t	        |j
                  |j                  |j                  d|j                  ¬«      | _	        | j                  «        y )NF)rˆ   r‰   rŠ   r‹   rd   )rl   rm   rZ  r\   r‡   r�   r]  r^  Úfreeze_lm_headÚlm_headrr  )rq   rç   rb  rs   s      €r2   rm   z"IdeficsForVisionText2Text.__init__Ý  s[   ø€ Ü‰Ñ˜Ô Ü! &Ó)ˆŒ
ä-Ø×*Ñ*Ø×*Ñ*Ø$*×$@Ñ$@ØØ#×2Ñ2ô
ˆŒð 	�‰Õr1   c                 ó.   — | j                   j                  S rS   ©r\   r`  r€   s    r2   r  z.IdeficsForVisionText2Text.get_input_embeddingsì  s   € Ø�z‰z×&Ñ&Ð&r1   c                 ó&   — || j                   _        y rS   rÕ  r�  s     r2   rƒ  z.IdeficsForVisionText2Text.set_input_embeddingsï  s   € Ø"'ˆ�
‰
Õr1   c                 ó   — | j                   S rS   ©rÓ  r€   s    r2   Úget_output_embeddingsz/IdeficsForVisionText2Text.get_output_embeddingsò  s   € Ø�|‰|Ðr1   c                 ó   — || _         y rS   rØ  )rq   Únew_embeddingss     r2   Úset_output_embeddingsz/IdeficsForVisionText2Text.set_output_embeddingsõ  s	   € Ø%ˆ�r1   c                 ó   — || _         y rS   ©r\   )rq   Údecoders     r2   Úset_decoderz%IdeficsForVisionText2Text.set_decoderø  s	   € Øˆ�
r1   c                 ó   — | j                   S rS   rÞ  r€   s    r2   Úget_decoderz%IdeficsForVisionText2Text.get_decoderû  s   € Ø�z‰zÐr1   c                 óÞ  — | j                  «       }| j                  «       }t        | j                  dd«      r`|j                  |_        |j
                  dkD  r@|j                  |j
                  k(  sJ ‚|j                  j                  |j                  _        t        |d«      rJt        |d«      r=|j                  |_        t        |d«      rt        |d«      r|j
                  |_        yyyyy)	z©
        Overwrite `transformers.modeling_utils.PreTrainedModel.tie_weights` to handle the case of
        IdeficsDecoupledLinear and IdeficsDecoupledEmbedding.
        Útie_word_embeddingsTr   r‰   rg   rŠ   rn   N)rÙ  r  Úgetattrrç   ro   rn   rŠ   rp   r�   rò   rg   r‰   )rq   Úoutput_embeddingsÚinput_embeddingss      r2   Útie_weightsz%IdeficsForVisionText2Text.tie_weightsþ  sé   € ð
 !×6Ñ6Ó8ÐØ×4Ñ4Ó6Ðä�4—;‘;Ð 5°tÔ<Ø'7×'>Ñ'>ÐÔ$Ø×9Ñ9¸AÒ=Ø(×@Ñ@ÐDT×DnÑDnÒnÐnÐnØ9I×9^Ñ9^×9eÑ9eÐ!×/Ñ/Ô6äÐ$ nÔ5¼'ÐBRÐTdÔ:eØ-=×-LÑ-LÐÔ*ÜÐ(Ð*CÔDÌØ Ð"=ôJð =M×<fÑ<fÐ!Õ9ðJÐDð ;fÐ5r1   )Úoutput_typerR  rG   r>   rÒ   r%   r„  r9   r:   r;   r<   Úlabelsr  r  r…  r†  r‡  r  re   c                 ó´  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }| j	                  |||||||||	||||||¬«      }|d   }| j                  |«      }d}|
��|
j                  |j                  «      }
|�s|dd…|j                  d   dz
   d…f   j                  |j                  «      }|ddd…dd…f   |dk7     j                  «       }|
ddd…f   |dk7     j                  «       }n1|ddd…dd…f   j                  «       }|
ddd…f   j                  «       }t        «       } ||j                  d|j                  d«      «      |j                  d«      «      }|s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  |j                   |j"                  ¬«      S )a  
            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]`.

        Returns:

        Example:

        ```python
        >>> from transformers import AutoProcessor, IdeficsForVisionText2Text

        >>> model = IdeficsForVisionText2Text.from_pretrained("HuggingFaceM4/idefics-9b")
        >>> processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics-9b")

        >>> dogs_image_url_1 = "https://huggingface.co/datasets/hf-internal-testing/fixtures_nlvr2/raw/main/image1.jpeg"
        >>> dogs_image_url_2 = "https://huggingface.co/datasets/hf-internal-testing/fixtures_nlvr2/raw/main/image2.jpeg"

        >>> prompts = [
        ...     [
        ...         "User:",
        ...         dogs_image_url_1,
        ...         "Describe this image.\nAssistant: An image of two dogs.\n",
        ...         "User:",
        ...         dogs_image_url_2,
        ...         "Describe this image.\nAssistant:",
        ...     ]
        ... ]
        >>> inputs = processor(prompts, return_tensors="pt")
        >>> generate_ids = model.generate(**inputs, max_new_tokens=6)
        >>> processor.batch_decode(generate_ids, skip_special_tokens=True)
        ```N)rG   r>   rÒ   r%   r„  r9   r:   r;   r<   r  r  r…  r†  r‡  r  r   r   .r8   )r5   r6   r%   r&   r'   r(   )rç   r  r…  r‘  r\   rÓ  rC   rD   r@   r  r   rA   r  r4   r%   r&   r'   r(   )rq   rG   r>   rÒ   r%   r„  r9   r:   r;   r<   rê  r  r  r…  r†  r‡  r  r2  r&   r6   r5   Úshift_attention_maskÚshift_logitsÚshift_labelsÚloss_fctr’   s                             r2   r}   z!IdeficsForVisionText2Text.forward  s#  € ðn 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð —*‘*ØØ)Ø%Ø+Ø'Ø%Ø%=Ø!5Ø!5ØØ/Ø!5Ø%=Ø#Ø)ð ó 
ˆð$   ™
ˆØ—‘˜mÓ,ˆàˆØÑØ—Y‘Y˜vŸ}™}Ó-ˆFàÐ)ð (6²a¸6¿<¹<È¹?ÈQÑ;NÐ9OÑ9QÐ6QÑ'R×'UÑ'UÐV\×VcÑVcÓ'dÐ$Ø% c¨3¨B¨3² kÑ2Ð3GÈ1Ñ3LÑM×XÑXÓZ�Ø% c¨1©2 g™Ð/CÀqÑ/HÑI×TÑTÓV‘à% c¨3¨B¨3² kÑ2×=Ñ=Ó?�Ø% c¨1©2 g™×9Ñ9Ó;�ä'Ó)ˆHÙ˜L×-Ñ-¨b°,×2CÑ2CÀBÓ2GÓHÈ,×J[ÑJ[Ð\^ÓJ_Ó`ˆDáØ�Y ¨¨ Ñ,ˆFØ'+Ð'7�D�7˜VÑ#ÐC¸VÐCä,ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø '× ;Ñ ;ô
ð 	
r1   c                 ó  •— i }|�"| j                   j                  r||d<   n||d<   n||d<   |j                  dd«      |d<   t        ‰| �  |f||||||
|	dœ|¤|¤Ž}|	�#|€!|d   j
                  d   }|	d d …| d …f   |d	<   |S )
Nr;   r:   r9   r†  F)r%   r>   r„  r  rÒ   r  r<   rG   r   r<   )rç   rc  Úpoprl   Úprepare_inputs_for_generationr@   )rq   rG   r>   rÒ   r„  r%   r  r9   r(   r<   r  rr   Úimages_kwargsÚmodel_inputsr   rs   s                  €r2   rò  z7IdeficsForVisionText2Text.prepare_inputs_for_generation„  sÕ   ø€ ð  ˆØÐ*Ø�{‰{×(Ò(Ø8K�Ð4Ò5à<O�Ð8Ò9à,8ˆM˜.Ñ)Ø4:·J±JÐ?YÐ[`Ó4aˆÐ0Ñ1ä‘wÑ<Øð
à+Ø)Ø'Ø)Ø%ØØ!5ñ
ð ð
ð ñ
ˆð  Ð+°Ð0EØ% kÑ2×8Ñ8¸Ñ;ˆJØ3GÊÈJÈ;É<ÈÑ3XˆLÐ/Ñ0àÐr1   r2  rK   rI   c                 óú   •— t        ‰| �  |||fi |¤Ž}d|v rT|d   }|d d …dd d …f   j                  d«      }|j                  dd«      r||d<   nt	        j
                  ||gd¬«      |d<   |j                  |d<   |S )Nr<   r8   r   r  Tr¾   r(   )rl   Ú#_update_model_kwargs_for_generationrÏ   rF   r-   r‘   r(   )rq   r2  rK   rI   rr   r<   Ú	last_maskrs   s          €r2   rö  z=IdeficsForVisionText2Text._update_model_kwargs_for_generation±  sª   ø€ ô ‘wÑBØØØñ
ð ñ	
ˆð " \Ñ1Ø#/Ð0FÑ#GÐ Ø,ªQ°²A¨XÑ6×@Ñ@ÀÓCˆIØ×Ñ ¨TÔ2Ø7@�Ð3Ò4ä7<·y±yÐBVÐXaÐAbÐhiÔ7j�Ð3Ñ4ð /6×.IÑ.IˆÐ*Ñ+ØÐr1   c                 óJ   ‡— d}| D ]  }|t        ˆfd„|D «       «      fz  }Œ |S )Nr0   c              3   óB   •K  — | ]  }|j                  d ‰«      –— Œ y­w)r   N)rE   )rU   Ú
past_stateÚbeam_idxs     €r2   rX   z;IdeficsForVisionText2Text._reorder_cache.<locals>.<genexpr>Ï  s   øè ø€ Ò$gÈj Z×%<Ñ%<¸QÀ×%IÑ$gùs   ƒ)rª   )Úpastrû  Úreordered_pastÚ
layer_pasts    `  r2   Ú_reorder_cachez(IdeficsForVisionText2Text._reorder_cacheË  s8   ø€ àˆØò 	jˆJØœuÓ$gÐ\fÔ$gÓgÐiÑi‰Nð	jàÐr1   rS   )NNNNNNNNNNNNNFNN)	NNNNNNNNNrÌ  )%r)   r*   r+   Ú_keys_to_ignore_on_load_missingÚ_tied_weights_keysrm   r  rƒ  rÙ  rÜ  rà  râ  rè  r   rÍ  r   r4   Ú_CONFIG_FOR_DOCr   r-   r!  r–   r   r.   r‚   r	   r   r}   rò  r   r   rƒ   r   rö  rÎ  rÿ  r„   r…   s   @r2   rÐ  rÐ  Ù  sl  ø„ Ø'8Ð&9Ð#Ø5Ð7GÐHÐõò'ò(òò&òòògñ* +Ð+AÓBÙÐ+HÐWfÔgð 15Ø15Ø37Ø=AØ59Ø48Ø@DØ<@Ø7;Ø-1Ø$(Ø,0Ø/3Ø38Ø&*Ø59ñ#m
à˜E×,Ñ,Ñ-ðm
ð ! §¡Ñ.ðm
ð ˜u×/Ñ/Ñ0ð	m
ð
 " $ u×'8Ñ'8Ñ"9Ñ:ðm
ð   × 1Ñ 1Ñ2ðm
ð ˜u×0Ñ0Ñ1ðm
ð #+¨5×+<Ñ+<Ñ"=ðm
ð ' u×'8Ñ'8Ñ9ðm
ð ' u§|¡|Ñ4ðm
ð ˜×)Ñ)Ñ*ðm
ð ˜D‘>ðm
ð $ D™>ðm
ð ' t™nðm
ð #+¨4¡.ðm
ð  ˜d‘^ð!m
ð" ! ×!1Ñ!1Ñ2ð#m
ð$ 
ˆuÐ3Ð3Ñ	4ò%m
ó hó Cðm
ðd ØØØØØØ Ø!Øõ+ðb $)ñ	àðð ˜3 ˜8‘nðð !ð	ð 
ˆc�3ˆh‰õð4 ñó ôr1   rÐ  )rÐ  rZ  rK  )r   FNN)r   )Or,   Údataclassesr   Útypingr   r   r   r   r   r	   r-   Útorch.nn.functionalr
   ró   ru   Útorch.utils.checkpointÚtorch.nnr   Úactivationsr   Úcache_utilsr   r   r   Ú
generationr   Úmodeling_attn_mask_utilsr   Úmodeling_outputsr   Úmodeling_utilsr   r   Úpytorch_utilsr   Úutilsr   r   r   r   r   Úconfiguration_ideficsr   Ú	perceiverr   Úvisionr   Ú!torch.nn.attention.flex_attentionr    Úintegrations.flex_attentionr!   Ú
get_loggerr)   rð   r  r#   r4   rM   ra   rQ   rc   rP   r‡   ÚModuler˜   Úappendr¬   rÍ   rÖ   rØ   rã   r#  r4  ÚLLAMA_START_DOCSTRINGrK  rÍ  rZ  rÐ  Ú__all__r0   r1   r2   ú<module>r     s  ðñ( å !ß :× :ã ß Ð Û Ý Ý %å !ß ;Ñ ;Ý )Ý >Ý +ß ?Ý 1÷õ õ 1Ý 0Ý ,ñ  Ô!Ý;åJð 
ˆ×	Ñ	˜HÓ	%€à!€ð ô)C [ó )Có ð)CðX ô&C Kó &Có ð&CðV ØØØó*#ðZ +-ó ôk
 §¡ô k
ô\>
˜RŸY™Yô >
ôDJ�R—Y‘Yô Jð. Ð × Ñ ˜NÔ +ô$
�u—x‘x—‘ô $
òN(óô:P�—‘ô Pô$l9�r—y‘yô l9ô`L˜"Ÿ)™)ô Lô^L b§i¡iô Lð^Ð ñ" ØYØóô?˜_ó ?ó	ð?ð0?Ð ñD ØYØóô]Ð)ó ]ó	ð]ô@wÐ 6¸ô wòt R�r1   