+
    œ°³j¸5  ã                   ó@  € ^ RI Ht ^ RIt^ RIHt ^RIHt ^RIHt ^RIH	t	 ^RI
HtHt ^RIHt ^R	IHtHtHtHt ^R
IHt ^RIHt ^RIHtHt ^RIHtHtHtHt ^RI H!t!H"t" ^RI#H$t$ ]PJ                  ! ]&4      t' ! R R]!4      t( ! R R]"4      t) ! R R]4      t*] ! R R]4      4       t+]! RR7      ] ! R R]4      4       4       t,]! RR7       ! R R]4      4       t- ! R R ]4      t.]! R!R7       ! R" R#]4      4       t/]! R$R7       ! R% R&]4      4       t0. R'Ot1R# )(é    )Ú	dataclassN)Únn)ÚACT2FN)ÚCache)Úcreate_bidirectional_mask)ÚBaseModelOutputWithPoolingÚModelOutput)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚcan_return_tupleÚlogging)Úmerge_with_config_defaults)Úcapture_outputs)ÚQwen2AudioEncoderÚQwen2AudioPreTrainedModel)ÚVoxtralForConditionalGenerationÚVoxtralModelÚVoxtralModelOutputWithPastÚVoxtralMultiModalProjector)ÚWhisperAttentionÚWhisperEncoderLayer©ÚAudioFlamingo3Configc                   ó   € ] tR t^.tRtR# )ÚAudioFlamingo3Attention© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Úz/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/audioflamingo3/modular_audioflamingo3.pyr   r   .   ó   † Ûr$   r   c                   ó   € ] tR t^2tRtR# )ÚAudioFlamingo3EncoderLayerr   Nr   r   r$   r%   r(   r(   2   r&   r$   r(   c                   ó   € ] tR t^6tRtRtR# )ÚAudioFlamingo3PreTrainedModelTr   N)r   r    r!   r"   Ú_supports_attention_backendr#   r   r$   r%   r*   r*   6   s   † Ø"&Ôr$   r*   c                   ó   € ] tR t^:tRtR# )Ú!AudioFlamingo3ModelOutputWithPastr   Nr   r   r$   r%   r-   r-   :   s   † ãr$   r-   zZ
    Base class for AudioFlamingo3 causal language model (or autoregressive) outputs.
    ©Úcustom_introc                   óH   a € ] tR t^?t o RtRtRtRtRtRt	Rt
V 3R ltRtV tR# )Ú$AudioFlamingo3CausalLMOutputWithPasta2  
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.
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance.
audio_hidden_states (`torch.FloatTensor`, *optional*):
    Hidden states of the audio encoder after projection.
Nc                ó:  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[ P                  R,          ;R&   # )é   NÚlossÚlogitsÚpast_key_valuesÚhidden_statesÚ
attentionsÚaudio_hidden_states)ÚtorchÚFloatTensorr   Útuple)ÚformatÚ__classdict__s   "€r%   Ú__annotate__Ú1AudioFlamingo3CausalLMOutputWithPast.__annotate__?   s˜   ø‡ ‚ ñ$ ×
Ñ
˜dÕ
"Ñ)ñ% ñ& ×Ñ Õ$Ñ+ñ' ñ( ˜T•\Ñ(ñ) ñ* ™×*Ñ*Õ+¨dÕ2Ñ9ñ+ ñ, ‘e×'Ñ'Õ(¨4Õ/Ñ6ñ- ñ. ×*Ñ*¨TÕ1Ñ8ò/ r$   r   )r   r    r!   r"   Ú__doc__r4   r5   r6   r7   r8   r9   Ú__annotate_func__r#   Ú__classdictcell__©r>   s   @r%   r1   r1   ?   s2   ø‡ € ñ	ð &*€DØ'+€FØ$(€OØ59€MØ26€JØ48Ð÷/ ƒ r$   r1   zT
    The audio model from AudioFlamingo3 without any head or projection on top.
    c                   óZ   a € ] tR t^Yt o RtR]R]/t]]	RV 3R lR ll4       4       t
RtV tR# )	ÚAudioFlamingo3EncoderzQ
AudioFlamingo3 encoder: Whisper encoder, average pool (time/2), then LayerNorm.
r7   r8   Nc                ór   <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[S[,          /# )r3   Úinput_featuresÚinput_features_maskNÚreturn)r:   ÚTensorr<   r   )r=   r>   s   "€r%   r?   Ú"AudioFlamingo3Encoder.__annotate__j   s<   ø€ ÷ 3
ñ 3
áŸ™ð3
ñ #Ÿ\™\¨DÕ0ð3
ñ
 
Ñ+Õ	+ñ3
r$   c                ó  € VP                   R,          ^,
          ^,          ^,           pVP                  R4      pV^,
          ^,          ^,           p\        P                  ! WAP                  R7      VR,          8  p\
        P                  P                  V P                  V4      4      p\
        P                  P                  V P                  V4      4      pVP                  ^ ^^4      pW`P                  P                  ,           p\
        P                  P                  WpP                  V P                  R7      p\        V P                   VVR7      pV P"                   FL  p	V P                  ;'       d$    \        P$                  ! . 4      V P&                  8  p
V
'       d   KD  V	! Wx4      pKN  	  VP                  ^ ^^4      pV P)                  V4      P                  ^ ^^4      pV P+                  V4      p\-        VR7      # )a(  
Args:
    input_features (`torch.FloatTensor` of shape `(batch_size, feature_size, sequence_length)`):
        Log-Mel features extracted from raw audio. Use the processor/feature extractor to compute and pad
        these features from waveform input.
    input_features_mask (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optional*):
        Mask to avoid performing attention on padding feature indices. Mask values selected in `[0, 1]`:

        - 1 for tokens that are **not masked**,
        - 0 for tokens that are **masked**.
©Údevice)ÚpÚtraining)ÚconfigÚinputs_embedsÚattention_mask)Úlast_hidden_stateéÿÿÿÿ©ºNNNN)ÚshapeÚsumr:   ÚarangerO   r   Ú
functionalÚgeluÚconv1Úconv2ÚpermuteÚembed_positionsÚweightÚdropoutrQ   r   rR   ÚlayersÚrandÚ	layerdropÚ
avg_poolerÚ
layer_normr   )ÚselfrH   rI   ÚkwargsÚseq_lenÚinput_features_lengthsrS   r7   rT   ÚlayerÚdrops   &&&,       r%   ÚforwardÚAudioFlamingo3Encoder.forwardh   s�  € ð( "×'Ñ'¨Õ+¨aÕ/°AÕ5¸Õ9ˆØ!4×!8Ñ!8¸Ó!<ÐØ"8¸1Õ"<ÀÕ!BÀQÕ!FÐÜ#Ÿlšl¨7×;PÑ;PÔQÐTjÐkrÕTsÑsÐô Ÿ™×*Ñ*¨4¯:©:°nÓ+EÓFˆÜŸ™×*Ñ*¨4¯:©:°mÓ+DÓEˆØ%×-Ñ-¨a°°AÓ6ˆð &×(<Ñ(<×(CÑ(CÕCˆÜŸ™×-Ñ-¨m¿|¹|ÐVZ×VcÑVcÐ-Ódˆä2Ø—;‘;Ø'Ø.ô
ˆð —[”[ˆEØ—=‘=×DÐD¤U§Z¢Z°£^°d·n±nÑ%DˆDß‘4Ù % mÓ D’ñ !ð &×-Ñ-¨a°°AÓ6ˆØŸ™¨Ó6×>Ñ>¸qÀ!ÀQÓGˆØŸ™¨Ó6ˆä)Ø+ô
ð 	
r$   r   ©N)r   r    r!   r"   rA   r(   r   Ú_can_record_outputsr   r   ro   r#   rC   rD   s   @r%   rF   rF   Y   sA   ø‡ € ñð
 	Ð3ØÐ-ðÐð
  Ø÷3
ñ 3
ó ó  ö3
r$   rF   c                   óB   a a€ ] tR t^ t oRtV3R lV 3R lltRtVtV ;t# )Ú!AudioFlamingo3MultiModalProjectorz‰
Audio adaptor (small MLP) that projects AudioFlamingo3Encoder features
to the LLM embedding space so they can replace `<sound>` tokens.
c                ó    <€ V ^8„  d   QhRS[ /# )r3   rR   r   )r=   r>   s   "€r%   r?   Ú.AudioFlamingo3MultiModalProjector.__annotate__¦   s   ø€ ÷ 
ñ 
Ñ3ñ 
r$   c                óœ  <€ \         SV `  4        \        P                  ! VP                  P
                  VP                  P
                  VP                  R 7      V n        \        VP                  ,          V n        \        P                  ! VP                  P
                  VP                  P
                  VP                  R 7      V n        R# ))ÚbiasN)ÚsuperÚ__init__r   ÚLinearÚaudio_configÚhidden_sizeÚtext_configÚprojector_biasÚlinear_1r   Úprojector_hidden_actÚactÚlinear_2©ri   rR   Ú	__class__s   &&€r%   rz   Ú*AudioFlamingo3MultiModalProjector.__init__¦   sŽ   ø€ Ü‰ÑÔÜŸ	š	Ø×Ñ×+Ñ+¨V×-?Ñ-?×-KÑ-KÐRX×RgÑRgô
ˆŒô ˜&×5Ñ5Õ6ˆŒÜŸ	š	Ø×Ñ×*Ñ*¨F×,>Ñ,>×,JÑ,JÐQW×QfÑQfô
ˆŽr$   )r‚   r€   rƒ   )	r   r    r!   r"   rA   rz   r#   rC   Ú__classcell__©r…   r>   s   @@r%   rt   rt       s   ù‡ € ñ÷

÷ 
ó 
r$   rt   z“
    The AudioFlamingo3 model (fine-tuned Whisper encoder, multi-modal projector, Qwen2 language model),
    without a language modeling head.
    c                   óœ   a a€ ] tR t^±t oRtRtRtV 3R lt]]	! RR7      V3R lR l4       4       t
]]	R
V3R lR ll4       4       tR	tVtV ;t# )ÚAudioFlamingo3ModelNc                ó&   <€ \         SV `  V4       R # rq   )ry   rz   r„   s   &&€r%   rz   ÚAudioFlamingo3Model.__init__¼   s   ø€ Ü‰Ñ˜Ö r$   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.r.   c          	      óz   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[S[,          RS[S[,          /# )r3   rH   rI   rj   rJ   )r:   r;   rK   r
   r   r<   r   )r=   r>   s   "€r%   r?   Ú AudioFlamingo3Model.__annotate__Ã   sI   ø€ ÷ ñ á×)Ñ)ðñ #Ÿ\™\ðñ Ñ+Õ,ð	ñ
 
Ñ+Õ	+ñr$   c                óÔ  € V P                   ! V3RVRR/VB pV P                  VP                  4      pVP                  R4      P	                  \
        P                  4      pV P                   P                  V4      w  rx\
        P                  ! VP                  ^,          VP                  R7      R,          VR,          8  p	WYP	                  VP                  4      ,          Vn        V# )a	  
input_features (`torch.FloatTensor`):
    Float values of mel features extracted from the raw speech waveform.
input_features_mask (`torch.Tensor` of shape `(batch_size, feature_sequence_length)`):
    Mask to avoid performing attention on padded feature indices.
rI   Úreturn_dictTrN   rV   )NrX   rW   )Úaudio_towerÚmulti_modal_projectorrU   rZ   Útor:   ÚlongÚ _get_feat_extract_output_lengthsr[   rY   rO   Úpooler_output)
ri   rH   rI   rj   Úaudio_outputÚaudio_embedsÚinput_lengthsÚ_Úpost_lengthsÚ
valid_masks
   &&&,      r%   Úget_audio_featuresÚ&AudioFlamingo3Model.get_audio_features¿   sÓ   € ð" ×'Ò'Øñ
Ø0Cð
ØQUð
ØY_ñ
ˆð ×1Ñ1°,×2PÑ2PÓQˆð ,×/Ñ/°Ó3×6Ñ6´u·z±zÓBˆØ×*Ñ*×KÑKÈMÓZ‰ˆÜ—\’\ ,×"4Ñ"4°QÕ"7À×@SÑ@SÔTÐU\Õ]Ð`lÐmtÕ`uÑuˆ
Ø%1·-±-À×@SÑ@SÓ2TÕ%UˆÔ"àÐr$   c                óH  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          R	S[R,          R
S[S[,          /	# )r3   Ú	input_idsNrH   rI   rT   Úposition_idsr6   rS   Ú	use_cacherj   )r:   Ú
LongTensorr;   rK   r   Úboolr
   r   )r=   r>   s   "€r%   r?   rŽ   ß   s±   ø€ ÷ .
ñ .
á×#Ñ# dÕ*ð.
ñ ×)Ñ)¨DÕ0ð.
ñ #Ÿ\™\¨DÕ0ð	.
ñ
 Ÿ™ tÕ+ð.
ñ ×&Ñ&¨Õ-ð.
ñ  �ð.
ñ ×(Ñ(¨4Õ/ð.
ñ ˜$•;ð.
ñ Ñ+Õ,ñ.
r$   c	                ó¼  € Vf   V P                  4       ! V4      pRp
Vej   Vef   V P                  W#RR7      P                  p
V P                  WV
R7      pVP	                  WºP                  VP                  VP                  4      4      pV P                  ! RRVRVRVRVR	V/V	B p\        VP                  VP                  VP                  VP                  V
R
7      # )z›
input_features_mask (`torch.Tensor` of shape `(batch_size, feature_sequence_length)`):
    Mask to avoid performing attention on padding feature indices.
NT)r�   )rS   Úaudio_featuresrS   rT   r¡   r6   r¢   )rU   r6   r7   r8   r9   r   )Úget_input_embeddingsr�   r–   Úget_placeholder_maskÚmasked_scatterr“   rO   ÚdtypeÚlanguage_modelr-   rU   r6   r7   r8   )ri   r    rH   rI   rT   r¡   r6   rS   r¢   rj   r˜   Úspecial_audio_maskÚoutputss   &&&&&&&&&,   r%   ro   ÚAudioFlamingo3Model.forwardÝ   s  € ð$ Ò Ø ×5Ñ5Ô7¸	ÓBˆMàˆØÒ%¨)Ò*?Ø×2Ñ2°>ÐdhÐ2Ói×wÑwˆLð "&×!:Ñ!:ØÀ|ð ";ó "Ðð *×8Ñ8Ø"§O¡O°M×4HÑ4HÈ-×J]ÑJ]Ó$^óˆMð ×%Ò%ñ 
Ø'ð
à)ð
ð &ð
ð ,ð	
ð
  ð
ð ñ
ˆô 1Ø%×7Ñ7Ø#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø ,ô
ð 	
r$   r   )NNNNNNNN)r   r    r!   r"   Ú_tp_planÚ_pp_planÚ_keep_in_fp32_modules_strictrz   r   r   r�   ro   r#   rC   r‡   rˆ   s   @@r%   rŠ   rŠ   ±   si   ù‡ € ð €HØ€HØ#'Ð õ!ð Ùð wô÷óó ðð4 Ø÷.
ñ .
ó ó ÷.
ð .
r$   rŠ   z†
    The AudioFlamingo3 model which consists of a fine-tuned Whisper encoder, a multi-modal projector and a Qwen2 language model.
    c                   ót   a a€ ] tR tRt o]! 4       tRtV 3R ltR t]	]
RV3R lR ll4       4       tRtVtV ;t# )	Ú&AudioFlamingo3ForConditionalGenerationi  Nc                óf   <€ \         SV `  V4       \        V4      V n        V P	                  4        R # rq   )ry   rz   rŠ   ÚmodelÚ	post_initr„   s   &&€r%   rz   Ú/AudioFlamingo3ForConditionalGeneration.__init__  s&   ø€ Ü‰Ñ˜Ô Ü(¨Ó0ˆŒ
Ø�‰Ör$   c                ó<   € V P                   P                  ! W3/ VB # rq   )rµ   r�   )ri   rH   rI   rj   s   &&&,r%   r�   Ú9AudioFlamingo3ForConditionalGeneration.get_audio_features  s   € Ø�z‰z×,Ò,¨^Ñ[ÐTZÑ[Ð[r$   c                ó°  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          R	S[ P                  R,          R
S[R,          RS[S[ P                  ,          RS[S[,          RS[	S[
,          /# )r3   r    NrH   rI   rT   r¡   r6   rS   Úlabelsr¢   Úlogits_to_keeprj   rJ   )r:   r£   r;   rK   r   r¤   Úintr
   r   r<   r1   )r=   r>   s   "€r%   r?   Ú3AudioFlamingo3ForConditionalGeneration.__annotate__#  sé   ø€ ÷ :
ñ :
á×#Ñ# dÕ*ð:
ñ ×)Ñ)¨DÕ0ð:
ñ #Ÿ\™\¨DÕ0ð	:
ñ
 Ÿ™ tÕ+ð:
ñ ×&Ñ&¨Õ-ð:
ñ  �ð:
ñ ×(Ñ(¨4Õ/ð:
ñ × Ñ  4Õ'ð:
ñ ˜$•;ð:
ñ ™eŸl™lÕ*ð:
ñ Ñ+Õ,ð:
ñ 
Ñ5Õ	5ñ:
r$   c                óÈ  € V P                   ! RRVRVRVRVRVRVRVRV	/VB pVP                  p\        V
\        4      '       d   \	        V
) R	4      MT
pV P                  VR
VR
3,          4      pR	pVe7   V P                  ! RRVRVRV P                  P                  P                  /VB p\        VVVP                  VP                  VP                  VP                  R7      # )aY  
input_features_mask (`torch.Tensor` of shape `(batch_size, feature_sequence_length)`):
    Mask to avoid performing attention on padding feature indices.
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Labels for computing the masked language modeling loss.

Example:

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

>>> model_id = "nvidia/audio-flamingo-3-hf"
>>> processor = AutoProcessor.from_pretrained(model_id)
>>> model = AudioFlamingo3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")
```r    rH   rI   rT   r¡   r6   rS   r¢   NrX   r5   r»   Ú
vocab_size)r4   r5   r6   r7   r8   r9   r   )rµ   rU   Ú
isinstancer½   ÚsliceÚlm_headÚloss_functionrR   r~   rÀ   r1   r6   r7   r8   r9   )ri   r    rH   rI   rT   r¡   r6   rS   r»   r¢   r¼   rj   r­   r7   Úslice_indicesr5   r4   s   &&&&&&&&&&&,     r%   ro   Ú.AudioFlamingo3ForConditionalGeneration.forward!  s1  € ð> —*’*ñ 

Øð

à)ð

ð !4ð

ð *ð	

ð
 &ð

ð ,ð

ð (ð

ð  ð

ð ñ

ˆð  ×1Ñ1ˆÜ8BÀ>ÔSV×8WÒ8Wœ˜~˜o¨tÔ4Ð]kˆØ—‘˜m¨A¨}¸aÐ,?Õ@ÓAˆàˆØÒØ×%Ò%ñ ØðØ&,ðØ9=¿¹×9PÑ9P×9[Ñ9[ðØ_eñˆDô 4ØØØ#×3Ñ3Ø!×/Ñ/Ø×)Ñ)Ø '× ;Ñ ;ô
ð 	
r$   )rµ   )
NNNNNNNNNr   )r   r    r!   r"   ÚAttributeErrorr±   Ú_tied_weights_keysrz   r�   r   r   ro   r#   rC   r‡   rˆ   s   @@r%   r³   r³     sG   ù‡ € ñ $2Ó#3Ð ØÐõò
\ð Ø÷:
ñ :
ó ó ÷:
ð :
r$   r³   )r³   r*   rF   rŠ   )2Údataclassesr   r:   r   Úactivationsr   Úcache_utilsr   Úmasking_utilsr   Úmodeling_outputsr   r	   Úprocessing_utilsr
   Úutilsr   r   r   r   Úutils.genericr   Úutils.output_capturingr   Ú qwen2_audio.modeling_qwen2_audior   r   Úvoxtral.modeling_voxtralr   r   r   r   Úwhisper.modeling_whisperr   r   Úconfiguration_audioflamingo3r   Ú
get_loggerr   Úloggerr   r(   r*   r-   r1   rF   rt   rŠ   r³   Ú__all__r   r$   r%   Ú<module>rÙ      sU  ðõ  "ã Ý å !Ý  Ý 6ß GÝ &ß RÓ RÝ 7Ý 5÷÷ó ÷ MÝ >ð 
×	Ò	˜HÓ	%€ô	Ð.ô 	ô	Ð!4ô 	ô'Ð$=ô 'ð ô	Ð(Bó 	ó ð	ñ ðôð
 ô9¨;ó 9ó óð9ñ( ðôô
?
Ð-ó ?
óð
?
ôD
Ð(Bô 
ñ" ðôôV
˜,ó V
óðV
ñr ðôô
H
Ð-Ló H
óð
H
òV‚r$   