§
    ‚Štj†ˆ  ã                   ó   — d dl mZ d dl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 ddlmZmZ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 ddlmZ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, ddl-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9 ddl:m;Z;m<Z<  e,j=        e>¦  «        Z? e*d¬¦  «        e G d„ de¦  «        ¦   «         ¦   «         Z@ e*d¬¦  «        e G d„ d e¦  «        ¦   «         ¦   «         ZA G d!„ d"ejB        ¦  «        ZC G d#„ d$ejB        ¦  «        ZD G d%„ d&e4¦  «        ZE G d'„ d(e3¦  «        ZF G d)„ d*e7¦  «        ZG G d+„ d,e¦  «        ZHe* G d-„ d.e%¦  «        ¦   «         ZI G d/„ d0eI¦  «        ZJ G d1„ d2e8¦  «        ZK G d3„ d4e;¦  «        ZL e*d5¬¦  «         G d6„ d7eIe¦  «        ¦   «         ZMg d8¢ZNdS )9é    )ÚCallable)Ú	dataclassN)Ústrict)ÚCrossEntropyLossé   )ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)ÚPreTrainedConfig)ÚGenerationMixin)Úcreate_bidirectional_maskÚcreate_causal_mask)ÚFlashAttentionKwargs)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPastÚ)BaseModelOutputWithPastAndCrossAttentionsÚSeq2SeqLMOutputÚSeq2SeqModelOutput)ÚRopeParameters)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚcan_return_tupleÚlogging)Úmerge_with_config_defaults)ÚOutputRecorderÚcapture_outputsé   )ÚGlmAttentionÚGlmRotaryEmbeddingÚapply_rotary_pos_emb)ÚLlamaDecoderLayerÚ
LlamaModelÚeager_attention_forward)ÚWhisperModelÚshift_tokens_rightzUsefulSensors/moonshine-tiny)Ú
checkpointc                   óÔ  ‡ — e Zd ZU dZdZdgZdddddœZd	Zee	d
<   dZ
ee	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d<   dZedz  e	d<   dZedz  e	d<   dZedz  e	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d<   dZee	d <   dZeez  dz  e	d!<   dZee	d"<   d#Z ee	d$<   d%Z!eez  e	d&<   dZ"edz  e	d'<   d(Z#ee$e         z  dz  e	d)<   dZ%edz  e	d*<   dZ&ee	d+<   ˆ fd,„Z'ˆ xZ(S )-ÚMoonshineConfiga‹	  
    encoder_num_key_value_heads (`int`, *optional*):
        This is the number of key_value heads that should be used to implement Grouped Query Attention. If
        `encoder_num_key_value_heads=encoder_num_attention_heads`, the model will use Multi Head Attention (MHA), if
        `encoder_num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
        converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
        by meanpooling all the original heads within that group. For more details, check out [this
        paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
        `num_attention_heads`.
    decoder_num_key_value_heads (`int`, *optional*):
        This is the number of key_value heads that should be used to implement Grouped Query Attention. If
        `decoder_num_key_value_heads=decoder_num_attention_heads`, the model will use Multi Head Attention (MHA), if
        `decoder_num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
        converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
        by meanpooling all the original heads within that group. For more details, check out [this
        paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to
        `decoder_num_attention_heads`.
    pad_head_dim_to_multiple_of (`int`, *optional*):
        Pad head dimension in encoder and decoder to the next multiple of this value. Necessary for using certain
        optimized attention implementations.
    encoder_hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
        The non-linear activation function (function or string) in the encoder.
    decoder_hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
        The non-linear activation function (function or string) in the decoder.

    Example:

    ```python
    >>> from transformers import MoonshineModel, MoonshineConfig

    >>> # Initializing a Moonshine style configuration
    >>> configuration = MoonshineConfig().from_pretrained("UsefulSensors/moonshine-tiny")

    >>> # Initializing a model from the configuration
    >>> model = MoonshineModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Ú	moonshineÚpast_key_valuesÚdecoder_num_key_value_headsÚdecoder_num_attention_headsÚdecoder_num_hidden_layersÚdecoder_hidden_act)Únum_key_value_headsÚnum_attention_headsÚnum_hidden_layersÚ
hidden_acti €  Ú
vocab_sizei   Úhidden_sizei€  Úintermediate_sizeé   Úencoder_num_hidden_layersé   Úencoder_num_attention_headsNÚencoder_num_key_value_headsÚpad_head_dim_to_multiple_ofÚgeluÚencoder_hidden_actÚsilui   Úmax_position_embeddingsg{®Gáz”?Úinitializer_rangeé   Údecoder_start_token_idTÚ	use_cacheÚrope_parametersÚis_encoder_decoderFÚattention_biasç        Úattention_dropoutÚbos_token_idr"   Úeos_token_idÚpad_token_idÚtie_word_embeddingsc                 ó²   •— | j         €| j        | _         | j        €| j        | _        |                     dd¦  «          t          ¦   «         j        di |¤Ž d S )NÚpartial_rotary_factorgÍÌÌÌÌÌì?© )r?   r>   r0   r1   Ú
setdefaultÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €úm/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/moonshine/modular_moonshine.pyrW   zMoonshineConfig.__post_init__€   se   ø€ ØÔ+Ð3Ø/3Ô/OˆDÔ,àÔ+Ð3Ø/3Ô/OˆDÔ,à×ÒÐ1°3Ñ7Ô7Ð7Ø�‰ŒÔÐ'Ð' Ð'Ð'Ð'Ð'Ð'ó    ))Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferenceÚattribute_mapr8   ÚintÚ__annotations__r9   r:   r<   r2   r>   r1   r?   r0   r@   rB   Ústrr3   rD   rE   ÚfloatrG   rH   ÚboolrI   r   ÚdictrJ   rK   rM   rN   rO   ÚlistrP   rQ   rW   Ú__classcell__©rZ   s   @r[   r-   r-   3   s.  ø€ € € € € € ð&ð &ðP €JØ#4Ð"5Ðà<Ø<Ø8Ø*ð	ð €Mð €J�ÐÐÑØ€K�ÐÐÑØ!Ð�sÐ!Ð!Ñ!Ø%&Ð˜sÐ&Ð&Ñ&Ø%&Ð˜sÐ&Ð&Ñ&Ø'(Ð Ð(Ð(Ñ(Ø'(Ð Ð(Ð(Ñ(Ø.2Ð  t¡Ð2Ð2Ñ2Ø.2Ð  t¡Ð2Ð2Ñ2Ø.2Ð  t¡Ð2Ð2Ñ2Ø$Ð˜Ð$Ð$Ñ$Ø$Ð˜Ð$Ð$Ñ$Ø#&Ð˜SÐ&Ð&Ñ&Ø#Ð�uÐ#Ð#Ñ#Ø"#Ð˜CÐ#Ð#Ñ#Ø€IˆtÐÐÑØ48€O�^ dÑ*¨TÑ1Ð8Ð8Ñ8Ø#Ð˜Ð#Ð#Ñ#Ø €N�DÐ Ð Ñ Ø%(Ð�u˜s‘{Ð(Ð(Ñ(Ø €L�#˜‘*Ð Ð Ñ Ø+,€L�#˜˜Sœ	‘/ DÑ(Ð,Ð,Ñ,Ø#€L�#˜‘*Ð#Ð#Ñ#Ø $Ð˜Ð$Ð$Ñ$ð(ð (ð (ð (ð (ð (ð (ð (ð (r\   r-   z™
    Extends [~modeling_outputs.BaseModelOutput] to include the output attention mask since sequence length is not preserved in the model's forward.
    )Úcustom_introc                   ó2   — e Zd ZU dZdZej        dz  ed<   dS )ÚMoonshineEncoderModelOutputa–  
    attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
        Mask to avoid performing attention on padding token indices after sequence compression. Returned because the
        sequence length may differ from the input sequence length. Mask values selected in `[0, 1]`:

        - 1 for tokens that are **not masked**,
        - 0 for tokens that are **masked**.
    NÚattention_mask)r]   r^   r_   r`   rp   ÚtorchÚTensorre   rT   r\   r[   ro   ro   ‹   s5   € € € € € € ðð ð +/€N�E”L 4Ñ'Ð.Ð.Ñ.Ð.Ð.r\   ro   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚMoonshineEncoderMLPc                 ó
  •— t          ¦   «                              ¦   «          || _        t          |         | _        t          j        |j        |j        ¦  «        | _	        t          j        |j        |j        ¦  «        | _
        d S ©N©rV   Ú__init__Úconfigr   Úactivation_fnÚnnÚLinearr9   r:   Úfc1Úfc2©rX   ry   r7   rZ   s      €r[   rx   zMoonshineEncoderMLP.__init__Ÿ   sc   ø€ Ý‰Œ×ÒÑÔÐØˆŒÝ# JÔ/ˆÔÝ”9˜VÔ/°Ô1IÑJÔJˆŒÝ”9˜VÔ5°vÔ7IÑJÔJˆŒˆˆr\   Úhidden_statesÚreturnc                 ó„   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|S rv   )r}   rz   r~   )rX   r€   s     r[   ÚforwardzMoonshineEncoderMLP.forward¦   s=   € ØŸš Ñ/Ô/ˆØ×*Ò*¨=Ñ9Ô9ˆØŸš Ñ/Ô/ˆØÐr\   ©r]   r^   r_   rx   rq   rr   rƒ   rk   rl   s   @r[   rt   rt   ž   sc   ø€ € € € € ðKð Kð Kð Kð Kð U¤\ð °e´lð ð ð ð ð ð ð ð r\   rt   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚMoonshineDecoderMLPc                 ó  •— t          ¦   «                              ¦   «          || _        t          |         | _        t          j        |j        |j        dz  ¦  «        | _	        t          j        |j        |j        ¦  «        | _
        d S )Nr"   rw   r   s      €r[   rx   zMoonshineDecoderMLP.__init__®   sh   ø€ Ý‰Œ×ÒÑÔÐØˆŒÝ# JÔ/ˆÔÝ”9˜VÔ/°Ô1IÈAÑ1MÑNÔNˆŒÝ”9˜VÔ5°vÔ7IÑJÔJˆŒˆˆr\   r€   r�   c                 ó¾   — |                       |¦  «        }|                     dd¬¦  «        \  }}|                      |¦  «        |z  }|                      |¦  «        }|S )Nr"   éÿÿÿÿ)Údim)r}   Úchunkrz   r~   )rX   r€   Úgates      r[   rƒ   zMoonshineDecoderMLP.forwardµ   s_   € ØŸš Ñ/Ô/ˆØ+×1Ò1°!¸Ð1Ñ<Ô<Ñˆ�tØ×*Ò*¨4Ñ0Ô0°=Ñ@ˆØŸš Ñ/Ô/ˆØÐr\   r„   rl   s   @r[   r†   r†   ­   sc   ø€ € € € € ðKð Kð Kð Kð Kð U¤\ð °e´lð ð ð ð ð ð ð ð r\   r†   c                   ó   — e Zd ZdS )ÚMoonshineRotaryEmbeddingN)r]   r^   r_   rT   r\   r[   rŽ   rŽ   ½   s   € € € € € Ø€Dr\   rŽ   c                   ó  ‡ — e Zd Zdededededef
ˆ fd„Z	 	 	 	 ddej        d	e	ej        ej        f         dz  d
ej        dz  de
dz  dej        dz  dee         de	ej        ej        dz  e	ej                 dz  f         fd„Zˆ xZS )ÚMoonshineAttentionry   Ú	layer_idxÚ	is_causalr5   r4   c                 óV  •— |                      ||dœ¦  «         t          ¦   «                              ||¦  «         || _        t	          |d|j        |j        z  ¦  «        | _        | j        j	        �0| j        j	        }|| j        |z   dz
  |z  z  }|| j        z
  | _
        d S d| _
        d S )N)r5   r4   Úhead_dimrF   r   )ÚupdaterV   rx   r’   Úgetattrr9   r5   r”   ry   r@   Úhead_dim_padding)	rX   ry   r‘   r’   r5   r4   Útarget_multipleÚtarget_head_dimrZ   s	           €r[   rx   zMoonshineAttention.__init__Â   s·   ø€ ð 	�ŠÐ.AÐZmÐnÐnÑoÔoÐoÝ‰Œ×Ò˜ Ñ+Ô+Ð+Ø"ˆŒÝ ¨
°FÔ4FÈ&ÔJdÑ4dÑeÔeˆŒð Œ;Ô2Ð>Ø"œkÔEˆOØ-°$´-À/Ñ2QÐTUÑ2UÐZiÑ1iÑjˆOØ$3°d´mÑ$CˆDÔ!Ð!Ð!à$%ˆDÔ!Ð!Ð!r\   Nr€   Úposition_embeddingsrp   r/   Úkey_value_statesrY   r�   c                 óN  — |j         d d…         \  }}|                      |¦  «                             ||| j        j        | j        ¦  «                             dd¦  «        }	|d u}
|�?|j                             | j	        ¦  «        }|
rd|j        | j	        <   |j
        }n|j        }|�|n|}|
r3|r1|r/|j        | j	                 j        }|j        | j	                 j        }n¿|                      |¦  «                             |d| j        j        | j        ¦  «                             dd¦  «        }|                      |¦  «                             |d| j        j        | j        ¦  «                             dd¦  «        }|
r!|�|                     ||| j	        ¦  «        \  }}|
s;|\  }}t%          |	|||¦  «        \  }	}|�|                     ||| j	        ¦  «        \  }}t'          j        | j        j        t,          ¦  «        }| j        o	|d u o|dk    }| j        dk    r„t2          j        j                             |	d| j        f¦  «        }	t2          j        j                             |d| j        f¦  «        }t2          j        j                             |d| j        f¦  «        } || |	|||f| j        sdn| j        | j        |dœ|¤Ž\  }}| j        dk    r|dd | j         …f         }|                      ||d¦  «         !                    ¦   «         }|  "                    |¦  «        }||fS )	Nr‰   rF   r"   Tr   rL   )ÚdropoutÚscalingr’   .)#ÚshapeÚq_projÚviewry   r4   r”   Ú	transposeÚ
is_updatedÚgetr‘   Úcross_attention_cacheÚself_attention_cacheÚlayersÚkeysÚvaluesÚk_projÚv_projr•   r%   r   Úget_interfaceÚ_attn_implementationr(   r’   r—   rq   r{   Ú
functionalÚpadÚtrainingrM   rž   ÚreshapeÚ
contiguousÚo_proj)rX   r€   rš   rp   r/   r›   rY   ÚbszÚq_lenÚquery_statesÚis_cross_attentionr£   Úcurrent_statesÚ
key_statesÚvalue_statesÚcosÚsinÚattention_interfacer’   Úattn_outputÚattn_weightss                        r[   rƒ   zMoonshineAttention.forward×   sm  € ð #Ô(¨¨"¨Ô-‰
ˆˆUð �KŠK˜Ñ&Ô&×+Ò+¨C°¸¼Ô8WÐY]ÔYfÑgÔg×qÒqÐrsÐuvÑwÔwð 	ð .°TÐ9ÐØÐ&Ø(Ô3×7Ò7¸¼ÑGÔGˆJØ!ð Gà=A�Ô*¨4¬>Ñ:Ø"1Ô"G��à"1Ô"F�ð .>Ð-IÐ)Ð)È}ˆØð 	l /ð 	l°jð 	lØ(Ô/°´Ô?ÔDˆJØ*Ô1°$´.ÔAÔHˆLˆLð —’˜NÑ+Ô+ß’�c˜2˜tœ{Ô>ÀÄÑNÔNß’˜1˜a‘”ð ð —’˜NÑ+Ô+ß’�c˜2˜tœ{Ô>ÀÄÑNÔNß’˜1˜a‘”ð ð
 "ð l oÐ&AØ+:×+AÒ+AÀ*ÈlÐ\`Ô\jÑ+kÔ+kÑ(�
˜Là!ð 	lØ*‰HˆC�Ý';¸LÈ*ÐVYÐ[^Ñ'_Ô'_Ñ$ˆL˜*àÐ*Ø+:×+AÒ+AÀ*ÈlÐ\`Ô\jÑ+kÔ+kÑ(�
˜Lå(?Ô(MØŒKÔ,Õ.Eñ)
ô )
Ðð ”NÐK ~¸Ð'=ÐKÀ%È!Â)ˆ	àÔ  1Ò$Ð$Ý œ8Ô.×2Ò2°<À!ÀTÔEZÐA[Ñ\Ô\ˆLÝœÔ,×0Ò0°¸aÀÔAVÐ=WÑXÔXˆJÝ œ8Ô.×2Ò2°<À!ÀTÔEZÐA[Ñ\Ô\ˆLà$7Ð$7ØØØØØð
%
ð  $œ}ÐH�C�C°$Ô2HØ”LØð
%
ð 
%
ð ð
%
ð 
%
Ñ!ˆ�\ð Ô  1Ò$Ð$Ø% cÐ+C¨dÔ.CÐ-CÐ+CÐ&CÔDˆKà!×)Ò)¨#¨u°bÑ9Ô9×DÒDÑFÔFˆØ—k’k +Ñ.Ô.ˆØ˜LÐ(Ð(r\   )NNNN)r]   r^   r_   r-   rd   rh   rx   rq   rr   Útupler	   r   r   rƒ   rk   rl   s   @r[   r�   r�   Á   s8  ø€ € € € € ð&àð&ð ð&ð ð	&ð
 !ð&ð !ð&ð &ð &ð &ð &ð &ð0 IMØ.2Ø(,Ø04ðO)ð O)à”|ðO)ð # 5¤<°´Ð#=Ô>ÀÑEðO)ð œ tÑ+ð	O)ð
  ™ðO)ð  œ,¨Ñ-ðO)ð Ð-Ô.ðO)ð 
ˆuŒ|˜Uœ\¨DÑ0°%¸¼Ô2EÈÑ2LÐLÔ	MðO)ð O)ð O)ð O)ð O)ð O)ð O)ð O)r\   r�   c                   ó(   ‡ — e Zd Zdedefˆ fd„Zˆ xZS )ÚMoonshineEncoderLayerry   r‘   c                 óF  •— t          ¦   «                              ||¦  «         t          ||d|j        |j        ¬¦  «        | _        t          ||j        ¦  «        | _        t          j
        |j        d¬¦  «        | _        t          j
        |j        d¬¦  «        | _        d S )NF©ry   r‘   r’   r5   r4   ©Úbias)rV   rx   r�   r>   r?   Ú	self_attnrt   rB   Úmlpr{   Ú	LayerNormr9   Úinput_layernormÚpost_attention_layernorm©rX   ry   r‘   rZ   s      €r[   rx   zMoonshineEncoderLayer.__init__*  s˜   ø€ Ý‰Œ×Ò˜ Ñ+Ô+Ð+å+ØØØØ &Ô BØ &Ô Bð
ñ 
ô 
ˆŒõ ' v¨vÔ/HÑIÔIˆŒÝ!œ|¨FÔ,>ÀUÐKÑKÔKˆÔÝ(*¬°VÔ5GÈeÐ(TÑ(TÔ(TˆÔ%Ð%Ð%r\   )r]   r^   r_   r-   rd   rx   rk   rl   s   @r[   rÂ   rÂ   )  sW   ø€ € € € € ðU˜ð U¸3ð Uð Uð Uð Uð Uð Uð Uð Uð Uð Ur\   rÂ   c                   ó†  ‡ — e Zd Zddededz  fˆ fd„Z	 	 	 	 	 	 	 	 	 ddej        dej        dz  dej        dz  d	ej        dz  d
ej        dz  dej        dz  de	dz  de
dz  deej        ej        f         dz  deej        ej        f         dz  dee         deej        eej        ej        f         dz  f         fd„Zˆ xZS )ÚMoonshineDecoderLayerNry   r‘   c                 óà  •— t          ¦   «                              ¦   «          |j        | _        t          ||d|j        |j        ¬¦  «        | _        t          ||d|j        |j        ¬¦  «        | _        t          ||j	        ¦  «        | _
        t          j        |j        d¬¦  «        | _        t          j        |j        d¬¦  «        | _        t          j        |j        d¬¦  «        | _        d S )NTrÄ   FrÅ   )rV   rx   r9   r�   r5   r4   rÇ   Úencoder_attnr†   r7   rÈ   r{   rÉ   rÊ   rË   Úfinal_layernormrÌ   s      €r[   rx   zMoonshineDecoderLayer.__init__;  sç   ø€ Ý‰Œ×ÒÑÔÐØ!Ô-ˆÔå+ØØØØ &Ô :Ø &Ô :ð
ñ 
ô 
ˆŒõ /ØØØØ &Ô :Ø &Ô :ð
ñ 
ô 
ˆÔõ ' v¨vÔ/@ÑAÔAˆŒÝ!œ|¨FÔ,>ÀUÐKÑKÔKˆÔÝ(*¬°VÔ5GÈeÐ(TÑ(TÔ(TˆÔ%Ý!œ|¨FÔ,>ÀUÐKÑKÔKˆÔÐÐr\   Fr€   rp   Úencoder_hidden_statesÚencoder_attention_maskÚposition_idsÚencoder_position_idsr/   rH   rš   Úencoder_position_embeddingsrY   r�   c           
      óD  — |}|                       |¦  «        } | j        d||||||	dœ|¤Ž\  }}||z   }|�9|}|                      |¦  «        }|                      |||||¬¦  «        \  }}||z   }|}|                      |¦  «        }|                      |¦  «        }||z   }|S )N)r€   rp   rÔ   r/   rH   rš   )r€   r›   rp   r/   rH   rT   )rÊ   rÇ   rË   rÐ   rÑ   rÈ   )rX   r€   rp   rÒ   rÓ   rÔ   rÕ   r/   rH   rš   rÖ   rY   ÚresidualÚ_s                 r[   rƒ   zMoonshineDecoderLayer.forwardS  s÷   € ð !ˆØ×,Ò,¨]Ñ;Ô;ˆà)˜4œ>ð 
Ø'Ø)Ø%Ø+ØØ 3ð
ð 
ð ð
ð 
Ñˆ�qð ! =Ñ0ˆà Ð,Ø$ˆHØ ×9Ò9¸-ÑHÔHˆMØ#×0Ò0Ø+Ø!6Ø5Ø /Ø#ð  1ñ  ô  ÑˆM˜1ð % }Ñ4ˆMà ˆØ×,Ò,¨]Ñ;Ô;ˆØŸš Ñ/Ô/ˆØ  =Ñ0ˆØÐr\   rv   )	NNNNNNFNN)r]   r^   r_   r-   rd   rx   rq   rr   Ú
LongTensorr	   rh   rÀ   r   r   ÚFloatTensorrƒ   rk   rl   s   @r[   rÎ   rÎ   :  s‡  ø€ € € € € ðLð L˜ð L¸3À¹:ð Lð Lð Lð Lð Lð Lð6 /3Ø59Ø6:Ø04Ø8<Ø(,Ø!&ØHLØPTð,ð ,à”|ð,ð œ tÑ+ð,ð  %œ|¨dÑ2ð	,ð
 !&¤¨tÑ 3ð,ð Ô&¨Ñ-ð,ð $Ô.°Ñ5ð,ð  ™ð,ð ˜$‘;ð,ð # 5¤<°´Ð#=Ô>ÀÑEð,ð &+¨5¬<¸¼Ð+EÔ%FÈÑ%Mð,ð Ð+Ô,ð,ð 
ˆuÔ  %¨Ô(9¸5Ô;LÐ(LÔ"MÐPTÑ"TÐTÔ	Uð,ð ,ð ,ð ,ð ,ð ,ð ,ð ,r\   rÎ   c                   óT   — e Zd ZU eed<   dZdZdZdZddgZ	dZ
dZdZdej        fd	„Zd
S )ÚMoonshinePreTrainedModelry   ÚmodelÚinput_valuesÚaudioTrÂ   rÎ   Úinput_lengthsc                 ó–   — t          |dz
  dz  dz   ¦  «        }t          |dz
  dz  dz   ¦  «        }t          |dz
  dz  dz   ¦  «        }|S )zH
        Computes the output length of the convolutional layers
        é   é@   rF   é   r   r"   )rd   )rX   rá   Úoutput_conv1_lengthÚoutput_conv2_lengthÚoutput_conv3_lengths        r[   Ú _get_feat_extract_output_lengthsz9MoonshinePreTrainedModel._get_feat_extract_output_lengths�  sc   € õ " =°3Ñ#6¸"Ñ"<¸qÑ"@ÑAÔAÐÝ!Ð#6¸Ñ#:¸aÑ"?À!Ñ"CÑDÔDÐÝ!Ð#6¸Ñ#:¸aÑ"?À!Ñ"CÑDÔDÐà"Ð"r\   N)r]   r^   r_   r-   re   Úbase_model_prefixÚmain_input_nameÚinput_modalitiesÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_supports_flash_attnÚ_supports_sdpaÚ_can_compile_fullgraphrq   rÚ   ré   rT   r\   r[   rÝ   rÝ   ‚  st   € € € € € € àÐÐÑØÐØ$€OØÐØ&*Ð#Ø0Ð2IÐJÐØÐØ€Nà!Ðð#¸eÔ>Nð #ð #ð #ð #ð #ð #r\   rÝ   c                   óÊ   ‡ — e Zd ZdZdZeedœZdefˆ fd„Z	de
j        fd„Zde
j        fd	„Zee	 ddej        dej        d
z  dee         deez  fd„¦   «         ¦   «         Zˆ xZS )ÚMoonshineEncoderz£
    Transformer encoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MoonshineEncoderLayer`]

    Args:
        config: MoonshineConfig
    rß   )Ú
attentionsr€   ry   c                 ó`  •‡— t          ¦   «                              ‰¦  «         ‰| _        ‰j        }t	          j        d|ddd¬¦  «        | _        t	          j        |d|z  dd¬	¦  «        | _        t	          j        d|z  |dd¬	¦  «        | _        t	          j	        d|d
¬¦  «        | _
        t	          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _        t	          j        |d¬¦  «        | _        t#          ‰¬¦  «        | _        d| _        |                      ¦   «          d S )NrF   rã   rä   F)Úkernel_sizeÚstriderÆ   r"   rå   r   )rö   r÷   gñhãˆµøä>)Ú
num_groupsÚnum_channelsÚepsc                 ó0   •— g | ]}t          ‰|¦  «        ‘ŒS rT   )rÂ   ©Ú.0Úidxry   s     €r[   ú
<listcomp>z-MoonshineEncoder.__init__.<locals>.<listcomp>´  s$   ø€ ÐcÐcÐc°CÕ" 6¨3Ñ/Ô/ÐcÐcÐcr\   rÅ   ©ry   )rV   rx   ry   r9   r{   ÚConv1dÚconv1Úconv2Úconv3Ú	GroupNormÚ	groupnormÚ
ModuleListÚranger<   r§   rÉ   Ú
layer_normrŽ   Ú
rotary_embÚgradient_checkpointingÚ	post_init)rX   ry   Ú	embed_dimrZ   s    ` €r[   rx   zMoonshineEncoder.__init__©  s  øø€ Ý‰Œ×Ò˜Ñ Ô Ð ØˆŒØÔ&ˆ	å”Y˜q )¸ÀRÈeÐTÑTÔTˆŒ
Ý”Y˜y¨!¨i©-ÀQÈqÐQÑQÔQˆŒ
Ý”Y˜q 9™}¨iÀQÈqÐQÑQÔQˆŒ
Ýœ°ÀÐPTÐUÑUÔUˆŒå”mØcÐcÐcÐc½5ÀÔAaÑ;bÔ;bÐcÑcÔcñ
ô 
ˆŒõ œ, y°uÐ=Ñ=Ô=ˆŒÝ2¸&ÐAÑAÔAˆŒØ&+ˆÔ#Ø�ŠÑÔÐÐÐr\   r�   c                 ó   — | j         S rv   ©r  ©rX   s    r[   Úget_input_embeddingsz%MoonshineEncoder.get_input_embeddings»  s
   € ØŒzÐr\   Úvaluec                 ó   — || _         d S rv   r  )rX   r  s     r[   Úset_input_embeddingsz%MoonshineEncoder.set_input_embeddings¾  s   € ØˆŒ
ˆ
ˆ
r\   Nrp   rY   c                 ó¦  — |                      d¦  «        }t          j                             |                      |¦  «        ¦  «        }|                      |¦  «        }t          j                             |                      |¦  «        ¦  «        }t          j                             |                      |¦  «        ¦  «        }| 	                    ddd¦  «        }d}|�;|  
                    |j        d         ¦  «        }d}|ddd|…f         dd|…f         }|}t          | j        |||¬¦  «        }t          j        d|j        d         |j        ¬	¦  «                              d¦  «        }|                      ||¬
¦  «        }	| j        D ]}
 |
|f|||	dœ|¤Ž}Œ|                      |¦  «        }t)          ||�|                     ¦   «         nd¬¦  «        S )a.  
        Args:
            input_values (`torch.FloatTensor` of shape `(batch_size, audio_length)`):
                Float values of the raw speech waveform. Raw speech waveform can be
                obtained by loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a
                `numpy.ndarray` or a `torch.Tensor`, *e.g.* via the torchcodec library (`pip install torchcodec`) or
                the soundfile library (`pip install soundfile`). To prepare the array into
                `input_values`, the [`AutoFeatureExtractor`] should be used for padding
                and conversion into a tensor of type `torch.FloatTensor`.
            attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
                Mask to avoid performing attention on padding indices in `input_values`. 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)
        rF   r   r"   Nr‰   i€  .©ry   Úinputs_embedsrp   rÒ   ©Údevice©rÔ   )rp   rÔ   rš   )Úlast_hidden_staterp   )Ú	unsqueezer{   r®   Útanhr  r  rA   r  r  Úpermuteré   rŸ   r   ry   rq   Úaranger  r
  r§   r	  ro   rd   )rX   rß   rp   rY   r€   Úoutput_attention_maskÚmask_lenÚdownsample_striderÔ   rš   Úencoder_layers              r[   rƒ   zMoonshineEncoder.forwardÁ  sô  € ð. $×-Ò-¨aÑ0Ô0ˆÝœ×*Ò*¨4¯:ª:°lÑ+CÔ+CÑDÔDˆØŸš }Ñ5Ô5ˆÝœ×*Ò*¨4¯:ª:°mÑ+DÔ+DÑEÔEˆÝœ×*Ò*¨4¯:ª:°mÑ+DÔ+DÑEÔEˆØ%×-Ò-¨a°°AÑ6Ô6ˆð !%ÐØÐ%Ø×<Ò<¸^Ô=QÐRTÔ=UÑVÔVˆHØ *ÐØ+¨CÐ1DÐ1DÐ3DÐ1DÐ,DÔEÀcÈ9ÈHÈ9ÀnÔUˆNØ$2Ð!å2Ø”;Ø'Ø)Ø"/ð	
ñ 
ô 
ˆõ ”| A }Ô':¸1Ô'=ÀmÔFZÐ[Ñ[Ô[×eÒeÐfgÑhÔhˆØ"Ÿošo¨mÈ,˜oÑWÔWÐà!œ[ð 	ð 	ˆMØ)˜MØðà-Ø)Ø$7ð	ð ð
 ðð ˆMˆMð Ÿš¨Ñ6Ô6ˆå*Ø+Ø:OÐ:[Ð0×4Ò4Ñ6Ô6Ð6Ðaeð
ñ 
ô 
ð 	
r\   rv   )r]   r^   r_   r`   rë   r�   rÂ   Ú_can_record_outputsr-   rx   r{   ÚModuler  r  r   r!   rq   rÛ   rr   r   r   rÀ   r   rƒ   rk   rl   s   @r[   ró   ró   ›  s  ø€ € € € € ðð ð %€Oà(Ø.ðð Ðð
˜ð ð ð ð ð ð ð$ b¤ið ð ð ð ð¨"¬)ð ð ð ð ð  Øð /3ð<
ð <
àÔ'ð<
ð œ tÑ+ð<
ð Ð+Ô,ð	<
ð
 
Ð(Ñ	(ð<
ð <
ð <
ñ „_ñ  Ôð<
ð <
ð <
ð <
ð <
r\   ró   c                   óD  ‡ — e Zd ZdZ eedd¬¦  «        e eedd¬¦  «        dœZdefˆ fd„Z	e
e	 	 	 	 	 	 	 	 ddej        d	z  d
ej        d	z  dej        d	z  ded	z  dej        d	z  ded	z  dej        d	z  dej        d	z  dee         deez  fd„¦   «         ¦   «         Zˆ xZS )ÚMoonshineDecoderÚ	input_idsrF   rÇ   )ÚindexÚ
layer_namerÐ   )rô   r€   Úcross_attentionsry   c                 óú   •‡— t          ¦   «                              ‰¦  «         t          j        ‰j        d¬¦  «        | _        t          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _	        d S )NFrÅ   c                 ó0   •— g | ]}t          ‰|¦  «        ‘ŒS rT   )rÎ   rü   s     €r[   rÿ   z-MoonshineDecoder.__init__.<locals>.<listcomp>  s$   ø€ Ð$sÐ$sÐ$sÈCÕ%:¸6À3Ñ%GÔ%GÐ$sÐ$sÐ$sr\   )
rV   rx   r{   rÉ   r9   Únormr  r  r6   r§   ©rX   ry   rZ   s    `€r[   rx   zMoonshineDecoder.__init__
  sl   øø€ Ý‰Œ×Ò˜Ñ Ô Ð Ý”L Ô!3¸%Ð@Ñ@Ô@ˆŒ	Ý”mÐ$sÐ$sÐ$sÐ$sÕSXÐY_ÔYqÑSrÔSrÐ$sÑ$sÔ$sÑtÔtˆŒˆˆr\   Nrp   rÔ   r/   r  rH   rÒ   rÓ   rY   r�   c	           
      ó¢  — |du |duz  rt          d¦  «        ‚|€|                      |¦  «        }|r8|€6t          t          | j        ¬¦  «        t          | j        ¬¦  «        ¦  «        }|€V|�|                     ¦   «         nd}
t          j        |j        d         |j	        ¬¦  «        |
z   }| 
                    d¦  «        }t          | j        ||||¬¦  «        }t          | j        |||¬¦  «        }|}|                      ||¬	¦  «        }| j        D ]} ||||f|||||d
œ|	¤Ž}Œ|                      |¦  «        }t!          ||r|nd¬¦  «        S )a¤  
        encoder_hidden_states (`torch.FloatTensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
            Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention
            of the decoder.
        encoder_attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on padding indices in `encoder_hidden_states`. 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)
        Nz:You must specify exactly one of input_ids or inputs_embedsr   r   rF   r  )ry   r  rp   r/   rÔ   r  r  )rÓ   rÔ   r/   rH   rš   )r  r/   )Ú
ValueErrorÚembed_tokensr   r
   ry   Úget_seq_lengthrq   r  rŸ   r  r  r   r   r
  r§   r.  r   )rX   r(  rp   rÔ   r/   r  rH   rÒ   rÓ   rY   Úpast_seen_tokensÚcausal_maskr€   rš   Údecoder_layers                  r[   rƒ   zMoonshineDecoder.forward  sË  € ð0 ˜Ð -°tÐ";Ñ<ð 	[ÝÐYÑZÔZÐZàÐ Ø ×-Ò-¨iÑ8Ô8ˆMàð 	v˜Ð0Ý1µ,ÀdÄkÐ2RÑ2RÔ2RÕT`ÐhlÔhsÐTtÑTtÔTtÑuÔuˆOàÐØCRÐC^˜×=Ò=Ñ?Ô?Ð?ÐdeÐÝ œ<¨Ô(;¸AÔ(>À}ÔG[Ð\Ñ\Ô\Ð_oÑoˆLØ'×1Ò1°!Ñ4Ô4ˆLå(Ø”;Ø'Ø)Ø+Ø%ð
ñ 
ô 
ˆõ ";Ø”;Ø'Ø1Ø"7ð	"
ñ "
ô "
Ðð &ˆØ"Ÿošo¨mÈ,˜oÑWÔWÐà!œ[ð 	ð 	ˆMØ)˜MØØØ%ð
ð (>Ø)Ø /Ø#Ø$7ð
ð 
ð ð
ð 
ˆMˆMð Ÿ	š	 -Ñ0Ô0ˆå8Ø+Ø/8ÐB˜O˜O¸dð
ñ 
ô 
ð 	
r\   )NNNNNNNN)r]   r^   r_   rë   r    r�   rÎ   r$  r-   rx   r   r!   rq   rÚ   rr   r	   rÛ   rh   r   r   rÀ   r   rƒ   rk   rl   s   @r[   r'  r'    sŒ  ø€ € € € € Ø!€Oà$�nÐ%7¸qÈ[ÐYÑYÔYØ.Ø*˜NÐ+=ÀQÐSaÐbÑbÔbðð Ððu˜ð uð uð uð uð uð uð
  Øð .2Ø.2Ø04Ø(,Ø26Ø!%Ø:>Ø6:ðG
ð G
àÔ# dÑ*ðG
ð œ tÑ+ðG
ð Ô&¨Ñ-ð	G
ð
  ™ðG
ð Ô(¨4Ñ/ðG
ð ˜$‘;ðG
ð  %Ô0°4Ñ7ðG
ð !&¤¨tÑ 3ðG
ð Ð+Ô,ðG
ð 
Ð(Ñ	(ðG
ð G
ð G
ñ „_ñ  ÔðG
ð G
ð G
ð G
ð G
r\   r'  c                   ó4  — e Zd Zd„ Zee	 	 	 	 	 	 	 	 	 ddej        dz  dej        dz  dej        dz  dej        dz  de	e	ej                          dz  de
dz  d	e	ej                 dz  d
e	ej                 dz  dedz  dee         defd„¦   «         ¦   «         ZdS )ÚMoonshineModelc                 ó    — t          d¦  «        ‚)NzNot needed for Moonshine)ÚAttributeErrorr  s    r[   Ú_mask_input_featuresz#MoonshineModel._mask_input_features\  s   € ÝÐ7Ñ8Ô8Ð8r\   Nrß   rp   Údecoder_input_idsÚdecoder_attention_maskÚencoder_outputsr/   Údecoder_inputs_embedsÚdecoder_position_idsrH   rY   r�   c
                 óä   — |€ | j         |fd|i|
¤Ž} | j        d|||j        |j        ||||	dœ|
¤Ž}t	          |j        |j        |j        |j        |j        |j        |j        |j        ¬¦  «        S )a
  
        input_values (`torch.FloatTensor` of shape `(batch_size, audio_length)`):
            Float values of the raw speech waveform. Raw speech waveform can be
            obtained by loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a
            `numpy.ndarray` or a `torch.Tensor`, *e.g.* via the torchcodec library (`pip install torchcodec`) or
            the soundfile library (`pip install soundfile`). To prepare the array into
            `input_values`, the [`AutoFeatureExtractor`] should be used for padding
            and conversion into a tensor of type `torch.FloatTensor`.
        decoder_position_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`):
            Indices of positions of each input sequence tokens in the position embeddings.
            Used to calculate the position embeddings up to `config.decoder_config.max_position_embeddings`

        Example:

        ```python
        >>> import torch
        >>> from transformers import AutoFeatureExtractor, MoonshineModel
        >>> from datasets import load_dataset

        >>> model = MoonshineModel.from_pretrained("UsefulSensors/moonshine-tiny")
        >>> feature_extractor = AutoFeatureExtractor.from_pretrained("UsefulSensors/moonshine-tiny")
        >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
        >>> inputs = feature_extractor(ds[0]["audio"]["array"], return_tensors="pt")
        >>> input_values = inputs.input_values
        >>> decoder_input_ids = torch.tensor([[1, 1]]) * model.config.decoder_start_token_id
        >>> last_hidden_state = model(input_values, decoder_input_ids=decoder_input_ids).last_hidden_state
        >>> list(last_hidden_state.shape)
        [1, 2, 288]
        ```
        Nrp   )r(  rp   rÒ   rÓ   r/   r  rÔ   rH   )r  r/   Údecoder_hidden_statesÚdecoder_attentionsr+  Úencoder_last_hidden_staterÒ   Úencoder_attentionsrT   )	ÚencoderÚdecoderr  rp   r   r/   r€   rô   r+  )rX   rß   rp   r<  r=  r>  r/   r?  r@  rH   rY   Údecoder_outputss               r[   rƒ   zMoonshineModel.forward_  s¾   € ðZ Ð"Ø/;¨t¬|¸LÐ/rÐ/rÐYgÐ/rÐkqÐ/rÐ/rˆOàEQÀTÄ\ð 
F
Ø'Ø1Ø"1Ô"CØ#2Ô#AØ+Ø/Ø-Øð
F
ð 
F
ð ð
F
ð 
F
ˆõ "Ø-Ô?Ø+Ô;Ø"1Ô"?Ø.Ô9Ø,Ô=Ø&5Ô&GØ"1Ô"?Ø.Ô9ð	
ñ 	
ô 	
ð 		
r\   )	NNNNNNNNN)r]   r^   r_   r;  r   r   rq   rÛ   rÚ   rÀ   r   rh   r   r   r   rƒ   rT   r\   r[   r8  r8  [  sI  € € € € € ð9ð 9ð 9ð Øð 26Ø26Ø59Ø:>ØBFØ6:ØAEØ?CØ!%ðC
ð C
àÔ'¨$Ñ.ðC
ð Ô(¨4Ñ/ðC
ð !Ô+¨dÑ2ð	C
ð
 !&Ô 0°4Ñ 7ðC
ð ˜u UÔ%6Ô7Ô8¸4Ñ?ðC
ð -¨tÑ3ðC
ð  % UÔ%6Ô7¸$Ñ>ðC
ð $ EÔ$4Ô5¸Ñ<ðC
ð ˜$‘;ðC
ð Ð+Ô,ðC
ð 
ðC
ð C
ð C
ñ „^ñ ÔðC
ð C
ð C
r\   r8  zj
    The Moonshine Model with a language modeling head. Can be used for automatic speech recognition.
    c                   ó„  ‡ — e Zd ZddiZdefˆ fd„Zd„ Zd„ Zdej	        fd„Z
ee	 	 	 	 	 	 	 	 	 	 dd
ej        d	z  dej        d	z  dej        d	z  dej        d	z  deeej                          d	z  ded	z  deej                 d	z  deej                 d	z  ded	z  dej        d	z  dee         defd„¦   «         ¦   «         Zˆ xZS )Ú!MoonshineForConditionalGenerationzproj_out.weightz!model.decoder.embed_tokens.weightry   c                 óæ   •— t          ¦   «                              |¦  «         t          |¦  «        | _        t	          j        |j        |j        d¬¦  «        | _        |  	                    ¦   «          d S )NFrÅ   )
rV   rx   r8  rÞ   r{   r|   r9   r8   Úproj_outr  r/  s     €r[   rx   z*MoonshineForConditionalGeneration.__init__¯  s`   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ý# FÑ+Ô+ˆŒ
Ýœ	 &Ô"4°fÔ6GÈeÐTÑTÔTˆŒð 	�ŠÑÔÐÐÐr\   c                 ó   — | j         S rv   ©rL  r  s    r[   Úget_output_embeddingsz7MoonshineForConditionalGeneration.get_output_embeddings·  s
   € ØŒ}Ðr\   c                 ó   — || _         d S rv   rN  )rX   Únew_embeddingss     r[   Úset_output_embeddingsz7MoonshineForConditionalGeneration.set_output_embeddingsº  s   € Ø&ˆŒˆˆr\   r�   c                 ó4   — | j                              ¦   «         S rv   )rÞ   r  r  s    r[   r  z6MoonshineForConditionalGeneration.get_input_embeddings½  s   € ØŒz×.Ò.Ñ0Ô0Ð0r\   Nrß   rp   r<  r=  r>  r/   r?  r@  rH   ÚlabelsrY   c                 óÎ  — |
�)|€'|€%t          |
| j        j        | j        j        ¦  «        } | j        |f||||||||	dœ|¤Ž}|                      |j        ¦  «        }d}|
�Kt          ¦   «         } ||                     d| j        j	        ¦  «        |
                     d¦  «        ¦  «        }t          |||j        |j        |j        |j        |j        |j        |j        ¬¦	  «	        S )a0  
        input_values (`torch.FloatTensor` of shape `(batch_size, audio_length)`):
            Float values of the raw speech waveform. Raw speech waveform can be
            obtained by loading a `.flac` or `.wav` audio file into an array of type `list[float]`, a
            `numpy.ndarray` or a `torch.Tensor`, *e.g.* via the torchcodec library (`pip install torchcodec`) or
            the soundfile library (`pip install soundfile`). To prepare the array into
            `input_values`, the [`AutoFeatureExtractor`] should be used for padding
            and conversion into a tensor of type `torch.FloatTensor`.
        decoder_position_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`):
            Indices of positions of each input sequence tokens in the position embeddings.
            Used to calculate the position embeddings up to `config.decoder_config.max_position_embeddings`

        Example:

        ```python
        >>> import torch
        >>> from transformers import AutoProcessor, MoonshineForConditionalGeneration
        >>> from datasets import load_dataset

        >>> processor = AutoProcessor.from_pretrained("UsefulSensors/moonshine-tiny")
        >>> model = MoonshineForConditionalGeneration.from_pretrained("UsefulSensors/moonshine-tiny")

        >>> ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")

        >>> inputs = processor(ds[0]["audio"]["array"], return_tensors="pt")
        >>> input_values = inputs.input_values

        >>> generated_ids = model.generate(input_values, max_new_tokens=100)

        >>> transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
        >>> transcription
        'Mr. Quilter is the apostle of the middle classes, and we are glad to welcome his gospel.'
        ```N)rp   r<  r>  r=  r/   r?  r@  rH   r‰   )	ÚlossÚlogitsr/   rB  rC  r+  rD  rÒ   rE  )r*   ry   rP   rG   rÞ   rL  r  r   r±   r8   r   r/   rB  rC  r+  rD  rÒ   rE  )rX   rß   rp   r<  r=  r>  r/   r?  r@  rH   rT  rY   ÚoutputsrW  rV  Úloss_fcts                   r[   rƒ   z)MoonshineForConditionalGeneration.forwardÀ  s   € ðd ÐØ Ð(Ð-BÐ-JÝ$6Ø˜DœKÔ4°d´kÔ6Xñ%ô %Ð!ð '1 d¤jØð'
à)Ø/Ø+Ø#9Ø+Ø"7Ø!5Øð'
ð '
ð ð'
ð '
ˆð —’˜wÔ8Ñ9Ô9ˆàˆØÐÝ'Ñ)Ô)ˆHØ�8˜FŸNšN¨2¨t¬{Ô/EÑFÔFÈÏÊÐWYÑHZÔHZÑ[Ô[ˆDåØØØ#Ô3Ø")Ô"?Ø&Ô9Ø$Ô5Ø&-Ô&GØ")Ô"?Ø&Ô9ð

ñ 

ô 

ð 
	
r\   )
NNNNNNNNNN)r]   r^   r_   Ú_tied_weights_keysr-   rx   rO  rR  r{   r%  r  r   r   rq   rÛ   rÚ   rÀ   r   rh   r   r   r   rƒ   rk   rl   s   @r[   rJ  rJ  §  sË  ø€ € € € € ð ,Ð-PÐQÐð˜ð ð ð ð ð ð ðð ð ð'ð 'ð 'ð1 b¤ið 1ð 1ð 1ð 1ð Øð 26Ø26Ø59Ø:>ØBFØ6:ØAEØ?CØ!%Ø*.ðS
ð S
àÔ'¨$Ñ.ðS
ð Ô(¨4Ñ/ðS
ð !Ô+¨dÑ2ð	S
ð
 !&Ô 0°4Ñ 7ðS
ð ˜u UÔ%6Ô7Ô8¸4Ñ?ðS
ð -¨tÑ3ðS
ð  % UÔ%6Ô7¸$Ñ>ðS
ð $ EÔ$4Ô5¸Ñ<ðS
ð ˜$‘;ðS
ð Ô  4Ñ'ðS
ð Ð+Ô,ðS
ð 
ðS
ð S
ð S
ñ „^ñ ÔðS
ð S
ð S
ð S
ð S
r\   rJ  )r-   r8  rÝ   rJ  )OÚcollections.abcr   Údataclassesr   rq   Útorch.nnr{   Úhuggingface_hub.dataclassesr   r   Úactivationsr   Úcache_utilsr	   r
   r   Úconfiguration_utilsr   Ú
generationr   Úmasking_utilsr   r   Úmodeling_flash_attention_utilsr   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   r   Úmodeling_rope_utilsr   Úmodeling_utilsr   r   Úprocessing_utilsr   Úutilsr   r   r   r   Úutils.genericr   Úutils.output_capturingr    r!   Úglm.modeling_glmr#   r$   r%   Úllama.modeling_llamar&   r'   r(   Úwhisper.modeling_whisperr)   r*   Ú
get_loggerr]   Úloggerr-   ro   r%  rt   r†   rŽ   r�   rÂ   rÎ   rÝ   ró   r'  r8  rJ  Ú__all__rT   r\   r[   ú<module>rs     sE  ðð %Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !à €€€Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ø %Ð %Ð %Ð %Ð %Ð %à !Ð !Ð !Ð !Ð !Ð !Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø )Ð )Ð )Ð )Ð )Ð )Ø JÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ BÐ BÐ BÐ BÐ BÐ BØ 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 2Ð 1Ð 1Ð 1Ð 1Ð 1Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ &Ð &Ð &Ð &Ð &Ð &Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ UÐ UÐ UÐ UÐ UÐ UÐ UÐ UÐ UÐ UØ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YÐ YØ GÐ GÐ GÐ GÐ GÐ GÐ GÐ Gð 
ˆÔ	˜HÑ	%Ô	%€ð €Ð9Ð:Ñ:Ô:ØðS(ð S(ð S(ð S(ð S(Ð&ñ S(ô S(ñ „ñ ;Ô:ðS(ðl €ððñ ô ð
 ð
/ð 
/ð 
/ð 
/ð 
/ /ñ 
/ô 
/ñ „ñô ð
/ðð ð ð ð ˜"œ)ñ ô ð ðð ð ð ð ˜"œ)ñ ô ð ð 	ð 	ð 	ð 	ð 	Ð1ñ 	ô 	ð 	ðe)ð e)ð e)ð e)ð e)˜ñ e)ô e)ð e)ðPUð Uð Uð Uð UÐ-ñ Uô Uð Uð"Eð Eð Eð Eð EÐ6ñ Eô Eð EðP ð#ð #ð #ð #ð #˜ñ #ô #ñ „ð#ð0d
ð d
ð d
ð d
ð d
Ð/ñ d
ô d
ð d
ðNV
ð V
ð V
ð V
ð V
�zñ V
ô V
ð V
ðrI
ð I
ð I
ð I
ð I
�\ñ I
ô I
ð I
ðX €ððñ ô ð
i
ð i
ð i
ð i
ð i
Ð(@À/ñ i
ô i
ñô ð
i
ðXð ð €€€r\   