Ë
    ÜÓ^j–D  ã                   ó  — 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 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mZ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&m'Z' ddl(m)Z)  ejT                  e+«      Z, e«       rd dlZ ed¬«      e G d„ de«      «       «       Z-e G d„ de%«      «       Z.d„ Z/d„ Z0 G d„ de)«      Z1 G d„ de#«      Z2e G d „ d!e"«      «       Z3 G d"„ d#e!«      Z4 ed$¬%«       G d&„ d'e «      «       Z5g d(¢Z6y))é    )Ú	dataclass)Úpi)Ústrict)ÚTensorÚbroadcast_tensorsé   )Úinitialization)ÚCache)ÚPreTrainedConfig)ÚBaseModelOutputWithPooling)ÚPreTrainedModel)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚcan_return_tupleÚis_torch_availableÚloggingÚtorch_compilable_checké   )ÚAudioFlamingo3Config)Ú&AudioFlamingo3ForConditionalGenerationÚAudioFlamingo3ModelÚ!AudioFlamingo3ModelOutputWithPastÚAudioFlamingo3PreTrainedModel)ÚAudioFlamingo3Processor)ÚCONFIG_MAPPING)ÚMoonshineRotaryEmbeddingNznvidia/music-flamingo-2601-hf)Ú
checkpointc                   óV   — e Zd ZU dZdZeed<   dZeed<   dZe	ed<   dZ
edz  ed	<   d
„ Zy)ÚMusicFlamingoConfiga…  
    audio_bos_token_id (`int`, *optional*, defaults to 151670):
        The beginning-of-audio token index used to mark the start of audio spans.
    audio_eos_token_id (`int`, *optional*, defaults to 151671):
        The end-of-audio token index used to mark the end of audio spans.
    audio_frame_step (`float`, *optional*, defaults to 0.01):
        Duration in seconds of one input mel frame (trained with hop_length 160 at sampling_rate 16000).

    Example:

    ```python
    >>> from transformers import MusicFlamingoForConditionalGeneration, MusicFlamingoConfig, AudioFlamingo3EncoderConfig, Qwen2Config

    >>> # Initializing an MusicFlamingoEncoder config
    >>> audio_config = AudioFlamingo3EncoderConfig()

    >>> # Initializing a Qwen2 config
    >>> text_config = Qwen2Config()

    >>> # Initializing an MusicFlamingo configuration
    >>> configuration = MusicFlamingoConfig(audio_config, text_config)

    >>> # Initializing a model from the musicflamingo style configuration
    >>> model = MusicFlamingoForConditionalGeneration(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ivP Úaudio_bos_token_idiwP Úaudio_eos_token_idg{®Gáz„?Úaudio_frame_stepNÚrope_parametersc                 óÚ  — | j                   €ddddœ| _         t        | j                  t        «      rK| j                  d   dv rd| j                  d<   t	        | j                  d      d
i | j                  ¤Ž| _        n| j                  €t	        d   «       | _        t        | j
                  t        «      rT| j
                  j                  dd«      | j
                  d<   t	        | j
                  d      d
i | j
                  ¤Ž| _        n| j
                  €t	        d   «       | _        | j                   d	   | _        | j                  j                  | _	        t        j                  | fi |¤Ž y )NÚdefaultg     À’@gš™™™™™É?)Ú	rope_typeÚ
rope_thetaÚpartial_rotary_factorÚ
model_type)NÚmusicflamingo_encoderÚaudioflamingo3_encoderÚqwen2r(   © )r$   Ú
isinstanceÚaudio_configÚdictr   Útext_configÚgetÚmax_position_embeddingsÚhidden_sizeÚhead_dimr   Ú__post_init__)ÚselfÚkwargss     ú‚/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/musicflamingo/modular_musicflamingo.pyr7   z!MusicFlamingoConfig.__post_init__\   sK  € Ø×ÑÐ'à&Ø$Ø),ñ$ˆDÔ ô
 �d×'Ñ'¬Ô.Ø× Ñ  Ñ.Ð2QÑQØ2J�×!Ñ! ,Ñ/ä .¨t×/@Ñ/@ÀÑ/NÑ OÑ dÐRV×RcÑRcÑ dˆDÕØ×ÑÐ&Ü .Ð/GÑ HÓ JˆDÔä�d×&Ñ&¬Ô-Ø-1×-=Ñ-=×-AÑ-AÀ,ÐPWÓ-XˆD×Ñ˜\Ñ*Ü-¨d×.>Ñ.>¸|Ñ.LÑMÑaÐPT×P`ÑP`ÑaˆDÕØ×ÑÐ%Ü-¨gÑ6Ó8ˆDÔà'+×';Ñ';¸LÑ'IˆÔ$Ø×)Ñ)×5Ñ5ˆŒÜ×&Ñ& tÑ6¨vÓ6ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   ÚintÚ__annotations__r"   r#   Úfloatr$   r1   r7   r.   r;   r:   r    r    7   s=   … ñð: %Ð˜Ó$Ø$Ð˜Ó$Ø"Ð�eÓ"Ø#'€O�T˜D‘[Ó'ó7r;   r    c                   óv   ‡ — e Zd Z	 	 	 	 	 dˆ fd„	Zdededefd„Zed„ «       Z	ed„ «       Z
d„ Zd	„ Zd
„ Zd„ Zˆ xZS )ÚMusicFlamingoProcessorc                 ó¦   •— t         ‰| �  |||||¬«       | `|| _        || _        |j                  |«      | _        |j                  |«      | _        y)as  
        audio_token (`Optional[str]`, *optional*, defaults to `"<sound>"`):
            Special token used to represent audio inputs in the chat template.
        audio_bos_token (`Optional[str]`, *optional*, defaults to `"<|sound_bos|>"`):
            Special token used to represent the beginning of audio.
        audio_eos_token (`Optional[str]`, *optional*, defaults to `"<|sound_eos|>"`):
            Special token used to represent the end of audio.
        max_audio_len (`int`, *optional*, defaults to 1200):
            Maximum length of audio sequences in seconds. Audio longer than this will be truncated.
        )Úchat_templateÚaudio_tokenÚmax_audio_lenN)ÚsuperÚ__init__Údefault_transcription_promptÚaudio_bos_tokenÚaudio_eos_tokenÚconvert_tokens_to_idsr!   r"   )	r8   Úfeature_extractorÚ	tokenizerrF   rG   rL   rM   rH   Ú	__class__s	           €r:   rJ   zMusicFlamingoProcessor.__init__x   sd   ø€ ô( 	‰ÑØØØ'Ø#Ø'ð 	ô 	
ð Ð-Ø.ˆÔØ.ˆÔØ"+×"AÑ"AÀ/Ó"RˆÔØ"+×"AÑ"AÀ/Ó"RˆÕr;   Úaudio_inputsÚ	audio_idxÚreturnc                 ód   — |d   |   }| j                   | j                  |z  z   | j                  z   S )NÚnum_audio_tokens)rL   rG   rM   )r8   rR   rS   rV   s       r:   Úreplace_audio_tokenz*MusicFlamingoProcessor.replace_audio_token™   s;   € Ø'Ð(:Ñ;¸IÑFÐØ×#Ñ# d×&6Ñ&6Ð9IÑ&IÑIÈD×L`ÑL`Ñ`Ð`r;   c                 óH   — | j                   | j                  | j                  gS ©N)Úaudio_token_idr!   r"   ©r8   s    r:   Úaudio_token_idsz&MusicFlamingoProcessor.audio_token_ids�   s!   € à×#Ñ# T×%<Ñ%<¸d×>UÑ>UÐVÐVr;   c                 óD   — t         j                  d«       | j                  S )zLDeprecated alias for `audio_token_ids`; will be removed in a future release.z@`audio_ids` is deprecated; please use `audio_token_ids` instead.)ÚloggerÚwarning_oncer\   r[   s    r:   Ú	audio_idsz MusicFlamingoProcessor.audio_ids¢   s   € ô 	×ÑÐ^Ô_Ø×#Ñ#Ð#r;   c                 ó   — t        d«      ‚©Nz/This method is not supported for MusicFlamingo.©ÚNotImplementedError©r8   Úargsr9   s      r:   Úapply_transcription_requestz2MusicFlamingoProcessor.apply_transcription_request¨   ó   € Ü!Ð"SÓTÐTr;   c                 ó   — t        d«      ‚©Nz5MusicFlamingo does not need to overwrite this method.rc   re   s      r:   ÚdecodezMusicFlamingoProcessor.decode«   ó   € Ü!Ð"YÓZÐZr;   c                 ó   — t        d«      ‚rj   rc   re   s      r:   Úbatch_decodez#MusicFlamingoProcessor.batch_decode®   rl   r;   c                 ó   — t        d«      ‚rb   rc   re   s      r:   Ú"_strip_assistant_prefix_and_quotesz9MusicFlamingoProcessor._strip_assistant_prefix_and_quotes±   rh   r;   )Nz<sound>z<|sound_bos|>z<|sound_eos|>i°  )r<   r=   r>   rJ   r1   r@   ÚstrrW   Úpropertyr\   r`   rg   rk   rn   rp   Ú__classcell__©rQ   s   @r:   rD   rD   v   s{   ø„ ð ØØ'Ø'ØõSðBa°ð aÀð aÈó að ñWó ðWð ñ$ó ð$ò
Uò[ò[öUr;   rD   c                 óÈ   —  | j                   g | j                  d d ¢d‘d‘­Ž } | j                  d¬«      \  }}t        j                  | |fd¬«      } | j                  d«      S )Néÿÿÿÿr   ©Údiméþÿÿÿ)ÚreshapeÚshapeÚunbindÚtorchÚstackÚflatten)ÚxÚx1Úx2s      r:   Úrotate_halfrƒ   µ   sa   € Øˆ�	‰	Ð'�1—7‘7˜3˜B�<Ð' Ð' QÒ'€AØ�X‰X˜"ˆXÓ�F€BˆÜ�‰�b�S˜"�I 2Ô&€AØ�9‰9�R‹=Ðr;   c                 óV  — | j                   }| j                  t        j                  «      } |j                  | «      }|j                  | «      }|j                  d   }| d|d …f   }| dd |…f   }||z  t        |«      |z  z   }t        j                  ||fd¬«      j                  |«      S )Nrv   .rw   )ÚdtypeÚtor}   Úfloat64r{   rƒ   Úcat)Úhidden_statesÚcosÚsinÚoriginal_dtypeÚrot_dimÚpassthroughÚrotateds          r:   Úapply_rotary_time_embr�   ¼   s¥   € Ø"×(Ñ(€NØ!×$Ñ$¤U§]¡]Ó3€MØ
�&‰&�Ó
€CØ
�&‰&�Ó
€CØ�i‰i˜‰m€Gà  W¡X Ñ.€KØ˜C  ' ˜MÑ*€GØ˜‰}¤¨WÓ!5¸Ñ!;Ñ<€GÜ�9‰9�g˜{Ð+°Ô4×7Ñ7¸ÓGÐGr;   c            	       óv   ‡ — e Zd ZdZd	defˆ fd„Zd„ Z ej                  «       de	de
dee	e	f   fd„«       Zˆ xZS )
ÚMusicFlamingoRotaryEmbeddinga·  Rotary time embedding module used by MusicFlamingo checkpoints.

    This is a checkpoint-faithful integration, not a direct implementation of the RoTE formulation described in
    (Goel et al., 2024): https://arxiv.org/abs/2410.12109. It applies axial rotary embeddings over the window index
    within each audio sample and the encoder time index within each window, then modulates both axes with absolute
    timestamps in seconds.
    Úconfigc                 ó†   •— t         ‰| �  ||¬«       | j                  | j                  «      }| j	                  d|d¬«       y )N©ÚdeviceÚposition_anglesF)Ú
persistent)rI   rJ   Ú_compute_position_anglesÚinv_freqÚregister_buffer)r8   r“   r–   r—   rQ   s       €r:   rJ   z%MusicFlamingoRotaryEmbedding.__init__Ò   s?   ø€ Ü‰Ñ˜¨ÐÔ/Ø×7Ñ7¸¿¹ÓFˆØ×ÑÐ.°ÈEÐÕRr;   c                 óB  — t        j                  t        | j                  «      |j                  |j
                  ¬«      }|| j                  z  dt        z  z  }|j                  d«      |z  }t        j                  |dd¬«      }|j                  |j
                  ¬«      S )N©r–   r…   r   rv   rw   )r…   )
r}   Úaranger@   Úmax_seq_len_cachedr–   r…   r   Ú	unsqueezeÚrepeat_interleaver†   )r8   rš   Ú	positionsr—   s       r:   r™   z5MusicFlamingoRotaryEmbedding._compute_position_angles×   s„   € Ü—L‘L¤ T×%<Ñ%<Ó!=ÀhÇoÁoÐ]e×]kÑ]kÔlˆ	Ø × 7Ñ 7Ñ7¸1¼r¹6ÑBˆ	Ø#×-Ñ-¨bÓ1°HÑ<ˆÜ×1Ñ1°/À1È"ÔMˆØ×!Ñ!¨¯©Ð!Ó7Ð7r;   Ú
timestampsÚseq_lenrT   c                 ó®  — |dd…df   j                  | j                  j                  | j                  j                  ¬«      }| j                  j
                  dz  |z  }t        j                  ||z  «      | j                  z  }|j                  d«      | j                  z  }t        j                  |dd¬«      }|dd…ddd…f   }| j                  d| ddd…dd…f   }t        ||«      \  }}t        j                  ||fd¬«      }| dz  t        z  j                  |«      }	||	j                  d«      z  }|j                  «       |j!                  «       fS )zBCompute 2D axial rotary embeddings for window and time dimensions.Nr   r�   é   rv   r   rw   )r†   rš   r–   r…   r“   r#   r}   ÚroundrŸ   r    r¡   r—   r   rˆ   r   rŠ   r‹   )
r8   r£   r¤   Úwindow_startsÚwindow_durationÚwindow_positionsÚwindow_freqsÚ
time_freqsÚfreqsÚangles
             r:   Úforwardz$MusicFlamingoRotaryEmbedding.forwardÞ   s5  € ð
 #¢1 a 4Ñ(×+Ñ+°4·=±=×3GÑ3GÈtÏ}É}×ObÑObÐ+ÓcˆØŸ+™+×6Ñ6¸Ñ:¸WÑDˆÜ Ÿ;™; }°Ñ'FÓGÈ$×JaÑJaÑaÐØ'×1Ñ1°"Ó5¸¿¹ÑEˆÜ×.Ñ.¨|¸QÀBÔGˆð $¢A tªQ JÑ/ˆØ×)Ñ)¨(¨7Ð3°Dº!ºQ°JÑ?ˆ
Ü#4°\À:Ó#NÑ ˆ�jÜ—	‘	˜<¨Ð4¸"Ô=ˆØ�˜q‘¤2Ñ%×)Ñ)¨%Ó0ˆØ˜Ÿ™¨Ó+Ñ+ˆØ�y‰y‹{˜EŸI™I›KÐ'Ð'r;   rY   )r<   r=   r>   r?   r    rJ   r™   r}   Úno_gradr   r@   Útupler¯   rs   rt   s   @r:   r’   r’   É   sV   ø„ ññSÐ2õ Sò
8ð €U‡]�]ƒ_ð( &ð (°3ð (¸5ÀÈÀÑ;Pò (ó ô(r;   r’   c                   ó>   — e Zd ZdZ ej
                  «       d„ «       Zy)ÚMusicFlamingoPreTrainedModelNc                 óÈ   — t        j                  | |«       t        |t        «      r<|j	                  |j
                  «      }t        j                  |j                  |«       y y rY   )	r   Ú_init_weightsr/   r’   r™   rš   ÚinitÚcopy_r—   )r8   ÚmoduleÚbuffer_values      r:   rµ   z*MusicFlamingoPreTrainedModel._init_weightsö   sJ   € ä×%Ñ% d¨FÔ3Ü�fÔ:Ô;Ø!×:Ñ:¸6¿?¹?ÓKˆLÜ�J‰J�v×-Ñ-¨|Õ<ð <r;   )r<   r=   r>   Ú_no_split_modulesr}   r°   rµ   r.   r;   r:   r³   r³   ó   s"   „ ØÐà€U‡]�]ƒ_ñ=ó ñ=r;   r³   c                   ó   — e Zd Zy)Ú MusicFlamingoModelOutputWithPastN)r<   r=   r>   r.   r;   r:   r¼   r¼   þ   s   „ àr;   r¼   c                   óþ  ‡ — e Zd Zdefˆ fd„Zdej                  dej                  dedej                  fd„Z	e
 ed¬	«      d
ej                  dej                  dej                  dee   deez  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j                  dz  dedz  dej                  dz  dedz  dee   fd„«       «       Zˆ xZS )ÚMusicFlamingoModelr“   c                 óD   •— t         ‰| �  |«       t        |«      | _        y rY   )rI   rJ   r’   Úpos_emb©r8   r“   rQ   s     €r:   rJ   zMusicFlamingoModel.__init__  s   ø€ Ü‰Ñ˜Ô Ü3°FÓ;ˆ�r;   Ú	input_idsÚpost_lengthsÚmax_post_lengthrT   c                 óž  — || j                   j                  k(  }t        j                  t        j                  j
                  j                  |j                  «       dd¬«      d¬«      }t        j                  |dk(  «      \  }}t        j                  |dk(  «      \  }}||z
  j                  t        j                  «      }	|j                  «       }
|j                  «       }t        |
|k(  d|
› d|› �«       | j                   j                  d	z  }t        j                  ||j                  t        j                   ¬
«      |z  }t        j"                  t        j$                  d|j                  ¬«      t        j&                  |d¬«      d d g«      }t        j&                  |	d¬«      }t        j(                  ||d¬«      }t        j(                  |t        j                  |	j*                  d   |j                  ¬«      «      }t        j                  |j*                  d   |j                  ¬«      ||   z
  }|j-                  d«      |z  |z  |z   S )N)é   rÆ   r   )ÚvaluerÆ   rw   rv   z6Audio features and audio tokens do not match, tokens: z, features: r¦   r�   r•   T)Úright)r“   rZ   r}   ÚdiffÚnnÚ
functionalÚpadr@   Úwherer†   ÚlongÚsumr   r#   rž   r–   Úfloat32rˆ   ÚzerosÚcumsumÚsearchsortedr{   r    )r8   rÂ   rÃ   rÄ   Úaudio_token_maskrÉ   Ú_ÚstartsÚendsÚsample_lengthsÚn_audio_tokensÚn_audio_featuresÚaudio_embed_frame_stepÚframe_offsetsÚcumsum_postÚcumsum_samplesÚsample_indicesÚsample_start_rowsÚwindow_indicess                      r:   Ú_build_audio_timestampsz*MusicFlamingoModel._build_audio_timestamps  sý  € ð %¨¯©×(BÑ(BÑBÐÜ�z‰zœ%Ÿ(™(×-Ñ-×1Ñ1Ð2B×2FÑ2FÓ2HÈ&ÐXYÐ1ÓZÐ`aÔbˆÜ—K‘K ¨¡	Ó*‰	ˆˆ6Ü—+‘+˜d b™jÓ)‰ˆˆ4Ø ™-×+Ñ+¬E¯J©JÓ7ˆà)×-Ñ-Ó/ˆØ'×+Ñ+Ó-ÐÜØÐ.Ñ.ØDÀ^ÐDTÐT`ÐaqÐ`rÐsô	
ð "&§¡×!=Ñ!=ÀÑ!AÐä�L‰L˜°×1DÑ1DÌEÏMÉMÔZÐ]sÑsð 	ô
 —i‘i¤§¡¨Q°|×7JÑ7JÔ!KÌUÏ\É\ÐZfÐlmÔMnÐorÐprÐMsÐ tÓuˆÜŸ™ n¸!Ô<ˆÜ×+Ñ+¨N¸KÈtÔTˆô "×.Ñ.ØœEŸL™L¨×)=Ñ)=¸aÑ)@È×I\ÑI\Ô]ó
Ðô �L‰L˜×+Ñ+¨AÑ.°|×7JÑ7JÔKÐN_Ð`nÑNoÑoð 	ð
 ×'Ñ'¨Ó*¨_Ñ<Ð?UÑUÐXeÑeÐer;   zŸThis method is used to get the audio embeddings from input features (a log mel spectrogram), meaning inferring the audio encoder and the multi-modal projector.©Úcustom_introÚinput_featuresÚinput_features_maskr9   c                 ó–  —  | j                   |f|ddœ|¤Ž}|j                  }| j                   j                  |j                  d«      j	                  t
        j                  «      «      \  }}| j                  |||j                  d   «      }	| j                  |	j	                  |j                  «      |j                  d   ¬«      \  }
}t        ||
|«      }| j                  |«      }t        j                  |j                  d   |j                  ¬«      ddd…f   |dd…df   k  }||j	                  |j                  «         |_        |S )	az  
        input_features_mask (`torch.Tensor` of shape `(batch_size, feature_sequence_length)`):
            Mask to avoid performing attention on padded feature indices.
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Token ids containing the audio token ID placeholders, for reconstructing rotary time embedding timestamps.
        T)ræ   Úreturn_dictrv   ry   )r¤   rÆ   r•   N)Úaudio_towerÚlast_hidden_stateÚ _get_feat_extract_output_lengthsrÏ   r†   r}   rÎ   râ   r{   rÀ   r–   r�   Úmulti_modal_projectorrž   Úpooler_output)r8   rå   ræ   rÂ   r9   Úaudio_outputr‰   rÕ   rÃ   Úaudio_timestampsrŠ   r‹   Úaudio_embedsÚ
valid_masks                 r:   Úget_audio_featuresz%MusicFlamingoModel.get_audio_features1  sL  € ð" (�t×'Ñ'Øð
à 3Øñ
ð ñ	
ˆð %×6Ñ6ˆØ×*Ñ*×KÑKÐL_×LcÑLcÐdfÓLg×LjÑLjÔkp×kuÑkuÓLvÓw‰ˆˆ<Ø×7Ñ7¸	À<ÐQ^×QdÑQdÐegÑQhÓiÐØ—<‘<Ð 0× 3Ñ 3°M×4HÑ4HÓ IÐS`×SfÑSfÐgiÑSj�<Ók‰ˆˆSÜ-¨m¸SÀ#ÓFˆØ×1Ñ1°-Ó@ˆô —\‘\ ,×"4Ñ"4°QÑ"7À×@SÑ@SÔTÐUYÒ[\ÐU\Ñ]Ð`lÒmnÐptÐmtÑ`uÑuˆ
Ø%1°*·-±-À×@SÑ@SÓ2TÑ%UˆÔ"àÐr;   NÚattention_maskÚposition_idsÚpast_key_valuesÚinputs_embedsÚ	use_cachec	           	      óš  — |€ | j                  «       |«      }d}
|�`|�^| j                  |||d¬«      j                  }
| j                  |||
¬«      }|j	                  ||
j                  |j                  «      «      } | j                  d|||||dœ|	¤Ž}t        |j                  |j                  |j                  |j                  |
¬«      S )z³
        input_features_mask (`torch.Tensor` of shape `(batch_size, feature_sequence_length)`):
            Mask to avoid performing attention on padding feature indices.
        NT)rÂ   rè   )rö   Úaudio_features)rö   ró   rô   rõ   r÷   )rê   rõ   r‰   Ú
attentionsÚaudio_hidden_statesr.   )Úget_input_embeddingsrò   rí   Úget_placeholder_maskÚmasked_scatterr†   r–   Úlanguage_modelr¼   rê   rõ   r‰   rú   )r8   rÂ   rå   ræ   ró   rô   rõ   rö   r÷   r9   rð   Úspecial_audio_maskÚoutputss                r:   r¯   zMusicFlamingoModel.forwardU  s  € ð$ Ð Ø7˜D×5Ñ5Ó7¸	ÓBˆMàˆØÐ%¨)Ð*?Ø×2Ñ2ØÐ 3¸yÐVZð 3ó ç‰mð ð
 "&×!:Ñ!:Ø¨À|ð ";ó "Ðð *×8Ñ8Ð9KÈ\Ï_É_Ð]j×]qÑ]qÓMrÓsˆMà%�$×%Ñ%ð 
Ø'Ø)Ø%Ø+Øñ
ð ñ
ˆô 0Ø%×7Ñ7Ø#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø ,ô
ð 	
r;   )NNNNNNNN)r<   r=   r>   r    rJ   r}   Ú
LongTensorr@   ÚFloatTensorrâ   r   r   r   r   r   r±   r   rò   r
   Úboolr¯   rs   rt   s   @r:   r¾   r¾     s¡  ø„ ð<Ð2õ <ð'fà×#Ñ#ð'fð ×&Ñ&ð'fð ð	'fð
 
×	Ñ	ó'fðR Ùð wôðà×)Ñ)ðð #Ÿ\™\ðð ×#Ñ#ð	ð
 Ð+Ñ,ðð 
Ð+Ñ	+òóó ðð@ Øð .2Ø37Ø37Ø.2Ø04Ø(,Ø26Ø!%ñ.
à×#Ñ# dÑ*ð.
ð ×)Ñ)¨DÑ0ð.
ð #Ÿ\™\¨DÑ0ð	.
ð
 Ÿ™ tÑ+ð.
ð ×&Ñ&¨Ñ-ð.
ð  ™ð.
ð ×(Ñ(¨4Ñ/ð.
ð ˜$‘;ð.
ð Ð+Ñ,ò.
ó ó ô.
r;   r¾   z�
    The MusicFlamingo model which consists of a fine-tuned Whisper encoder, rotary time embedding, a multi-modal projector, and a Qwen2 language model.
    rã   c                   ó*   ‡ — e Zd Zdefˆ fd„Zd„ Zˆ xZS )Ú%MusicFlamingoForConditionalGenerationr“   c                 ód   •— t         ‰| �  |«       t        |«      | _        | j	                  «        y rY   )rI   rJ   r¾   ÚmodelÚ	post_initrÁ   s     €r:   rJ   z.MusicFlamingoForConditionalGeneration.__init__Ž  s&   ø€ Ü‰Ñ˜Ô Ü'¨Ó/ˆŒ
Ø�‰Õr;   c                 ó@   —  | j                   j                  |||fi |¤ŽS rY   )r  rò   )r8   rå   ræ   rÂ   r9   s        r:   rò   z8MusicFlamingoForConditionalGeneration.get_audio_features“  s%   € Ø,ˆt�z‰z×,Ñ,¨^Ð=PÐR[ÑfÐ_eÑfÐfr;   )r<   r=   r>   r    rJ   rò   rs   rt   s   @r:   r  r  ˆ  s   ø„ ðÐ2õ ö
gr;   r  )r    rD   r  r¾   r³   )7Údataclassesr   Úmathr   Úhuggingface_hub.dataclassesr   r}   r   r   Ú r	   r¶   Úcache_utilsr
   Úconfiguration_utilsr   Úmodeling_outputsr   Úmodeling_utilsr   Úprocessing_utilsr   Úutilsr   r   r   r   r   r   Ú+audioflamingo3.configuration_audioflamingo3r   Ú&audioflamingo3.modeling_audioflamingo3r   r   r   r   Ú(audioflamingo3.processing_audioflamingo3r   Úautor   Úmoonshine.modeling_moonshiner   Ú
get_loggerr<   r^   r    rD   rƒ   r�   r’   r³   r¼   r¾   r  Ú__all__r.   r;   r:   ú<module>r     s7  ðõ  "Ý å .ß +å &Ý  Ý 3Ý :Ý -Ý &÷÷ õ O÷ó õ OÝ !Ý Cð 
ˆ×	Ñ	˜HÓ	%€ñ ÔÛñ Ð:Ô;Øô:7Ð.ó :7ó ó <ð:7ðz ô;UÐ4ó ;Uó ð;Uò|ò
Hô'(Ð#;ô '(ôT=Ð#@ô =ð ô	Ð'Hó 	ó ð	ôB
Ð,ô B
ñJ ðôô
gÐ,Ró góð
gò�r;   