§
    ‚Štj€” ã                   óè  — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZ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mZmZmZmZ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/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZBmCZC e
rddlDmEZE  e6jF        eG¦  «        ZHe5e G d„ de,¦  «        ¦   «         ¦   «         ZIdejJ        deKdeKfd „ZL G d!„ d"ejM        ¦  «        ZN	 	 d?d$ejM        d%ejJ        d&ejJ        d'ejJ        d(ejJ        dz  d)eOdz  d*eOd+e2e4         fd,„ZP G d-„ d.ejM        ¦  «        ZQ G d/„ d0e'¦  «        ZRe5 G d1„ d2e0¦  «        ¦   «         ZS G d3„ d4eS¦  «        ZTe5 G d5„ d6eS¦  «        ¦   «         ZU e5d7¬8¦  «         G d9„ d:eSe¦  «        ¦   «         ZV e5d;¬8¦  «         G d<„ d=eSe¦  «        ¦   «         ZWg d>¢ZXdS )@zPyTorch Musicgen model.é    N)ÚCallable)Ú	dataclass)ÚTYPE_CHECKINGÚAnyÚOptional)ÚCrossEntropyLossé   )Úinitialization)ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)Ú%ClassifierFreeGuidanceLogitsProcessorÚGenerationConfigÚGenerationMixinÚGenerationModeÚLogitsProcessorListÚStoppingCriteriaList)Úcreate_bidirectional_maskÚcreate_causal_mask)ÚFlashAttentionKwargs)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚ)BaseModelOutputWithPastAndCrossAttentionsÚ!CausalLMOutputWithCrossAttentionsÚModelOutputÚSeq2SeqLMOutput)ÚALL_ATTENTION_FUNCTIONSÚPreTrainedModel)ÚUnpack)ÚTransformersKwargsÚauto_docstringÚlogging)Úcan_return_tupleÚmerge_with_config_defaults)ÚOutputRecorderÚcapture_outputsé   )Ú
AutoConfig©Ú	AutoModelé   )ÚMusicgenConfigÚMusicgenDecoderConfig)ÚBaseStreamerc                   óp   — e Zd ZU dZdZeej                 dz  ed<   dZ	ej
        dz  ed<   dZedz  ed<   dS )ÚMusicgenUnconditionalInputaú  
    encoder_outputs (`tuple[torch.FloatTensor]` of length 1, with tensor shape `(batch_size, sequence_length, hidden_size)`):
        Sequence of hidden-states at the output of the last layer of the text encoder model.
    attention_mask (`torch.LongTensor`)  of shape `(batch_size, sequence_length)`, *optional*):
        Encoder attention 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**.
    guidance_scale (`float`, *optional*):
        Guidance scale for classifier free guidance, setting the balance between the conditional logits (predicted
        from the prompts) and the unconditional logits (predicted without prompts).
    NÚencoder_outputsÚattention_maskÚguidance_scale)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   ÚtupleÚtorchÚFloatTensorÚ__annotations__r3   Ú
LongTensorr4   Úfloat© ó    úl/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/musicgen/modeling_musicgen.pyr1   r1   C   sg   € € € € € € ð	ð 	ð 8<€O�U˜5Ô,Ô-°Ñ4Ð;Ð;Ñ;Ø.2€N�EÔ$ tÑ+Ð2Ð2Ñ2Ø#'€N�E˜D‘LÐ'Ð'Ñ'Ð'Ð'r@   r1   Ú	input_idsÚpad_token_idÚdecoder_start_token_idc                 ó2  — |                       dd¦  «        } |                      | j        ¦  «        }| ddd…f                              ¦   «         |ddd…f<   |€t	          d¦  «        ‚||d<   |€t	          d¦  «        ‚|                     |d	k    |¦  «         |S )
z1
    Shift input ids one token to the right.
    r,   r(   .NéÿÿÿÿzSMake sure to set the decoder_start_token_id attribute of the model's configuration.©.r   zIMake sure to set the pad_token_id attribute of the model's configuration.éœÿÿÿ)Ú	transposeÚ	new_zerosÚshapeÚcloneÚ
ValueErrorÚmasked_fill_)rB   rC   rD   Úshifted_input_idss       rA   Úshift_tokens_rightrP   V   s²   € ð
 ×#Ò# A qÑ)Ô)€IØ!×+Ò+¨I¬OÑ<Ô<ÐØ!*¨3°°°¨8Ô!4×!:Ò!:Ñ!<Ô!<Ð�c˜1˜2˜2�gÑØÐ%ÝÐnÑoÔoÐoØ 6Ð�fÑàÐÝÐdÑeÔeÐeà×"Ò"Ð#4¸Ò#<¸lÑKÔKÐKàÐr@   c                   ó¢   ‡ — e Zd ZdZdedefˆ fd„Zdedefd„Zededefd„¦   «         Z e	j
        ¦   «         dd	e	j        d
efd„¦   «         Zˆ xZS )Ú%MusicgenSinusoidalPositionalEmbeddingzDThis module produces sinusoidal positional embeddings of any length.Únum_positionsÚembedding_dimc                 ó�   •— t          ¦   «                              ¦   «          || _        || _        |                      ||¦  «         d S ©N)ÚsuperÚ__init__rT   rS   Úmake_weights)ÚselfrS   rT   Ú	__class__s      €rA   rX   z.MusicgenSinusoidalPositionalEmbedding.__init__m   sE   ø€ Ý‰Œ×ÒÑÔÐØ*ˆÔØ*ˆÔØ×Ò˜-¨Ñ7Ô7Ð7Ð7Ð7r@   Únum_embeddingsc                 óØ   — |                       ||¦  «        }t          | d¦  «        r+|                     | j        j        | j        j        ¬¦  «        }|                      d|d¬¦  «         d S )NÚweights©ÚdtypeÚdeviceF)Ú
persistent)Úget_embeddingÚhasattrÚtor^   r`   ra   Úregister_buffer)rZ   r\   rT   Úemb_weightss       rA   rY   z2MusicgenSinusoidalPositionalEmbedding.make_weightss   sj   € Ø×(Ò(¨¸ÑGÔGˆÝ�4˜Ñ#Ô#ð 	_à%Ÿ.š.¨t¬|Ô/AÈ$Ì,ÔJ]˜.Ñ^Ô^ˆKà×Ò˜Y¨ÀÐÑFÔFÐFÐFÐFr@   c                 óÚ  — |dz  }t          j        d¦  «        |dz
  z  }t          j        t          j        |t          j        ¬¦  «                             ¦   «         | z  ¦  «        }t          j        | t          j        ¬¦  «                             ¦   «                              d¦  «        |                     d¦  «        z  }t          j        t          j	        |¦  «        t          j
        |¦  «        gd¬¦  «                             | d¦  «        }|dz  dk    r+t          j        |t          j        | d¦  «        gd¬¦  «        }|                     t          j        ¦   «         ¦  «        S )zÁ
        Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the
        description in Section 3.5 of "Attention Is All You Need".
        r(   i'  r,   ©r`   r   ©ÚdimrF   )ÚmathÚlogr:   ÚexpÚarangeÚint64r>   Ú	unsqueezeÚcatÚcosÚsinÚviewÚzerosre   Úget_default_dtype)r\   rT   Úhalf_dimÚembs       rA   rc   z3MusicgenSinusoidalPositionalEmbedding.get_embedding{   s'  € ð ! AÑ%ˆÝŒh�u‰oŒo ¨A¡Ñ.ˆÝŒi�œ XµU´[ÐAÑAÔA×GÒGÑIÔIÈSÈDÑPÑQÔQˆÝŒl˜>µ´Ð=Ñ=Ô=×CÒCÑEÔE×OÒOÐPQÑRÔRÐUX×UbÒUbÐcdÑUeÔUeÑeˆÝŒi�œ 3™œ­¬°3©¬Ð8¸aÐ@Ñ@Ô@×EÒEÀnÐVXÑYÔYˆØ˜1Ñ Ò!Ð!å”)˜S¥%¤+¨n¸aÑ"@Ô"@ÐAÀqÐIÑIÔIˆCØ�vŠv•eÔ-Ñ/Ô/Ñ0Ô0Ð0r@   r   rB   Úpast_key_values_lengthc                 ó‚  — |                      ¦   «         \  }}}t          j        |¦  «        |z                        |j        ¦  «        }|| j                              d¦  «        k    r|                      || j        ¦  «         | j                             d| 	                    d¦  «        ¦  «         
                    ¦   «         S )Nr   rF   )Úsizer:   ro   re   ra   r^   rY   rT   Úindex_selectru   Údetach)rZ   rB   rz   ÚbszÚ	codebooksÚseq_lenÚposition_idss          rA   Úforwardz-MusicgenSinusoidalPositionalEmbedding.forward‹   s¤   € à"+§.¢.Ñ"2Ô"2ÑˆˆY˜åœ WÑ-Ô-Ð0FÑF×JÒJÈ9ÔK[Ñ\Ô\ˆà�T”\×&Ò& qÑ)Ô)Ò)Ð)Ø×Ò˜g tÔ'9Ñ:Ô:Ð:ØŒ|×(Ò(¨¨L×,=Ò,=¸bÑ,AÔ,AÑBÔB×IÒIÑKÔKÐKr@   )r   )r5   r6   r7   r8   ÚintrX   rY   Ústaticmethodrc   r:   Úno_gradÚTensorrƒ   Ú__classcell__©r[   s   @rA   rR   rR   j   sï   ø€ € € € € ØNÐNð8 cð 8¸#ð 8ð 8ð 8ð 8ð 8ð 8ðG¨3ð G¸sð Gð Gð Gð Gð ð1 cð 1¸#ð 1ð 1ð 1ñ „\ð1ð €U„]�_„_ðLð L ¤ð LÀsð Lð Lð Lñ „_ðLð Lð Lð Lð Lr@   rR   ç        ÚmoduleÚqueryÚkeyÚvaluer3   ÚscalingÚdropoutÚkwargsc                 ó®  — |€|                      d¦  «        dz  }t          j        ||                     dd¦  «        ¦  «        |z  }|�||z   }t          j                             |d¬¦  «        }t          j                             ||| j        ¬¦  «        }t          j        ||¦  «        }	|	                     dd¦  «         	                    ¦   «         }	|	|fS )NrF   ç      à¿r(   r	   rj   ©ÚpÚtrainingr,   )
r|   r:   ÚmatmulrI   ÚnnÚ
functionalÚsoftmaxr�   r–   Ú
contiguous)
r‹   rŒ   r�   rŽ   r3   r�   r�   r‘   Úattn_weightsÚattn_outputs
             rA   Úeager_attention_forwardrž   —   sÈ   € ð €Ø—*’*˜R‘.”. DÑ(ˆõ ”<  s§}¢}°Q¸Ñ':Ô':Ñ;Ô;¸gÑE€LàÐ!Ø# nÑ4ˆå”=×(Ò(¨¸2Ð(Ñ>Ô>€LÝ”=×(Ò(¨¸È6Ì?Ð(Ñ[Ô[€Lå”,˜|¨UÑ3Ô3€KØ×'Ò'¨¨1Ñ-Ô-×8Ò8Ñ:Ô:€Kà˜Ð$Ð$r@   c                   ó.  ‡ — e Zd ZdZ	 	 	 	 	 	 ddedededz  d	edz  d
edz  dedz  dedz  dedz  fˆ fd„Z	 	 	 	 dde	j
        de	j
        dz  dedz  de	j
        dz  de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 )ÚMusicgenAttentionz=Multi-headed attention from 'Attention Is All You Need' paperrŠ   FTNÚ	embed_dimÚ	num_headsr�   Ú
is_decoderÚbiasÚ	is_causalÚconfigÚ	layer_idxc	                 ó  •— t          ¦   «                              ¦   «          || _        || _        || _        ||z  | _        || _        | j        |z  | j        k    rt          d| j        › d|› d�¦  «        ‚| j        dz  | _        || _	        || _
        || _        t          j        |||¬¦  «        | _        t          j        |||¬¦  «        | _        t          j        |||¬¦  «        | _        t          j        |||¬¦  «        | _        d S )Nz;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).r“   ©r¤   )rW   rX   r¡   r¢   r�   Úhead_dimr¦   rM   r�   r£   r¥   r§   r˜   ÚLinearÚk_projÚv_projÚq_projÚout_proj)
rZ   r¡   r¢   r�   r£   r¤   r¥   r¦   r§   r[   s
            €rA   rX   zMusicgenAttention.__init__¶   s  ø€ õ 	‰Œ×ÒÑÔÐØ"ˆŒØ"ˆŒØˆŒØ! YÑ.ˆŒØˆŒàŒM˜IÑ%¨$¬.Ò8Ð8Ýð3ÈdÌnð 3ð 3Ø%.ð3ð 3ð 3ñô ð ð ”} dÑ*ˆŒØ$ˆŒØ"ˆŒØ"ˆŒå”i 	¨9¸4Ð@Ñ@Ô@ˆŒÝ”i 	¨9¸4Ð@Ñ@Ô@ˆŒÝ”i 	¨9¸4Ð@Ñ@Ô@ˆŒÝœ	 )¨Y¸TÐBÑBÔBˆŒˆˆr@   Úhidden_statesÚkey_value_statesÚpast_key_valuesr3   Úoutput_attentionsr‘   Úreturnc                 óˆ  — |du}|j         dd…         }g |¢d‘| j        ‘R }	|                      |¦  «                             |	¦  «                             dd¦  «        }
d}|�Ht          |t          ¦  «        r1|j                             | j	        ¦  «        }|r|j
        }n
|j        }n|}|r|n|}|r3|�1|r/|j        | j	                 j        }|j        | j	                 j        }nÚg |j         dd…         ¢d‘| j        ‘R }|                      |¦  «                             |¦  «                             dd¦  «        }|                      |¦  «                             |¦  «                             dd¦  «        }|�E|                     ||| j	        ¦  «        \  }}|r$t          |t          ¦  «        rd|j        | j	        <   t%          j        | j        j        t,          ¦  «        } || |
|||f| j        sdn| j        | j        |dœ|¤Ž\  }} |j        g |¢d‘R Ž                      ¦   «         }|                      |¦  «        }||fS )	z#Input shape: Batch x Time x ChannelNrF   r,   r(   FTrŠ   )r�   r�   r³   )rK   rª   r®   ru   rI   Ú
isinstancer   Ú
is_updatedÚgetr§   Úcross_attention_cacheÚself_attention_cacheÚlayersÚkeysÚvaluesr¬   r­   Úupdater   Úget_interfacer¦   Ú_attn_implementationrž   r–   r�   r�   Úreshaper›   r¯   )rZ   r°   r±   r²   r3   r³   r‘   Úis_cross_attentionÚinput_shapeÚhidden_shapeÚquery_statesr·   Úcurr_past_key_valuesÚcurrent_statesÚ
key_statesÚvalue_statesÚkv_shapeÚattention_interfacer�   rœ   s                       rA   rƒ   zMusicgenAttention.forward×   s¦  € ð .°TÐ9Ðð $Ô)¨#¨2¨#Ô.ˆà8˜Ð8 bÐ8¨$¬-Ð8Ð8ˆð —{’{ =Ñ1Ô1×6Ò6°|ÑDÔD×NÒNÈqÐRSÑTÔTˆàˆ
ØÐ&Ý˜/Õ+>Ñ?Ô?ð 7Ø,Ô7×;Ò;¸D¼NÑKÔK�
Ø%ð Pà+:Ô+PÐ(Ð(à+:Ô+OÐ(Ð(à'6Ð$à-?ÐRÐ)Ð)À]ˆØð 	F /Ð"=À*Ð"=à-Ô4°T´^ÔDÔIˆJØ/Ô6°t´~ÔFÔMˆLˆLàF˜Ô-¨c¨r¨cÔ2ÐF°BÐF¸¼ÐFÐFˆHØŸš ^Ñ4Ô4×9Ò9¸(ÑCÔC×MÒMÈaÐQRÑSÔSˆJØŸ;š; ~Ñ6Ô6×;Ò;¸HÑEÔE×OÒOÐPQÐSTÑUÔUˆLàÐ*à+?×+FÒ+FÀzÐS_ÐaeÔaoÑ+pÔ+pÑ(�
˜Là%ð F­*°_ÕFYÑ*ZÔ*Zð FØAE�OÔ.¨t¬~Ñ>å(?Ô(MØŒKÔ,Õ.Eñ)
ô )
Ðð %8Ð$7ØØØØØð
%
ð  $œ}Ð>�C�C°$´,Ø”LØ/ð
%
ð 
%
ð ð
%
ð 
%
Ñ!ˆ�\ð *�kÔ)Ð;¨;Ð;¸Ð;Ð;Ð;×FÒFÑHÔHˆØ—m’m KÑ0Ô0ˆà˜LÐ(Ð(r@   )rŠ   FTFNN)NNNF)r5   r6   r7   r8   r„   r>   Úboolr-   rX   r:   r‡   r   r    r   r9   rƒ   rˆ   r‰   s   @rA   r    r    ³   s�  ø€ € € € € ØGÐGð !$Ø"'Ø Ø!&Ø(,Ø $ðCð CàðCð ðCð ˜‘ð	Cð
 ˜4‘KðCð �T‰kðCð ˜$‘;ðCð  Ñ%ðCð ˜‘:ðCð Cð Cð Cð Cð CðH 15Ø(,Ø.2Ø).ðI)ð I)à”|ðI)ð  œ,¨Ñ-ðI)ð  ™ð	I)ð
 œ tÑ+ðI)ð   $™;ðI)ð Ð-Ô.ðI)ð 
ˆuŒ|˜Uœ\¨DÑ0°%¸¼Ô2EÈÑ2LÐLÔ	MðI)ð I)ð I)ð I)ð I)ð I)ð I)ð I)r@   r    c                   ó¶   ‡ — e Zd Zdde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dz  d
edz  de	e
         dej        fd„Zˆ xZS )ÚMusicgenDecoderLayerNr¦   c           
      ó´  •— t          ¦   «                              ¦   «          |j        | _        t	          | j        |j        |j        ddd||¬¦  «        | _        |j        | _        t          |j
                 | _        |j        | _        t          j        | j        ¦  «        | _        t	          | j        |j        |j        dd||¬¦  «        | _        t          j        | j        ¦  «        | _        t          j        | j        |j        d¬¦  «        | _        t          j        |j        | j        d¬¦  «        | _        t          j        | j        ¦  «        | _        d S )NTF)r¡   r¢   r�   r£   r¤   r¥   r¦   r§   )r�   r£   r¤   r¦   r§   r©   )rW   rX   Úhidden_sizer¡   r    Únum_attention_headsÚattention_dropoutÚ	self_attnr�   r   Úactivation_functionÚactivation_fnÚactivation_dropoutr˜   Ú	LayerNormÚself_attn_layer_normÚencoder_attnÚencoder_attn_layer_normr«   Úffn_dimÚfc1Úfc2Úfinal_layer_norm)rZ   r¦   r§   r[   s      €rA   rX   zMusicgenDecoderLayer.__init__$  s/  ø€ Ý‰Œ×ÒÑÔÐØÔ+ˆŒå*Ø”nØÔ0ØÔ,ØØØØØð	
ñ 	
ô 	
ˆŒð ”~ˆŒÝ# FÔ$>Ô?ˆÔØ"(Ô";ˆÔå$&¤L°´Ñ$@Ô$@ˆÔ!Ý-ØŒNØÔ&ØÔ,ØØØØð
ñ 
ô 
ˆÔõ (*¤|°D´NÑ'CÔ'CˆÔ$Ý”9˜Tœ^¨V¬^À%ÐHÑHÔHˆŒÝ”9˜Vœ^¨T¬^À%ÐHÑHÔHˆŒÝ "¤¨T¬^Ñ <Ô <ˆÔÐÐr@   Tr°   r3   Úencoder_hidden_statesÚencoder_attention_maskr²   Ú	use_cacher‘   r´   c                 óÞ  — |}|                       |¦  «        } | j        |f||dœ|¤Ž\  }}	t          j                             || j        | j        ¬¦  «        }||z   }|�]|}|                      |¦  «        } | j        |f|||dœ|¤Ž\  }}	t          j                             || j        | j        ¬¦  «        }||z   }|}|                      |¦  «        }|  	                    |  
                    |¦  «        ¦  «        }t          j                             || j        | j        ¬¦  «        }|                      |¦  «        }t          j                             || j        | j        ¬¦  «        }||z   }|S )að  
        Args:
            hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
            attention_mask (`torch.FloatTensor`): attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            encoder_hidden_states (`torch.FloatTensor`):
                cross attention input to the layer of shape `(batch, seq_len, embed_dim)`
            encoder_attention_mask (`torch.FloatTensor`): encoder attention mask of size
                `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
            past_key_values (`Cache`): cached past key and value projection states
        )r²   r3   r”   N)r±   r3   r²   )rØ   rÓ   r˜   r™   r�   r–   rÚ   rÙ   rÞ   rÕ   rÜ   rÖ   rÝ   )
rZ   r°   r3   rß   rà   r²   rá   r‘   ÚresidualÚ_s
             rA   rƒ   zMusicgenDecoderLayer.forwardE  s§  € ð* !ˆØ×1Ò1°-Ñ@Ô@ˆð *˜4œ>Øð
à+Ø)ð
ð 
ð ð	
ð 
Ñˆ�qõ œ×-Ò-¨m¸t¼|ÐVZÔVcÐ-ÑdÔdˆØ  =Ñ0ˆð !Ð,Ø$ˆHØ ×8Ò8¸ÑGÔGˆMà0˜tÔ0Øð à!6Ø5Ø /ð	 ð  ð
 ð ð  ÑˆM˜1õ œM×1Ò1°-À4Ä<ÐZ^ÔZgÐ1ÑhÔhˆMØ$ }Ñ4ˆMð !ˆØ×-Ò-¨mÑ<Ô<ˆØ×*Ò*¨4¯8ª8°MÑ+BÔ+BÑCÔCˆÝœ×-Ò-¨m¸tÔ?VÐaeÔanÐ-ÑoÔoˆØŸš Ñ/Ô/ˆÝœ×-Ò-¨m¸t¼|ÐVZÔVcÐ-ÑdÔdˆØ  =Ñ0ˆàÐr@   rV   )NNNNT)r5   r6   r7   r.   rX   r:   r‡   r   rÌ   r    r!   rƒ   rˆ   r‰   s   @rA   rÎ   rÎ   #  sê   ø€ € € € € ð=ð =Ð4ð =ð =ð =ð =ð =ð =ðH /3Ø59Ø6:Ø(,Ø!%ð:ð :à”|ð:ð œ tÑ+ð:ð  %œ|¨dÑ2ð	:ð
 !&¤¨tÑ 3ð:ð  ™ð:ð ˜$‘;ð:ð Ð+Ô,ð:ð 
Œð:ð :ð :ð :ð :ð :ð :ð :r@   rÎ   c                   óp   ‡ — e Zd ZU eed<   dZdZddgZdZdZ	dZ
 ej        ¦   «         ˆ fd„¦   «         Zˆ xZS )ÚMusicgenPreTrainedModelr¦   ÚmodelTrÎ   r    c                 óì   •— t          ¦   «                              |¦  «         t          |t          ¦  «        r<|                     |j        |j        ¦  «        }t          j        |j	        |¦  «         d S d S rV   )
rW   Ú_init_weightsr¶   rR   rc   rS   rT   ÚinitÚcopy_r^   )rZ   r‹   rg   r[   s      €rA   ré   z%MusicgenPreTrainedModel._init_weightsŒ  sm   ø€ å‰Œ×Ò˜fÑ%Ô%Ð%Ý�fÕCÑDÔDð 	4Ø ×.Ò.¨vÔ/CÀVÔEYÑZÔZˆKÝŒJ�v”~ {Ñ3Ô3Ð3Ð3Ð3ð	4ð 	4r@   )r5   r6   r7   r.   r<   Úbase_model_prefixÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_supports_flash_attnÚ_supports_sdpaÚ_supports_flex_attnr:   r†   ré   rˆ   r‰   s   @rA   ræ   ræ   ‚  s�   ø€ € € € € € à!Ð!Ð!Ñ!ØÐØ&*Ð#Ø/Ð1DÐEÐØÐØ€NØÐà€U„]�_„_ð4ð 4ð 4ð 4ñ „_ð4ð 4ð 4ð 4ð 4r@   ræ   c                   ó>  ‡ — e Zd ZdZe eedd¬¦  «         eedd¬¦  «        dœZdefˆ fd„Z	e
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d	z  dej        d	z  ded	z  dee         deez  fd„¦   «         ¦   «         ¦   «         Zˆ xZS )ÚMusicgenDecoderzw
    Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MusicgenDecoderLayer`]
    r,   rÓ   )ÚindexÚ
layer_namerÙ   )r°   Ú
attentionsÚcross_attentionsr¦   c                 óÎ  •‡‡— t          ¦   «                              ‰¦  «         ‰j        | _        ‰j        | _        ‰j        | _        ‰j        | _        ‰j        | _        ‰j	        rt          j        ‰j        ¦  «        nd| _        ‰j        dz   Št          j        ˆˆfd„t!          ‰j        ¦  «        D ¦   «         ¦  «        | _        t%          ‰j        ‰j        ¦  «        | _        t          j        ˆfd„t!          ‰j        ¦  «        D ¦   «         ¦  «        | _        t          j        ‰j        ¦  «        | _        ‰j        | _        d| _        |                      ¦   «          d S )Nç      ð?r,   c                 óD   •— g | ]}t          j        ‰‰j        ¦  «        ‘ŒS r?   )r˜   Ú	EmbeddingrÐ   )Ú.0rä   r¦   r¡   s     €€rA   ú
<listcomp>z,MusicgenDecoder.__init__.<locals>.<listcomp>ª  s(   ø€ Ð^Ð^Ð^¸Q�RŒ\˜) VÔ%7Ñ8Ô8Ð^Ð^Ð^r@   c                 ó2   •— g | ]}t          ‰|¬ ¦  «        ‘ŒS ))r§   )rÎ   )rü   Úir¦   s     €rA   rý   z,MusicgenDecoder.__init__.<locals>.<listcomp>³  s'   ø€ Ð`Ð`Ð`¸1Õ! &°AÐ6Ñ6Ô6Ð`Ð`Ð`r@   F)rW   rX   r�   Ú	layerdropÚmax_position_embeddingsÚmax_target_positionsrÐ   Úd_modelÚnum_codebooksÚscale_embeddingrl   ÚsqrtÚembed_scaleÚ
vocab_sizer˜   Ú
ModuleListÚrangeÚembed_tokensrR   Úembed_positionsÚnum_hidden_layersr»   r×   Ú
layer_normrÀ   Úattn_implementationÚgradient_checkpointingÚ	post_init)rZ   r¦   r¡   r[   s    `@€rA   rX   zMusicgenDecoder.__init__Ÿ  sP  øøø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø”~ˆŒØÔ)ˆŒØ$*Ô$BˆÔ!ØÔ)ˆŒØ#Ô1ˆÔØ<BÔ<RÐ[�4œ9 VÔ%7Ñ8Ô8Ð8ÐX[ˆÔàÔ%¨Ñ)ˆ	ÝœMØ^Ð^Ð^Ð^Ð^Å%ÈÔH\ÑB]ÔB]Ð^Ñ^Ô^ñ
ô 
ˆÔõ  EØÔ*ØÔñ 
ô  
ˆÔõ
 ”mØ`Ð`Ð`Ð`ÅÀfÔF^Ñ@_Ô@_Ð`Ñ`Ô`ñ
ô 
ˆŒõ œ, vÔ'9Ñ:Ô:ˆŒØ#)Ô#>ˆÔ à&+ˆÔ#à�ŠÑÔÐÐÐr@   NrB   r3   rß   rà   r²   Úinputs_embedsrá   r‘   r´   c                 óâ  ‡ ‡— |�|�t          d¦  «        ‚|�3|                     d‰ j        |j        d         ¦  «        Š‰j        \  }	}
}n#|�|dd…dd…dd…f         Šnt          d¦  «        ‚|r8|€6t	          t          ‰ j        ¬¦  «        t          ‰ j        ¬¦  «        ¦  «        }|�|                     ¦   «         nd}|€)t          ˆˆ fd„t          |
¦  «        D ¦   «         ¦  «        }t          ‰ j        |||¬¦  «        }t          ‰ j        |||¬	¦  «        }‰                      ‰|¦  «        }||                     |j        ¦  «        z   }t          j                             |‰ j        ‰ j        ¬
¦  «        }t'          ‰ j        ¦  «        D ]<\  }}t+          j        dd¦  «        }‰ j        r|‰ j        k     rŒ- ||||f|||dœ|¤Ž}Œ=‰                      |¦  «        }t3          ||¬¦  «        S )á$  
        input_ids (`torch.LongTensor` of shape `(batch_size * num_codebooks, sequence_length)`):
            Indices of input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.

            Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
            such as with the [`EncodecModel`]. See [`EncodecModel.encode`] for details.

            [What are input IDs?](../glossary#input-ids)

            <Tip warning={true}>

            The `input_ids` will automatically be converted from shape `(batch_size * num_codebooks,
            target_sequence_length)` to `(batch_size, num_codebooks, target_sequence_length)` in the forward pass. If
            you obtain audio codes from an audio encoding model, such as [`EncodecModel`], ensure that the number of
            frames is equal to 1, and that you reshape the audio codes from `(frames, batch_size, num_codebooks,
            target_sequence_length)` to `(batch_size * num_codebooks, target_sequence_length)` prior to passing them as
            `input_ids`.

            </Tip>
        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.LongTensor` of shape `(batch_size, encoder_sequence_length)`, *optional*):
            Mask to avoid performing cross-attention on padding tokens indices of encoder input_ids. 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)
        NzTYou cannot specify both decoder_input_ids and decoder_inputs_embeds at the same timerF   zEYou have to specify either decoder_input_ids or decoder_inputs_embeds)r¦   r   c              3   óX   •K  — | ]$} ‰j         |         ‰d d …|f         ¦  «        V — Œ%d S rV   )r  )rü   ÚcodebookÚinputrZ   s     €€rA   ú	<genexpr>z*MusicgenDecoder.forward.<locals>.<genexpr>ú  sD   øè è € ÐuÐuÐT\Ð ; Ô 1°(Ô ;¸EÀ!À!À!ÀXÀ+Ô<NÑ OÔ OÐuÐuÐuÐuÐuÐur@   )r¦   r  r3   r²   )r¦   r  r3   rß   r”   r,   )rà   r²   rá   )Úlast_hidden_stater²   )rM   rÁ   r  rK   r   r   r¦   Úget_seq_lengthÚsumr
  r   r   r  re   ra   r˜   r™   r�   r–   Ú	enumerater»   ÚrandomÚuniformr   r  r   )rZ   rB   r3   rß   rà   r²   r  rá   r‘   r   r  r�   rz   Ú	positionsr°   ÚidxÚdecoder_layerÚdropout_probabilityr  s   `                 @rA   rƒ   zMusicgenDecoder.forward¼  sf  øø€ ðZ Ð  ]Ð%>ÝÐsÑtÔtÐtØÐ"à×%Ò% b¨$Ô*<¸i¼oÈbÔ>QÑRÔRˆEØ*/¬+Ñ'ˆC�  ØÐ&Ø! ! ! ! Q Q Q¨¨¨ )Ô,ˆEˆEåÐdÑeÔeÐeàð 	v˜Ð0Ý1µ,ÀdÄkÐ2RÑ2RÔ2RÕT`ÐhlÔhsÐTtÑTtÔTtÑuÔuˆOàETÐE` ×!?Ò!?Ñ!AÔ!AÐ!AÐfgÐàÐ ÝÐuÐuÐuÐuÐuÕ`eÐfsÑ`tÔ`tÐuÑuÔuÑuÔuˆMå+Ø”;Ø'Ø)Ø+ð	
ñ 
ô 
ˆõ ";Ø”;Ø'Ø1Ø"7ð	"
ñ "
ô "
Ðð ×(Ò(¨Ð0FÑGÔGˆ	Ø%¨	¯ª°]Ô5IÑ(JÔ(JÑJˆÝœ×-Ò-¨m¸t¼|ÐVZÔVcÐ-ÑdÔdˆå"+¨D¬KÑ"8Ô"8ð 	ð 	ÑˆC�å"(¤.°°AÑ"6Ô"6ÐØŒ}ð Ð"5¸¼Ò"FÐ"FØà)˜MØØØ%ðð (>Ø /Ø#ðð ð ðð ˆMˆMð Ÿš¨Ñ6Ô6ˆå8Ø+Ø+ð
ñ 
ô 
ð 	
r@   ©NNNNNNN)r5   r6   r7   r8   rÎ   r&   r    Ú_can_record_outputsr.   rX   r%   r'   r"   r:   r=   r‡   r;   r   rÌ   r    r!   r9   r   rƒ   rˆ   r‰   s   @rA   ró   ró   ”  s‚  ø€ € € € € ðð ð
 .Ø$�nÐ%6¸aÈKÐXÑXÔXØ*˜NÐ+<ÀAÐR`ÐaÑaÔaðð ÐðÐ4ð ð ð ð ð ð ð:  ØØð .2Ø.2Ø:>Ø:>Ø(,Ø26Ø!%ðd
ð d
àÔ# dÑ*ðd
ð œ tÑ+ðd
ð  %Ô0°4Ñ7ð	d
ð
 !&Ô 0°4Ñ 7ðd
ð  ™ðd
ð Ô(¨4Ñ/ðd
ð ˜$‘;ðd
ð Ð+Ô,ðd
ð 
Ð:Ñ	:ðd
ð d
ð d
ñ „^ñ „_ñ  Ôðd
ð d
ð d
ð d
ð d
r@   ró   c                   ó
  ‡ — e Zd Zdefˆ fd„Zd„ Zd„ Ze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dz  de
j        dz  dedz  dee         deez  fd„¦   «         ¦   «         ¦   «         Zˆ xZS )ÚMusicgenModelr¦   c                 óš   •— t          ¦   «                              |¦  «         t          |¦  «        | _        |                      ¦   «          d S rV   )rW   rX   ró   Údecoderr  ©rZ   r¦   r[   s     €rA   rX   zMusicgenModel.__init__(  s@   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ý& vÑ.Ô.ˆŒà�ŠÑÔÐÐÐr@   c                 ó   — | j         j        S rV   ©r(  r  ©rZ   s    rA   Úget_input_embeddingsz"MusicgenModel.get_input_embeddings.  s   € ØŒ|Ô(Ð(r@   c                 ó   — || j         _        d S rV   r+  ©rZ   rŽ   s     rA   Úset_input_embeddingsz"MusicgenModel.set_input_embeddings1  s   € Ø$)ˆŒÔ!Ð!Ð!r@   NrB   r3   rß   rà   r²   r  rá   r‘   r´   c                 ó0   —  | j         d|||||||dœ|¤Ž}	|	S )r  )rB   r3   rà   rß   r²   r  rá   r?   )r(  )
rZ   rB   r3   rß   rà   r²   r  rá   r‘   Údecoder_outputss
             rA   rƒ   zMusicgenModel.forward4  sP   € ðZ FRÀTÄ\ð 	F
ØØ)Ø#9Ø"7Ø+Ø'Øð	F
ð 	F
ð ð	F
ð 	F
ˆð Ðr@   r#  )r5   r6   r7   r.   rX   r-  r0  r%   r'   r"   r:   r=   r‡   r;   r   rÌ   r    r!   r9   r   rƒ   rˆ   r‰   s   @rA   r&  r&  &  sG  ø€ € € € € ðÐ4ð ð ð ð ð ð ð)ð )ð )ð*ð *ð *ð  ØØð .2Ø.2Ø:>Ø:>Ø(,Ø26Ø!%ð5ð 5àÔ# dÑ*ð5ð œ tÑ+ð5ð  %Ô0°4Ñ7ð	5ð
 !&Ô 0°4Ñ 7ð5ð  ™ð5ð Ô(¨4Ñ/ð5ð ˜$‘;ð5ð Ð+Ô,ð5ð 
Ð:Ñ	:ð5ð 5ð 5ñ „^ñ „_ñ  Ôð5ð 5ð 5ð 5ð 5r@   r&  zK
    The MusicGen decoder model with a language modelling head on top.
    )Úcustom_introc                   ó  ‡ — e Zd ZdZdefˆ fd„Zd„ Zd„ Zd„ Zd„ Z	e
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dz  dej        dz  dej        dz  dedz  dee         deez  fd„¦   «         ¦   «         ¦   «         Z	 	 	 	 	 	 	 d#d„Zd$d	ej        dededz  fd„Zed„ ¦   «         Z ej        ¦   «         	 	 	 	 	 	 d%dej        dz  dedz  dedz  de dz  dedz  de!d          fd!„¦   «         Z"ˆ xZ#S )&ÚMusicgenForCausalLM©Úaudior¦   c                 ó"  •‡— t          ¦   «                              ‰¦  «         t          ‰¦  «        | _        ‰j        | _        t          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _        |  	                    ¦   «          d S )Nc                 óR   •— g | ]#}t          j        ‰j        ‰j        d ¬¦  «        ‘Œ$S )Fr©   )r˜   r«   rÐ   r  )rü   rä   r¦   s     €rA   rý   z0MusicgenForCausalLM.__init__.<locals>.<listcomp>~  s0   ø€ ÐoÐoÐoÈa�RŒY�vÔ)¨6Ô+<À5ÐIÑIÔIÐoÐoÐor@   )
rW   rX   r&  rç   r  r˜   r	  r
  Úlm_headsr  r)  s    `€rA   rX   zMusicgenForCausalLM.__init__w  s…   øø€ Ý‰Œ×Ò˜Ñ Ô Ð å" 6Ñ*Ô*ˆŒ
à#Ô1ˆÔÝœØoÐoÐoÐoÕSXÐY_ÔYmÑSnÔSnÐoÑoÔoñ
ô 
ˆŒð
 	�ŠÑÔÐÐÐr@   c                 ó$   — | j         j        j        S rV   ©rç   r(  r  r,  s    rA   r-  z(MusicgenForCausalLM.get_input_embeddings„  s   € ØŒzÔ!Ô.Ð.r@   c                 ó(   — || j         j        _        d S rV   r<  r/  s     rA   r0  z(MusicgenForCausalLM.set_input_embeddings‡  s   € Ø*/ˆŒ
ÔÔ'Ð'Ð'r@   c                 ó   — | j         S rV   ©r:  r,  s    rA   Úget_output_embeddingsz)MusicgenForCausalLM.get_output_embeddingsŠ  s
   € ØŒ}Ðr@   c                 ó   — || _         d S rV   r?  ©rZ   Únew_embeddingss     rA   Úset_output_embeddingsz)MusicgenForCausalLM.set_output_embeddings�  s   € Ø&ˆŒˆˆr@   NrB   r3   rß   rà   r²   r  Úlabelsrá   r‘   r´   c	           
      ó’  ‡— |�)|€'|€%t          || j        j        | j        j        ¦  «        } | j        |f||||||dœ|	¤Ž}
|
j        Št          j        ˆfd„| j        D ¦   «         d¬¦  «        }d}|��|dd…dd…|j	        d          d…f         }t          ¦   «         }t          j        g | j        ¬¦  «        }|                     || j        j        k    d¦  «        }t          | j        j        ¦  «        D ]}}|dd…|f                              ¦   «                              d|j	        d         ¦  «        }|d	|f                              ¦   «                              d¦  «        }| |||¦  «        z  }Œ~|| j        j        z  } |j        dg|j	        d
d…         ¢R Ž }t'          |||
j        |
j        |
j        |
j        ¬¦  «        S )aÝ  
        input_ids (`torch.LongTensor` of shape `(batch_size * num_codebooks, sequence_length)`):
            Indices of input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.

            Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
            such as with the [`EncodecModel`]. See [`EncodecModel.encode`] for details.

            [What are input IDs?](../glossary#input-ids)

            <Tip warning={true}>

            The `input_ids` will automatically be converted from shape `(batch_size * num_codebooks,
            target_sequence_length)` to `(batch_size, num_codebooks, target_sequence_length)` in the forward pass. If
            you obtain audio codes from an audio encoding model, such as [`EncodecModel`], ensure that the number of
            frames is equal to 1, and that you reshape the audio codes from `(frames, batch_size, num_codebooks,
            target_sequence_length)` to `(batch_size * num_codebooks, target_sequence_length)` prior to passing them as
            `input_ids`.

            </Tip>
        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.LongTensor` of shape `(batch_size, encoder_sequence_length)`, *optional*):
            Mask to avoid performing cross-attention on padding tokens indices of encoder input_ids. 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)
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length, num_codebooks)`, *optional*):
            Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
            `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
            are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`
        N)r3   rß   rà   r²   r  rá   c                 ó&   •— g | ]} |‰¦  «        ‘ŒS r?   r?   )rü   Úheadr°   s     €rA   rý   z/MusicgenForCausalLM.forward.<locals>.<listcomp>Ó  s#   ø€ Ð OÐ OÐ O¸   mÑ!4Ô!4Ð OÐ OÐ Or@   r,   rj   ©ra   rH   rF   .r(   )ÚlossÚlogitsr²   r°   rö   r÷   )rP   r¦   rC   Úbos_token_idrç   r  r:   Ústackr:  rK   r   rv   ra   Úmasked_fillr
  r  r›   ru   rÁ   r   r²   r°   rö   r÷   )rZ   rB   r3   rß   rà   r²   r  rE  rá   r‘   ÚoutputsÚ	lm_logitsrJ  rK  Úloss_fctr  Úcodebook_logitsÚcodebook_labelsr°   s                     @rA   rƒ   zMusicgenForCausalLM.forward�  s  ø€ ðf Ð YÐ%6¸=Ð;PÝ*¨6°4´;Ô3KÈTÌ[ÔMeÑfÔfˆIà=G¸T¼ZØð	>
à)Ø"7Ø#9Ø+Ø'Øð	>
ð 	>
ð ð	>
ð 	>
ˆð  Ô1ˆå”KÐ OÐ OÐ OÐ OÀÄÐ OÑ OÔ OÐUVÐWÑWÔWˆ	àˆØÑð ˜q˜q˜q ! ! ! f¤l°1¤oÐ%5Ð%7Ð%7Ð7Ô8ˆFå'Ñ)Ô)ˆHÝ”;˜r¨$¬+Ð6Ñ6Ô6ˆDð ×'Ò'¨°$´+Ô2JÒ(JÈDÑQÔQˆFõ " $¤+Ô";Ñ<Ô<ð Cð C�Ø"(¨¨¨¨H¨Ô"5×"@Ò"@Ñ"BÔ"B×"GÒ"GÈÈFÌLÐY[ÔL\Ñ"]Ô"]�Ø"(¨¨h¨Ô"7×"BÒ"BÑ"DÔ"D×"IÒ"IÈ"Ñ"MÔ"M�Ø˜˜ °/ÑBÔBÑB��à˜$œ+Ô3Ñ3ˆDð &�IÔ% bÐ?¨9¬?¸1¸2¸2Ô+>Ð?Ð?Ð?ˆ	å0ØØØ#Ô3Ø!Ô/ØÔ)Ø$Ô5ð
ñ 
ô 
ð 	
r@   Tc	                 ó*  — |€/|                       || j        j        | j        j        ¬¦  «        \  }}|                      ||¦  «        }|�2|dk    r,|                     d¦  «        }|�|                     d¦  «        }|�|d d …dd …f         }||||||dœS )N©rC   Ú
max_lengthr,   ©r(   r,   rF   )rB   r3   rß   rà   r²   rá   )Úbuild_delay_pattern_maskÚgeneration_configrC   rV  Úapply_delay_pattern_maskÚrepeat)
rZ   rB   r3   rß   rà   r²   rá   Údelay_pattern_maskr4   r‘   s
             rA   Úprepare_inputs_for_generationz1MusicgenForCausalLM.prepare_inputs_for_generation÷  sÕ   € ð Ð%Ø,0×,IÒ,IØØ!Ô3Ô@ØÔ1Ô<ð -Jñ -ô -Ñ)ˆIÐ)ð ×1Ò1°)Ð=OÑPÔPˆ	àÐ%¨.¸1Ò*<Ð*<ð "×(Ò(¨Ñ0Ô0ˆIØÐ)Ø!/×!6Ò!6°vÑ!>Ô!>�àÐ&Ø! ! ! ! R S S &Ô)ˆIð #Ø,Ø%:Ø&<Ø.Ø"ð
ð 
ð 	
r@   rC   rV  c                 ó6  — |                      d| j        |j        d         ¦  «        }|j        \  }}}|�|n| j        j        }t          j        |||ft
          j        |j        ¬¦  «        dz  }| j	        j
        dk    r|dz  n|}|d|z  dz
  k     r2|                      ||z  d¦  «        |                      ||z  d¦  «        fS t          |¦  «        D ]p}	| j	        j
        dk    r|dd…|	f         |dd…|	|	||	z   …f<   Œ,|dd…d|	z  f         |dd…d|	z  |	||	z   …f<   |dd…d|	z  dz   f         |dd…d|	z  dz   |	||	z   …f<   Œqt          j        t          j        ||ft
          j        ¬¦  «        ||z
  dz   ¬¦  «        }
|
t          j        t          j        ||ft
          j        ¬¦  «        ¦  «        z   }
| j	        j
        dk    r|
                     dd¬	¦  «        }
|
                     |j        ¦  «         }||z  | |z  z   }|dd…ddd…f         }|dk                         ¦   «         dd…df         }t%          |¦  «        dk    rt'          |¦  «        }n|}|                      ||z  d¦  «        }|d
d|…f                               ||z  d¦  «        }||fS )aD  Build a delayed pattern mask to the input_ids. Each codebook is offset by the previous codebook by
        one, giving a delayed pattern mask at the start of sequence and end of sequence. Take the example where there
        are 4 codebooks and a max sequence length of 8, we have the delayed pattern mask of shape `(codebooks,
        seq_len)`:
        - [P, -1, -1, -1, -1, P, P, P]
        - [P, P, -1, -1, -1, -1, P, P]
        - [P, P, P, -1, -1, -1, -1, P]
        - [P, P, P, P, -1, -1, -1, -1]
        where P is the special padding token id and -1 indicates that the token is valid for prediction. If we include
        a prompt (decoder input ids), the -1 positions indicate where new tokens should be predicted. Otherwise, the
        mask is set to the value in the prompt:
        - [P, a, b, -1, -1, P, P, P]
        - [P, P, c, d, -1, -1, P, P]
        - [P, P, P, e, f, -1, -1, P]
        - [P, P, P, P, g, h, -1, -1]
        where a-h indicate the input prompt (decoder input ids) that are offset by 1. Now, we only override the -1
        tokens in our prediction.
        rF   Nr_   r(   r,   ri   )Údiagonalr   rj   .)rÁ   r  rK   rY  rV  r:   ÚonesÚlongra   r¦   Úaudio_channelsr
  ÚtriurÌ   ÚtrilÚrepeat_interleavere   ÚnonzeroÚlenÚmin)rZ   rB   rC   rV  r   r  r�   Úinput_ids_shiftedÚchannel_codebooksr  Údelay_patternÚmaskÚfirst_codebook_idsÚ	start_idsÚfirst_start_idÚpattern_masks                   rA   rX  z,MusicgenForCausalLM.build_delay_pattern_mask!  sL  € ð( ×%Ò% b¨$Ô*<¸i¼oÈbÔ>QÑRÔRˆ	Ø&/¤oÑ#ˆˆ]˜Gà#-Ð#9�Z�Z¸tÔ?UÔ?`ˆ
åŒJ˜˜]¨JÐ7½u¼zÐR[ÔRbÐcÑcÔcÐfhÑhð 	ð 37´+Ô2LÐPQÒ2QÐ2Q˜M¨QÑ.Ð.ÐWdÐà˜Ð-Ñ-°Ñ1Ò1Ð1Ø×$Ò$ S¨=Ñ%8¸"Ñ=Ô=Ð?P×?XÒ?XÐY\Ð_lÑYlÐnpÑ?qÔ?qÐqÐqõ Ð/Ñ0Ô0ð 	wð 	wˆHØŒ{Ô)¨QÒ.Ð.àPYÐZ[ÐZ[ÐZ[Ð]eÐZeÔPfÐ! ! ! ! X¨x¸'ÀHÑ:LÐ/LÐ"LÑMÐMð U^Ð^_Ð^_Ð^_ÐabÐemÑamÐ^mÔTnÐ! ! ! ! Q¨¡\°8¸gÈÑ>PÐ3PÐ"PÑQØXaÐbcÐbcÐbcÐefÐiqÑeqÐtuÑeuÐbuÔXvÐ! ! ! ! Q¨¡\°AÑ%5°xÀ'ÈHÑBTÐ7TÐ"TÑUÐUõ œ
ÝŒJÐ)¨:Ð6½e¼jÐIÑIÔIÐT^ÐarÑTrÐuvÑTvð
ñ 
ô 
ˆð &­¬
µ5´:Ð?PÐR\Ð>]ÕejÔeoÐ3pÑ3pÔ3pÑ(qÔ(qÑqˆàŒ;Ô%¨Ò*Ð*à)×;Ò;¸AÀ1Ð;ÑEÔEˆMà× Ò  Ô!1Ñ2Ô2Ð2ˆØÐ,Ñ,°¨u°|Ñ/CÑCˆ	ð ' q q q¨!¨Q¨Q¨Q wÔ/ÐØ'¨2Ò-×6Ò6Ñ8Ô8¸¸¸¸A¸Ô>ˆ	Ýˆy‰>Œ>˜AÒÐÝ  ™^œ^ˆNˆNð %ˆNð !×(Ò(¨¨}Ñ)<¸bÑAÔAˆØ˜c ? N ?Ð2Ô3×;Ò;¸CÀ-Ñ<OÐQSÑTÔTˆ	Ø˜,Ð&Ð&r@   c                 ól   — | j         d         }|dd|…f         }t          j        |dk    | |¦  «        } | S )z®Apply a delay pattern mask to the decoder input ids, only preserving predictions where
        the mask is set to -1, and otherwise setting to the value detailed in the mask.rF   .N)rK   r:   Úwhere)rB   Údecoder_pad_token_maskr�   s      rA   rZ  z,MusicgenForCausalLM.apply_delay_pattern_maskj  sC   € ð ”/ "Ô%ˆØ!7¸¸X¸g¸X¸Ô!FÐÝ”KÐ 6¸"Ò <¸iÐI_Ñ`Ô`ˆ	ØÐr@   ÚinputsrY  Úlogits_processorÚstopping_criteriaÚsynced_gpusÚstreamerr/   c           	      ód  — |€| j         }t          j        |¦  «        } |j        di |¤Ž}|                     ¦   «          |                      |                     ¦   «         ¦  «         |�|nt          ¦   «         }|�|nt          ¦   «         }d|v}	|                     dd¦  «        du}
|  	                    ||j
        |¦  «        \  }}}|j        d         | j        z  }|                      ||
|j        ¬¦  «         |j        |d<   |j        |d<   |                     dd¦  «        €|	r|                      |||¦  «        |d<   |j        d         }|                     d	¦  «        du o|j        du}|                     d
¦  «        du o|j        du}|                      ||||||¬¦  «        }|                      |||¦  «         |j        dz
  }|j        d         |k    r"|dk    r| j        j        s||j        d         z  }|                      ||d||¬¦  «         |                      ||j        |j        ¬¦  «        \  }}|�'|                     |                     ¦   «         ¦  «         ||d<   |                     ¦   «         }|j        �9|j        dk    r.|                     t?          |j        ¦  «        ¦  «         d|_        |                       |||d||j        ¬¦  «        }|  !                    ||¬¦  «        }|tD          j#        tD          j$        fv r- | j%        d||j&        dœ|¤Ž\  }} | j'        |f|||||dœ|¤Ž}ntQ          d¦  «        ‚|j)        r|j*        }n|}|  +                    ||d         ¦  «        }|||j,        k              -                    || j        d¦  «        }|j)        r	||_*        |S |S )á5  

        Generates sequences of token ids for models with a language modeling head.

        <Tip warning={true}>

        Most generation-controlling parameters are set in `generation_config` which, if not passed, will be set to the
        model's default generation configuration. You can override any `generation_config` by passing the corresponding
        parameters to generate(), e.g. `.generate(inputs, num_beams=4, do_sample=True)`.

        For an overview of generation strategies and code examples, check out the [following
        guide](./generation_strategies).

        </Tip>

        Parameters:
            inputs (`torch.Tensor` of varying shape depending on the modality, *optional*):
                The sequence used as a prompt for the generation or as model inputs to the encoder. If `None` the
                method initializes it with `bos_token_id` and a batch size of 1. For decoder-only models `inputs`
                should be in the format `input_ids`. For encoder-decoder models *inputs* can represent any of
                `input_ids`, `input_values`, `input_features`, or `pixel_values`.
            generation_config (`~generation.GenerationConfig`, *optional*):
                The generation configuration to be used as base parametrization for the generation call. `**kwargs`
                passed to generate matching the attributes of `generation_config` will override them. If
                `generation_config` is not provided, the default will be used, which had the following loading
                priority: 1) from the `generation_config.json` model file, if it exists; 2) from the model
                configuration. Please note that unspecified parameters will inherit [`~generation.GenerationConfig`]'s
                default values, whose documentation should be checked to parameterize generation.
            logits_processor (`LogitsProcessorList`, *optional*):
                Custom logits processors that complement the default logits processors built from arguments and
                generation config. If a logit processor is passed that is already created with the arguments or a
                generation config an error is thrown. This feature is intended for advanced users.
            stopping_criteria (`StoppingCriteriaList`, *optional*):
                Custom stopping criteria that complement the default stopping criteria built from arguments and a
                generation config. If a stopping criteria is passed that is already created with the arguments or a
                generation config an error is thrown. This feature is intended for advanced users.
            synced_gpus (`bool`, *optional*, defaults to `False`):
                Whether to continue running the while loop until max_length (needed to avoid deadlocking with
                `FullyShardedDataParallel` and DeepSpeed ZeRO Stage 3).
            streamer (`BaseStreamer`, *optional*):
                Streamer object that will be used to stream the generated sequences. Generated tokens are passed
                through `streamer.put(token_ids)` and the streamer is responsible for any further processing.
            kwargs (`dict[str, Any]`, *optional*):
                Ad hoc parametrization of `generate_config` and/or additional model-specific kwargs that will be
                forwarded to the `forward` function of the model. If the model is an encoder-decoder model, encoder
                specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with *decoder_*.

        Return:
            [`~utils.ModelOutput`] or `torch.LongTensor`: A [`~utils.ModelOutput`] (if `return_dict_in_generate=True`
            or when `config.return_dict_in_generate=True`) or a `torch.FloatTensor`.

                If the model is *not* an encoder-decoder model (`model.config.is_encoder_decoder=False`), the possible
                [`~utils.ModelOutput`] types are:

                    - [`~generation.GenerateDecoderOnlyOutput`],
                    - [`~generation.GenerateBeamDecoderOnlyOutput`]

                If the model is an encoder-decoder model (`model.config.is_encoder_decoder=True`), the possible
                [`~utils.ModelOutput`] types are:

                    - [`~generation.GenerateEncoderDecoderOutput`],
                    - [`~generation.GenerateBeamEncoderDecoderOutput`]
        Nr2   r3   r   rI  rá   r4   rF   rV  Ú
min_length©rY  Úhas_default_max_lengthÚhas_default_min_lengthÚmodel_input_nameÚinputs_tensorÚinput_ids_lengthr,   r  )Úgeneration_modeÚ
batch_sizeÚmax_cache_lengthrU  r\  ©rY  Úinput_ids_seq_lengthÚencoder_input_idsÚprefix_allowed_tokens_fnru  ra   ©rY  rv  )rB   Úexpand_size)ru  rv  rY  rw  rx  úŒGot incompatible mode for generation, should be one of greedy or sampling. Ensure that beam search is de-activated by setting `num_beams=1`.r?   ).rY  ÚcopyÚdeepcopyr¾   ÚvalidateÚ_validate_model_kwargsr   r   r¸   Ú_prepare_model_inputsrL  rK   r  Ú_prepare_special_tokensra   rá   r4   Ú&_prepare_attention_mask_for_generationrV  r{  Ú_prepare_generated_lengthÚ_validate_generated_lengthr¦   Úis_encoder_decoderÚ_prepare_cache_for_generationrX  Ú_decoder_start_token_tensorÚputÚcpuÚget_generation_modeÚappendr   Ú_get_logits_processorÚ_get_stopping_criteriar   ÚSAMPLEÚGREEDY_SEARCHÚ_expand_inputs_for_generationÚnum_return_sequencesÚ_samplerM   Úreturn_dict_in_generateÚ	sequencesrZ  Ú_pad_token_tensorrÁ   )rZ   rt  rY  ru  rv  rw  rx  r‘   Úmodel_kwargsÚrequires_attention_maskÚkwargs_has_attention_maskrB   r  rƒ  r�  r}  r~  r„  r\  r‚  rO  Ú
output_idss                         rA   ÚgeneratezMusicgenForCausalLM.generates  sç  € ðV Ð$Ø $Ô 6Ðå œMÐ*;Ñ<Ô<ÐØ/Ð(Ô/Ð9Ð9°&Ð9Ð9ˆØ×"Ò"Ñ$Ô$Ð$Ø×#Ò# L×$5Ò$5Ñ$7Ô$7Ñ8Ô8Ð8ð 0@Ð/KÐ+Ð+ÕQdÑQfÔQfÐØ1BÐ1NÐ-Ð-ÕThÑTjÔTjÐà"3¸<Ð"GÐØ$0×$4Ò$4Ð5EÀtÑ$LÔ$LÐTXÐ$XÐ!ð 59×4NÒ4NØÐ%Ô2°Lñ5
ô 5
Ñ1ˆ	Ð# \ð ”_ QÔ'¨4Ô+=Ñ=ˆ
Ø×$Ò$Ð%6Ð8QÐZcÔZjÐ$ÑkÔkÐkð %6Ô$?ˆ�[Ñ!Ø):Ô)IˆÐ%Ñ&à×ÒÐ,¨dÑ3Ô3Ð;Ð@WÐ;Ø-1×-XÒ-XØÐ,¨lñ.ô .ˆLÐ)Ñ*ð
 %œ?¨2Ô.ÐØ!'§¢¨LÑ!9Ô!9¸TÐ!AÐ!nÐFWÔFbÐjnÐFnÐØ!'§¢¨LÑ!9Ô!9¸TÐ!AÐ!nÐFWÔFbÐjnÐFnÐØ ×:Ò:Ø/Ø#9Ø#9Ø-Ø#Ø-ð ;ñ 
ô 
Ðð 	×'Ò'Ð(9Ð;KÐMcÑdÔdÐdð -Ô7¸!Ñ;ÐàÔ" 1Ô%Ð)9Ò9Ð9Ø  OÒ3Ð3Ø”KÔ2ð 4ð Ð 0Ô 6°qÔ 9Ñ9ÐØ×*Ò*ØØØ Ø!Ø-ð 	+ñ 	
ô 	
ð 	
ð )-×(EÒ(EØØ*ÔFØ(Ô3ð )Fñ )
ô )
Ñ%ˆ	Ð%ð ÐØ�LŠL˜Ÿš™œÑ)Ô)Ð)ð .@ˆÐ)Ñ*ð ,×?Ò?ÑAÔAˆð Ô+Ð7Ð<MÔ<\Ð_`Ò<`Ð<`Ø×#Ò#Õ$IÐJ[ÔJjÑ$kÔ$kÑlÔlÐlØ/3ÐÔ,ð  ×5Ò5Ø/Ø!1Ø'Ø%)Ø-ØÔ#ð 6ñ 
ô 
Ðð !×7Ò7Ø/ÐCTð 8ñ 
ô 
Ðð �~Ô4µnÔ6RÐSÐSÐSà&H dÔ&Hð 'Ø#Ø-ÔBð'ð 'ð ð'ð 'Ñ#ˆI�|ð #�d”lØðà!1Ø"3Ø"3Ø'Ø!ðð ð ðð ˆGˆGõ ðTñô ð ð
 Ô4ð 	!Ø Ô*ˆJˆJà ˆJð ×2Ò2°:¸|ÐL`Ô?aÑbÔbˆ
ð   
Ð.?Ô.QÒ QÔR×ZÒZØ˜Ô*¨Bñ
ô 
ˆ
ð Ô4ð 	Ø *ˆGÔØˆNàÐr@   ©NNNNNNNN)NNNNTNNrV   ©NNNNNN)$r5   r6   r7   Úoutput_modalitiesr.   rX   r-  r0  r@  rD  r%   r'   r"   r:   r=   r‡   r;   r   rÌ   r    r!   r9   r   rƒ   r]  r„   rX  r…   rZ  r†   r   r   r   r   rª  rˆ   r‰   s   @rA   r5  r5  o  sÄ  ø€ € € € € ð #ÐðÐ4ð ð ð ð ð ð ð/ð /ð /ð0ð 0ð 0ðð ð ð'ð 'ð 'ð  ØØð .2Ø.2Ø:>Ø:>Ø(,Ø26Ø*.Ø!%ðb
ð b
àÔ# dÑ*ðb
ð œ tÑ+ðb
ð  %Ô0°4Ñ7ð	b
ð
 !&Ô 0°4Ñ 7ðb
ð  ™ðb
ð Ô(¨4Ñ/ðb
ð Ô  4Ñ'ðb
ð ˜$‘;ðb
ð Ð+Ô,ðb
ð 
Ð2Ñ	2ðb
ð b
ð b
ñ „^ñ „_ñ  Ôðb
ðN Ø"Ø#ØØØØð(
ð (
ð (
ð (
ðTG'ð G'°%Ô2Bð G'ÐRUð G'ÐcfÐimÑcmð G'ð G'ð G'ð G'ðR ðð ñ „\ðð €U„]�_„_ð '+Ø59Ø7;Ø9=Ø#'Ø-1ðZð Zà”˜tÑ#ðZð ,¨dÑ2ðZð .°Ñ4ð	Zð
 0°$Ñ6ðZð ˜D‘[ðZð ˜>Ô*ðZð Zð Zñ „_ðZð Zð Zð Zð Zr@   r5  z_
    The composite MusicGen model with a text encoder, audio encoder and Musicgen decoder,
    c                    óR  ‡ — e Zd ZU eed<   dZdZdZdZ	 	 	 	 d<dedz  de	dz  de	dz  d	e
dz  fˆ fd
„Zd„ Zd„ Zd„ Ze	 	 	 d=dedz  dedz  dedz  de	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j        dz  deej                 dz  dedz  dej        dz  dej        dz  dej        dz  dedz  dee         deez  fd„¦   «         ¦   «         Z	 	 	 	 	 	 	 	 d?d edz  fd!„Z 	 	 	 d=d"ed#ed$e!eej"        f         d%edz  d&edz  d'ej#        dz  deej        e!eej"        f         f         fd(„Z$d)ej"        d#edz  d*e%de!ee&f         fd+„Z'	 d@d#edz  fd,„Z(dej"        fd-„Z)d.„ Z*d/„ Z+d0„ Z,d1ej"        dz  d&edz  d$e!eej"        f         dej        fd2„Z-	 dAd%ee.e         z  dz  d&edz  defd3„Z/ ej0        ¦   «         	 	 	 	 	 	 dBd1ej"        dz  d*e%dz  d4e1dz  d5e2dz  d6edz  d7e3d8         fd9„¦   «         Z4dCd;„Z5ˆ xZ6S )DÚ MusicgenForConditionalGenerationr¦   r6  Úencoder_decoderrB   TNÚtext_encoderÚaudio_encoderr(  c                 ó¦  •— |€|�|�|€t          d¦  «        ‚|€"t          |j        |j        |j        ¬¦  «        }n/t          || j        ¦  «        st          d|› d| j        › �¦  «        ‚|j        j        �D|j        j        |j        j        k    r*t          d|j        j        › d|j        j        › d�¦  «        ‚t          ¦   «          
                    |¦  «         |€ d	d
lm} |                     |j        ¦  «        }|€d	dlm}  |j        |j        ¦  «        }|€t                                |j        ¦  «        }|| _        || _        || _        | j        j                             ¦   «         | j        j                             ¦   «         k    r4t&                               d| j        j        › d| j        j        › �¦  «         | j        j                             ¦   «         | j        j                             ¦   «         k    r4t&                               d| j        j        › d| j        j        › �¦  «         | j        j                             ¦   «         | j        j                             ¦   «         k    r4t&                               d| j        j        › d| j        j        › �¦  «         | j        j        j        | j        j        _        | j        j        j        | j        j        _        | j        j        j        | j        j        _        | j        j        | j        _        | j        j        | j        _        | j        j        | j        _        | j        j        j        | j        j        j        k    rI| j        j        j        €8t/          j        | j        j        j        | j        j        j        ¦  «        | _        | j                             ¦   «         �t          d| j        › d�¦  «        ‚t7          t9          j        | j        j        ¦  «        j                              ¦   «         ¦  «        }d|vrt          d¦  «        ‚|  !                    ¦   «          dS )aº  
        text_encoder (`PreTrainedModel`, *optional*):
            The text encoder model that encodes text into hidden states for conditioning.
        audio_encoder (`PreTrainedModel`, *optional*):
            The audio encoder model that encodes audio into hidden states for conditioning.
        decoder (`MusicgenForCausalLM`, *optional*):
            The decoder model that generates audio tokens based on conditioning signals.
        NzlEither a configuration has to be provided, or all three of text encoder, audio encoder and MusicGen decoder.©r±  r²  r(  zConfig: z has to be of type z“If `cross_attention_hidden_size` is specified in the MusicGen decoder's configuration, it has to be equal to the text encoder's `hidden_size`. Got z6 for `config.decoder.cross_attention_hidden_size` and z' for `config.text_encoder.hidden_size`.r(   )ÚAutoModelForTextEncodingr*   zConfig of the text_encoder: z/ is overwritten by shared text_encoder config: zConfig of the audio_encoder: z0 is overwritten by shared audio_encoder config: zConfig of the decoder: z* is overwritten by shared decoder config: zThe encoder zB should not have a LM Head. Please use a model without and LM Headrß   z¸The selected decoder is not prepared for the encoder hidden states to be passed. Please see the following discussion on GitHub: https://github.com/huggingface/transformers/issues/23350)"rM   r-   r¦   r¶   Úconfig_classr(  Úcross_attention_hidden_sizer±  rÐ   rW   rX   Úauto.modeling_autorµ  Úfrom_configr+   r²  r5  Ú_from_configÚto_dictÚloggerÚwarningr[   rÀ   r˜   r«   Úenc_to_dec_projr@  ÚsetÚinspectÚ	signaturerƒ   Ú
parametersr¼   r  )	rZ   r¦   r±  r²  r(  rµ  r+   Údecoder_signaturer[   s	           €rA   rX   z)MusicgenForConditionalGeneration.__init__]  sP  ø€ ð ˆ>˜|Ð3°}Ð7LÐPWÐP_ÝØ~ñô ð ð ˆ>Ý#Ø)Ô0ÀÔ@TÐ^eÔ^lðñ ô ˆFˆFõ ˜f dÔ&7Ñ8Ô8ð \Ý Ð!Z¨FÐ!ZÐ!ZÀtÔGXÐ!ZÐ!ZÑ[Ô[Ð[àŒ>Ô5ÐAØŒ~Ô9¸VÔ=PÔ=\Ò\Ð\Ý ð:ØAGÄÔAkð:ð :àIOÔI\ÔIhð:ð :ð :ñô ð õ 	‰Œ×Ò˜Ñ Ô Ð àÐØEÐEÐEÐEÐEÐEà3×?Ò?ÀÔ@SÑTÔTˆLàÐ Ø6Ð6Ð6Ð6Ð6Ð6à1˜IÔ1°&Ô2FÑGÔGˆMàˆ?Ý)×6Ò6°v´~ÑFÔFˆGà(ˆÔØ*ˆÔØˆŒàÔÔ#×+Ò+Ñ-Ô-°´Ô1I×1QÒ1QÑ1SÔ1SÒSÐSÝ�NŠNð/¨tÔ/@Ô/Jð /ð /Ø”KÔ,ð/ð /ñô ð ð ÔÔ$×,Ò,Ñ.Ô.°$´+Ô2K×2SÒ2SÑ2UÔ2UÒUÐUÝ�NŠNð0°Ô0BÔ0Lð 0ð 0Ø”KÔ-ð0ð 0ñô ð ð Œ<Ô×&Ò&Ñ(Ô(¨D¬KÔ,?×,GÒ,GÑ,IÔ,IÒIÐIÝ�NŠNð*¨$¬,Ô*@ð *ð *Ø”KÔ'ð*ð *ñô ð ð 9=Ô8IÔ8PÔ8eˆŒÔ Ô5Ø9=Ô9KÔ9RÔ9gˆŒÔ!Ô6Ø37´<Ô3FÔ3[ˆŒÔÔ0Ø#'¤;Ô#;ˆÔÔ Ø$(¤KÔ$=ˆÔÔ!Ø"œkÔ1ˆŒÔð ÔÔ$Ô0°D´LÔ4GÔ4SÒSÐSØ”Ô#Ô?ÐGå#%¤9¨TÔ->Ô-EÔ-QÐSWÔS_ÔSfÔSrÑ#sÔ#sˆDÔ àÔ×2Ò2Ñ4Ô4Ð@ÝØt˜tÔ0ÐtÐtÐtñô ð õ  ¥Ô 1°$´,Ô2FÑ GÔ GÔ R× WÒ WÑ YÔ YÑZÔZÐØ"Ð*;Ð;Ð;Ýðkñô ð ð 	�ŠÑÔÐÐÐr@   c                 ó4   — | j                              ¦   «         S rV   )r±  r-  r,  s    rA   r-  z5MusicgenForConditionalGeneration.get_input_embeddingsÄ  s   € ØÔ ×5Ò5Ñ7Ô7Ð7r@   c                 ó4   — | j                              ¦   «         S rV   )r(  r@  r,  s    rA   r@  z6MusicgenForConditionalGeneration.get_output_embeddingsÇ  s   € ØŒ|×1Ò1Ñ3Ô3Ð3r@   c                 ó6   — | j                              |¦  «        S rV   )r(  rD  rB  s     rA   rD  z6MusicgenForConditionalGeneration.set_output_embeddingsÊ  s   € ØŒ|×1Ò1°.ÑAÔAÐAr@   Ú*text_encoder_pretrained_model_name_or_pathÚ+audio_encoder_pretrained_model_name_or_pathÚ%decoder_pretrained_model_name_or_pathr´   c           	      óÄ  — d„ |                      ¦   «         D ¦   «         }d„ |                      ¦   «         D ¦   «         }d„ |                      ¦   «         D ¦   «         }|D ]}	|d|	z   = Œ	|D ]}	|d|	z   = Œ	|D ]}	|d|	z   = Œ	|                     dd¦  «        }
|
€†|€t          d	¦  «        ‚d
|vr\t          j        |fi |¤ddi¤Ž\  }}|j        du s	|j        du r,t                               d|› d�¦  «         d|_        d|_        ||d
<   t          j        |g|¢R i |¤Ž}
|                     dd¦  «        }|€†|€t          d¦  «        ‚d
|vr\t          j        |fi |¤ddi¤Ž\  }}|j        du s	|j        du r,t                               d|› d�¦  «         d|_        d|_        ||d
<   t          j        |g|¢R i |¤Ž}|                     dd¦  «        }|€ä|€t          d¦  «        ‚d
|vr~t          j        |fi |¤ddi¤Ž\  }}t          |t          ¦  «        r|j        }|j        du s	|j        du r2t                               d|› d|› d|› d�¦  «         d|_        d|_        ||d
<   |d
         j        du s|d
         j        du r!t                               d|› d|› d�¦  «         t          j        |fi |¤Ž}t          d|
j        |j        |j        dœ|¤Ž} | |
|||¬¦  «        S )a  
        Instantiate a text encoder, an audio encoder, and a MusicGen decoder from one, two or three base classes of the
        library from pretrained model checkpoints.


        The model is set in evaluation mode by default using `model.eval()` (Dropout modules are deactivated). To train
        the model, you need to first set it back in training mode with `model.train()`.

        Params:
            text_encoder_pretrained_model_name_or_path (`str`, *optional*):
                Information necessary to initiate the text encoder. Can be either:

                    - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
                    - A path to a *directory* containing model weights saved using
                      [`~PreTrainedModel.save_pretrained`], e.g., `./my_model_directory/`.

            audio_encoder_pretrained_model_name_or_path (`str`, *optional*):
                Information necessary to initiate the audio encoder. Can be either:

                    - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
                    - A path to a *directory* containing model weights saved using
                      [`~PreTrainedModel.save_pretrained`], e.g., `./my_model_directory/`.

            decoder_pretrained_model_name_or_path (`str`, *optional*, defaults to `None`):
                Information necessary to initiate the decoder. Can be either:

                    - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co.
                    - A path to a *directory* containing model weights saved using
                      [`~PreTrainedModel.save_pretrained`], e.g., `./my_model_directory/`.

            model_args (remaining positional arguments, *optional*):
                All remaining positional arguments will be passed to the underlying model's `__init__` method.

            kwargs (remaining dictionary of keyword arguments, *optional*):
                Can be used to update the configuration object (after it being loaded) and initiate the model (e.g.,
                `output_attentions=True`).

                - To update the text encoder configuration, use the prefix *text_encoder_* for each configuration
                  parameter.
                - To update the audio encoder configuration, use the prefix *audio_encoder_* for each configuration
                  parameter.
                - To update the decoder configuration, use the prefix *decoder_* for each configuration parameter.
                - To update the parent model configuration, do not use a prefix for each configuration parameter.

                Behaves differently depending on whether a `config` is provided or automatically loaded.

        Example:

        ```python
        >>> from transformers import MusicgenForConditionalGeneration

        >>> # initialize a musicgen model from a t5 text encoder, encodec audio encoder, and musicgen decoder
        >>> model = MusicgenForConditionalGeneration.from_sub_models_pretrained(
        ...     text_encoder_pretrained_model_name_or_path="google-t5/t5-base",
        ...     audio_encoder_pretrained_model_name_or_path="facebook/encodec_24khz",
        ...     decoder_pretrained_model_name_or_path="facebook/musicgen-small",
        ... )
        >>> # saving model after fine-tuning
        >>> model.save_pretrained("./musicgen-ft")
        >>> # load fine-tuned model
        >>> model = MusicgenForConditionalGeneration.from_pretrained("./musicgen-ft")
        ```c                 ón   — i | ]2\  }}|                      d ¦  «        ¯|t          d ¦  «        d…         |“Œ3S )Útext_encoder_N©Ú
startswithrg  ©rü   ÚargumentrŽ   s      rA   ú
<dictcomp>zOMusicgenForConditionalGeneration.from_sub_models_pretrained.<locals>.<dictcomp>  sU   € ð 
ð 
ð 
á�˜%Ø×"Ò" ?Ñ3Ô3ð
Ø•S˜Ñ)Ô)Ð+Ð+Ô,¨eð
ð 
ð 
r@   c                 ón   — i | ]2\  }}|                      d ¦  «        ¯|t          d ¦  «        d…         |“Œ3S )Úaudio_encoder_NrÍ  rÏ  s      rA   rÑ  zOMusicgenForConditionalGeneration.from_sub_models_pretrained.<locals>.<dictcomp>  sW   € ð  
ð  
ð  
á�˜%Ø×"Ò"Ð#3Ñ4Ô4ð 
Ø•SÐ)Ñ*Ô*Ð,Ð,Ô-¨uð 
ð  
ð  
r@   c                 ón   — i | ]2\  }}|                      d ¦  «        ¯|t          d ¦  «        d…         |“Œ3S )Údecoder_NrÍ  rÏ  s      rA   rÑ  zOMusicgenForConditionalGeneration.from_sub_models_pretrained.<locals>.<dictcomp>!  sT   € ð 
ð 
ð 
Ù3B°8¸UÐX`×XkÒXkÐlvÑXwÔXwð
Ø•S˜‘_”_Ð&Ð&Ô'¨ð
ð 
ð 
r@   rÌ  rÓ  rÕ  rç   NzxIf `text_encoder_model` is not defined as an argument, a `text_encoder_pretrained_model_name_or_path` has to be defined.r¦   Úreturn_unused_kwargsTzInitializing z\ as a text_encoder model from a decoder model. Cross-attention and causal mask are disabled.Fz{If `audio_encoder_model` is not defined as an argument, an `audio_encoder_pretrained_model_name_or_path` has to be defined.z^ as an audio_encoder model from a decoder model. Cross-attention and causal mask are disabled.znIf `decoder_model` is not defined as an argument, a `decoder_pretrained_model_name_or_path` has to be defined.z9 as a decoder model. Cross attention layers are added to z and randomly initialized if z2's architecture allows for cross attention layers.zDecoder model z9 is not initialized as a decoder. In order to initialize zî as a decoder, make sure that the attributes `is_decoder` and `add_cross_attention` of `decoder_config` passed to `.from_sub_models_pretrained(...)` are set to `True` or do not pass a `decoder_config` to `.from_sub_models_pretrained(...)`r´  )r±  r²  r(  r¦   r?   )ÚitemsÚpoprM   r)   Úfrom_pretrainedr£   Úadd_cross_attentionr¼  Úinfor+   r¶   r-   r(  r½  r5  r¦   )ÚclsrÇ  rÈ  rÉ  Ú
model_argsr‘   Úkwargs_text_encoderÚkwargs_audio_encoderÚkwargs_decoderr�   r±  Úencoder_configr²  r(  Údecoder_configr¦   s                   rA   Úfrom_sub_models_pretrainedz;MusicgenForConditionalGeneration.from_sub_models_pretrainedÍ  s  € ðP
ð 
à#)§<¢<¡>¤>ð
ñ 
ô 
Ðð 
ð  
à#)§<¢<¡>¤>ð 
ñ  
ô  
Ðð
ð 
ØFLÇlÂlÁnÄnð
ñ 
ô 
ˆð
 'ð 	.ð 	.ˆCØ�¨Ñ,Ð-Ð-Ø'ð 	/ð 	/ˆCØÐ'¨#Ñ-Ð.Ð.Ø!ð 	)ð 	)ˆCØ�z CÑ'Ð(Ð(ð
 +×.Ò.¨w¸Ñ=Ô=ˆØÐØ9ÐAÝ ð%ñô ð ð
 Ð2Ð2Ð2Ý6@Ô6PØ>ð7ð 7ØBUð7ð 7Ølpð7ð 7ð 7Ñ3�Ð 3ð "Ô,°Ð4Ð4¸Ô8ZÐ^bÐ8bÐ8bÝ—K’Kð^Ð(Rð ^ð ^ð ^ñô ð ð 16�NÔ-Ø9>�NÔ6à0>Ð# HÑ-å$Ô4Ø:ðØ=Gðð ð ØK^ðð ˆLð -×0Ò0°¸$Ñ?Ô?ˆØÐ Ø:ÐBÝ ð%ñô ð ð
 Ð3Ð3Ð3Ý7AÔ7QØ?ð8ð 8ØCWð8ð 8Ønrð8ð 8ð 8Ñ4�Ð 4ð "Ô,°Ð4Ð4¸Ô8ZÐ^bÐ8bÐ8bÝ—K’Kð^Ð(Sð ^ð ^ð ^ñô ð ð 16�NÔ-Ø9>�NÔ6à1?Ð$ XÑ.å%Ô5Ø;ðØ>Hðð ð ØL`ðð ˆMð !×$Ò$ W¨dÑ3Ô3ˆØˆ?Ø4Ð<Ý ð%ñô ð ð
 ˜~Ð-Ð-Ý1;Ô1KØ9ð2ð 2Ø=Kð2ð 2Øbfð2ð 2ð 2Ñ.� õ ˜n­nÑ=Ô=ð <Ø%3Ô%;�Nà!Ô,°Ð5Ð5¸Ô9[Ð_dÐ9dÐ9dÝ—K’KðvÐ(Mð vð vØ0Uðvð vàAðvð vð vñô ð ð
 15�NÔ-Ø9=�NÔ6à+9�˜xÑ(à˜hÔ'Ô2°eÐ;Ð;¸~ÈhÔ?WÔ?kÐotÐ?tÐ?tÝ—’ðMÐ%Jð Mð MØ.SðMð Mð Mñô ð õ *Ô9Ð:_ÐrÐrÐcqÐrÐrˆGõ  ð 
Ø%Ô,¸MÔ<PÐZaÔZhð
ð 
Ølrð
ð 
ˆð ˆs ¸MÐSZÐciÐjÑjÔjÐjr@   r3   Úinput_valuesÚpadding_maskÚdecoder_input_idsÚdecoder_attention_maskr2   r²   r  Údecoder_inputs_embedsrE  rá   r‘   c                 ó"  — i }i }i }i }|                      ¦   «         D ]š\  }}|                     d¦  «        r|||t          d¦  «        d…         <   Œ5|                     d¦  «        r|||t          d¦  «        d…         <   Œe|                     d¦  «        r|||t          d¦  «        d…         <   Œ•|||<   Œ›|€ | j        d|||	dœ|¤|¤Ž}nt	          |t
          ¦  «        r	t          |Ž }|d         }| j        j        j        | j	        j        j        k    r&| j	        j        j
        €|                      |¦  «        }|�||d         z  }|�4|€2|
€0t          || j        j	        j        | j        j	        j        ¦  «        }n³|€±|
€¯ | j        d||dœ|¤Ž}|j        }|j        \  }}}}|d	k    rt%          d
|› d�¦  «        ‚| j        j	        j        dk    r5|j        d         | j	        j        dz  k    r|                     dd¬¦  «        }|d                              || j	        j        z  |¦  «        } | j	        d|||||
|||dœ|¤|¤Ž}t/          |j        |j        |j        |j        |j        |j        |j        |j        |j        ¬¦	  «	        S )aÅ  
        padding_mask (`torch.BoolTensor` 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)
        decoder_input_ids (`torch.LongTensor` of shape `(batch_size * num_codebooks, target_sequence_length)`, *optional*):
            Indices of decoder input sequence tokens in the vocabulary, corresponding to the sequence of audio codes.

            Indices can be obtained by encoding an audio prompt with an audio encoder model to predict audio codes,
            such as with the [`EncodecModel`]. See [`EncodecModel.encode`] for details.

            [What are decoder input IDs?](../glossary#decoder-input-ids)

            <Tip warning={true}>

            The `decoder_input_ids` will automatically be converted from shape `(batch_size * num_codebooks,
            target_sequence_length)` to `(batch_size, num_codebooks, target_sequence_length)` in the forward pass. If
            you obtain audio codes from an audio encoding model, such as [`EncodecModel`], ensure that the number of
            frames is equal to 1, and that you reshape the audio codes from `(frames, batch_size, num_codebooks,
            target_sequence_length)` to `(batch_size * num_codebooks, target_sequence_length)` prior to passing them as
            `decoder_input_ids`.

            </Tip>
        decoder_attention_mask (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
            be used by default.
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length, num_codebooks)`, *optional*):
            Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
            `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
            are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`

        Examples:
        ```python
        >>> from transformers import AutoProcessor, MusicgenForConditionalGeneration
        >>> import torch

        >>> processor = AutoProcessor.from_pretrained("facebook/musicgen-small")
        >>> model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-small")

        >>> inputs = processor(
        ...     text=["80s pop track with bassy drums and synth", "90s rock song with loud guitars and heavy drums"],
        ...     padding=True,
        ...     return_tensors="pt",
        ... )

        >>> pad_token_id = model.generation_config.pad_token_id
        >>> decoder_input_ids = (
        ...     torch.ones((inputs.input_ids.shape[0] * model.decoder.num_codebooks, 1), dtype=torch.long)
        ...     * pad_token_id
        ... )

        >>> logits = model(**inputs, decoder_input_ids=decoder_input_ids).logits
        >>> logits.shape  # (bsz * num_codebooks, tgt_len, vocab_size)
        torch.Size([8, 1, 2048])
        ```rÌ  NrÓ  rÕ  )rB   r3   r  r   ).N)rä  rå  r,   ú0Expected 1 frame in the audio code outputs, got úY frames. Ensure chunking is disabled by setting `chunk_length=None` in the audio encoder.r(   rj   ©r   .)rB   r3   rß   rà   r  rá   r²   rE  )	rJ  rK  r²   Údecoder_hidden_statesÚdecoder_attentionsr÷   Úencoder_last_hidden_staterß   Úencoder_attentionsr?   )r×  rÎ  rg  r±  r¶   r9   r   r¦   rÐ   r(  r·  r¾  rP   rC   rD   r²  Úaudio_codesrK   rM   rb  r  re  rÁ   r   rJ  rK  r²   r°   rö   r÷   r  )rZ   rB   r3   rä  rå  ræ  rç  r2   r²   r  rè  rE  rá   r‘   rÞ  rß  rà  Úcommon_kwargsr�   rŽ   rß   Úaudio_encoder_outputsrñ  Úframesr   r€   r�   r2  s                               rA   rƒ   z(MusicgenForConditionalGeneration.forward’  s{  € ðX !ÐØ!ÐØˆØˆØ Ÿ,š,™.œ.ð 	+ð 	+‰JˆC�Ø�~Š~˜oÑ.Ô.ð +ØCHÐ# C­¨OÑ(<Ô(<Ð(>Ð(>Ô$?Ñ@Ð@Ø—’Ð 0Ñ1Ô1ð +ØEJÐ$ S­Ð-=Ñ)>Ô)>Ð)@Ð)@Ô%AÑBÐBØ—’ 
Ñ+Ô+ð +Ø9>�˜s¥3 z¡?¤?Ð#4Ð#4Ô5Ñ6Ð6à%*�˜cÑ"Ð"àÐ"Ø/˜dÔ/ð Ø#Ø-Ø+ðð ð &ð	ð
  ðð ˆOˆOõ ˜­Ñ/Ô/ð 	@Ý-¨Ð?ˆOà /°Ô 2Ðð ÔÔ$Ô0°D´LÔ4GÔ4SÒSÐSØ”Ô#Ô?ÐGà$(×$8Ò$8Ð9NÑ$OÔ$OÐ!àÐ%Ø$9¸NÈ9Ô<UÑ$UÐ!àÐÐ%6Ð%>ÐCXÐC`Ý 2Ø˜œÔ+Ô8¸$¼+Ô:MÔ:dñ!ô !ÐÐð Ð&Ð+@Ð+HØ$6 DÔ$6ð %Ø)Ø)ð%ð %ð 'ð%ð %Ð!ð
 0Ô;ˆKØ.9Ô.?Ñ+ˆF�C˜ GØ˜Š{ˆ{Ý ðTÀvð Tð Tð Tñô ð ð
 Œ{Ô"Ô1°QÒ6Ð6¸;Ô;LÈQÔ;OÐSWÔS_ÔSmÐqrÑSrÒ;rÐ;rà)×;Ò;¸AÀ1Ð;ÑEÔE�à +¨FÔ 3× ;Ò ;¸CÀ$Ä,ÔB\Ñ<\Ð^eÑ fÔ fÐð >J¸T¼\ð >
Ø'Ø1Ø"7Ø#1Ø/ØØ+Øð>
ð >
ð ð>
ð ð>
ð >
ˆõ Ø Ô%Ø"Ô)Ø+Ô;Ø"1Ô"?Ø.Ô9Ø,Ô=Ø&5Ô&GØ"1Ô"?Ø.Ô9ð

ñ 

ô 

ð 
	
r@   Únext_sequence_lengthc
                 óJ  — |€4| j                              || j        j        | j        j        ¬¦  «        \  }}| j                              ||¦  «        }|	�2|	dk    r,|                     d¦  «        }|�|                     d¦  «        }|�|�|d d …| d …f         n|}d ||||||dœS )N)rV  r,   rW  )rB   r2   r²   ræ  r3   rç  rá   )r(  rX  rY  rC   rV  rZ  r[  )rZ   ræ  rõ  r²   r3   rç  rá   r2   Údecoder_delay_pattern_maskr4   r‘   s              rA   r]  z>MusicgenForConditionalGeneration.prepare_inputs_for_generation6  s÷   € ð &Ð-Ø<@¼L×<aÒ<aØ!ØÔ&Ô3ØÔ1Ô<ð =bñ =ô =Ñ9ÐÐ9ð !œL×AÒAÐBSÐUoÑpÔpÐàÐ%¨.¸1Ò*<Ð*<ð !2× 8Ò 8¸Ñ @Ô @ÐØ%Ð1Ø)?×)FÒ)FÀvÑ)NÔ)NÐ&àÐ&à@TÐ@`Ð! ! ! !Ð&:Ð%:Ð%;Ð%;Ð";Ô<Ð<Ðfwð ð
 Ø.Ø.Ø!2Ø,Ø&<Ø"ð
ð 
ð 	
r@   rƒ  r  r¦  rD   rL  ra   c                 óR  — |�d|v r|                      d¦  «        }n"d|v r|dk    r|                      d¦  «        }nd}|                      ||¦  «        }|€| j        }t          j        || j        j        z  dft          j        |¬¦  «        |z  }|€|}n�|d         |k                         ¦   «          	                    ¦   «         r_t          j
        ||gd¬¦  «        }d	|v rC|d	         }	t          j
        t          j        |	¦  «        dd…dd…f         |	fd¬¦  «        }	|	|d	<   ||fS )
zGPrepares `decoder_input_ids` for generation with encoder-decoder modelsNræ  rB   r,   r_   rG   rF   rj   rç  )rØ  Ú_get_decoder_start_token_idra   r:   r`  r(  r  ra  ÚallÚitemrr   Ú	ones_like)
rZ   rƒ  r  r¦  rD   rL  ra   ræ  Údecoder_input_ids_startrç  s
             rA   Ú)_prepare_decoder_input_ids_for_generationzJMusicgenForConditionalGeneration._prepare_decoder_input_ids_for_generationd  s„  € ð Ð#Ð(;¸|Ð(KÐ(KØ ,× 0Ò 0Ð1DÑ EÔ EÐÐØ˜LÐ(Ð(Ð-=ÀÒ-LÐ-LØ ,× 0Ò 0°Ñ =Ô =ÐÐà $Ðð "&×!AÒ!AÐBXÐZfÑ!gÔ!gÐØˆ>Ø”[ˆFåŒJ˜
 T¤\Ô%?Ñ?ÀÐCÍ5Ì:Ð^dÐeÑeÔeØ$ñ%ð 	 ð Ð$Ø 7ÐÐð   Ô'Ð+AÒA×FÒFÑHÔH×MÒMÑOÔOð 	PÝ %¤	Ð+BÐDUÐ*VÐ\^Ð _Ñ _Ô _ÐØ'¨<Ð7Ð7Ø)5Ð6NÔ)OÐ&Ý).¬Ý”_Ð%;Ñ<Ô<¸Q¸Q¸QÀÀÀ¸UÔCÐE[Ð\Øð*ñ *ô *Ð&ð :P�Ð5Ñ6à  ,Ð.Ð.r@   r€  rY  c                 óä  ‡
‡— |                       ¦   «         }t          |d¦  «        rd|j        _        g d¢Šˆfd„|                     ¦   «         D ¦   «         }t          t          j        |j        ¦  «        j	        ¦  «        Š
d‰
v pd‰
v }|s ˆ
fd„|                     ¦   «         D ¦   «         }|j
        |d<   |j        |d	<   |j        }|�|n| j        j        }d|d
<   |||<    |di |¤Žj        }	|�m|dk    rgt!          j        |	t!          j        |	¦  «        gd¬¦  «        }	d|v r9t!          j        |d         t!          j        |d         ¦  «        gd¬¦  «        |d<   t'          |	¬¦  «        |d<   |S )NÚ_hf_hookT©rÕ  Ú
cross_attnrá   c                 óT   •‡— i | ]#\  Š}t          ˆfd „‰D ¦   «         ¦  «        ° ‰|“Œ$S )c              3   óB   •K  — | ]}‰                      |¦  «        V — Œd S rV   ©rÎ  ©rü   r•   rÐ  s     €rA   r  zjMusicgenForConditionalGeneration._prepare_text_encoder_kwargs_for_generation.<locals>.<dictcomp>.<genexpr>¦  ó1   øè è € ÐIÐI°!�x×*Ò*¨1Ñ-Ô-ÐIÐIÐIÐIÐIÐIr@   ©Úany©rü   rŽ   rÐ  Úirrelevant_prefixs     @€rA   rÑ  z`MusicgenForConditionalGeneration._prepare_text_encoder_kwargs_for_generation.<locals>.<dictcomp>£  óT   øø€ ð 
ð 
ð 
á�˜%ÝÐIÐIÐIÐIÐ7HÐIÑIÔIÑIÔIð
Ø�eð
ð 
ð 
r@   r‘   r¦  c                 ó$   •— i | ]\  }}|‰v ¯	||“ŒS r?   r?   ©rü   rÐ  rŽ   Úencoder_signatures      €rA   rÑ  z`MusicgenForConditionalGeneration._prepare_text_encoder_kwargs_for_generation.<locals>.<dictcomp>«  ó2   ø€ ð ð ð Ù$3 H¨eÐQYÐ]nÐQnÐQn�˜%ÐQnÐQnÐQnr@   r³   Úoutput_hidden_statesÚreturn_dictr,   r   rj   r3   ©r  r2   r?   )Úget_encoderrd   r   Úio_same_devicer×  r¿  rÀ  rÁ  rƒ   rÂ  r³   r  r4   r±  Úmain_input_namer  r:   ÚconcatenateÚ
zeros_liker   )rZ   r€  r¦  r  rY  ÚencoderÚencoder_kwargsÚencoder_accepts_wildcardr4   r  r  r  s             @@rA   Ú+_prepare_text_encoder_kwargs_for_generationzLMusicgenForConditionalGeneration._prepare_text_encoder_kwargs_for_generation“  s   øø€ ð ×"Ò"Ñ$Ô$ˆõ �7˜JÑ'Ô'ð 	3Ø.2ˆGÔÔ+ð DÐCÐCÐð
ð 
ð 
ð 
à#/×#5Ò#5Ñ#7Ô#7ð
ñ 
ô 
ˆõ
  ¥Ô 1°'´/Ñ BÔ BÔ MÑNÔNÐØ#+Ð/@Ð#@Ð#gÀNÐVgÐDgÐ Ø'ð 	ðð ð ð Ø7E×7KÒ7KÑ7MÔ7Mðñ ô ˆNð /@Ô.QˆÐ*Ñ+Ø1BÔ1WˆÐ-Ñ.Ø*Ô9ˆð 0@Ð/KÐ+Ð+ÐQUÔQbÔQrÐØ(,ˆ�}Ñ%Ø+8ˆÐ'Ñ(Ø#˜GÐ5Ð5 nÐ5Ð5ÔGÐð Ð%¨.¸1Ò*<Ð*<Ý %Ô 1Ð3DÅeÔFVÐWhÑFiÔFiÐ2jÐpqÐ rÑ rÔ rÐØ <Ð/Ð/Ý16Ô1BØ!Ð"2Ô3µUÔ5EÀlÐScÔFdÑ5eÔ5eÐfÐlmð2ñ 2ô 2�Ð-Ñ.õ +:ÐL]Ð*^Ñ*^Ô*^ˆÐ&Ñ'àÐr@   c                 ó´  ‡‡— |                       d¬¦  «        }t          |d¦  «        rd|j        _        g d¢Šˆfd„|                     ¦   «         D ¦   «         }t          t          j        |j        ¦  «        j	        ¦  «        Šd‰v pd‰v }|s ˆfd	„|                     ¦   «         D ¦   «         }|�|n| j
        j        }d|d
<   | j        j        j        dk    r.|||<    |j        di |¤Ž}|j        }|j        }	|j        \  }
}}}�n|j        d         dk    rt'          d|j        d         › d�¦  «        ‚|d d …d d…d d …f         ||<    |j        di |¤Ž}|j        }|j        }|d d …dd …d d …f         ||<    |j        di |¤Ž}|j        }|j        }|j        \  }
}}}|                     |
|d|z  |f¦  «        }||d d …d d …d d d…d d …f<   ||d d …d d …dd d…d d …f<   |d gk    s|d gk    rt+          j        ||gd¬¦  «        }	nd g|z  }	|
dk    rt'          d|
› d�¦  «        ‚|d                              || j        j        z  |¦  «        }||d<   |	|d<   |S )Nr7  )Úmodalityr   Tr  c                 óT   •‡— i | ]#\  Š}t          ˆfd „‰D ¦   «         ¦  «        ° ‰|“Œ$S )c              3   óB   •K  — | ]}‰                      |¦  «        V — Œd S rV   r  r  s     €rA   r  zkMusicgenForConditionalGeneration._prepare_audio_encoder_kwargs_for_generation.<locals>.<dictcomp>.<genexpr>Ó  r  r@   r  r
  s     @€rA   rÑ  zaMusicgenForConditionalGeneration._prepare_audio_encoder_kwargs_for_generation.<locals>.<dictcomp>Ð  r  r@   r‘   r¦  c                 ó$   •— i | ]\  }}|‰v ¯	||“ŒS r?   r?   r  s      €rA   rÑ  zaMusicgenForConditionalGeneration._prepare_audio_encoder_kwargs_for_generation.<locals>.<dictcomp>Ø  r  r@   r  r,   r(   z3Expected stereo audio (2-channels) but example has z	 channel.rj   rê  rë  rì  ræ  Úaudio_scalesr?   )r  rd   r   r  r×  r¿  rÀ  rÁ  rƒ   rÂ  r²  r  r(  r¦   rb  Úencoderñ  r"  rK   rM   Únew_onesr:   rM  rÁ   r  )rZ   rä  r¦  r  r  r  r  ró  rñ  r"  rô  r   r€   r�   Úaudio_encoder_outputs_leftÚaudio_codes_leftÚaudio_scales_leftÚaudio_encoder_outputs_rightÚaudio_codes_rightÚaudio_scales_rightræ  r  r  s                        @@rA   Ú,_prepare_audio_encoder_kwargs_for_generationzMMusicgenForConditionalGeneration._prepare_audio_encoder_kwargs_for_generationÄ  s|  øø€ ð ×"Ò"¨GÐ"Ñ4Ô4ˆõ �7˜JÑ'Ô'ð 	3Ø.2ˆGÔÔ+ð DÐCÐCÐð
ð 
ð 
ð 
à#/×#5Ò#5Ñ#7Ô#7ð
ñ 
ô 
ˆõ
  ¥Ô 1°'´/Ñ BÔ BÔ MÑNÔNÐØ#+Ð/@Ð#@Ð#gÀNÐVgÐDgÐ Ø'ð 	ðð ð ð Ø7E×7KÒ7KÑ7MÔ7Mðñ ô ˆNð
 0@Ð/KÐ+Ð+ÐQUÔQcÔQsÐØ(,ˆ�}Ñ%àŒ<ÔÔ-°Ò2Ð2Ø/;ˆNÐ+Ñ,Ø$2 G¤NÐ$DÐ$D°^Ð$DÐ$DÐ!Ø/Ô;ˆKØ0Ô=ˆLà.9Ô.?Ñ+ˆF�C˜ G¡Gð Ô! !Ô$¨Ò)Ð)Ý ØjÈ,ÔJ\Ð]^ÔJ_ÐjÐjÐjñô ð ð 0<¸A¸A¸A¸rÀ¸rÀ1À1À1¸HÔ/EˆNÐ+Ñ,Ø)7¨¬Ð)IÐ)I¸.Ð)IÐ)IÐ&Ø9ÔEÐØ :Ô GÐà/;¸A¸A¸A¸q¸r¸rÀ1À1À1¸HÔ/EˆNÐ+Ñ,Ø*8¨'¬.Ð*JÐ*J¸>Ð*JÐ*JÐ'Ø ;Ô GÐØ!<Ô!IÐà.>Ô.DÑ+ˆF�C˜ Gà*×3Ò3°V¸SÀ!ÀiÁ-ÐQXÐ4YÑZÔZˆKà(8ˆK˜˜˜˜1˜1˜1˜c˜c ˜c 1 1 1˜Ñ%Ø):ˆK˜˜˜˜1˜1˜1˜a˜d ˜d A A A˜Ñ&à  T FÒ*Ð*Ð.@ÀTÀFÒ.JÐ.JÝ$œ{Ð,=Ð?QÐ+RÐXYÐZÑZÔZ��à $˜v¨™|�à�QŠ;ˆ;ÝðPÀ6ð Pð Pð Pñô ð ð
 (¨Ô/×7Ò7¸¸d¼lÔ>XÑ8XÐZaÑbÔbÐà,=ˆÐ(Ñ)Ø'3ˆ�^Ñ$ØÐr@   c                 ó`   — t          || j        j        j        | j        j        j        ¦  «        S rV   )rP   r¦   r(  rC   rL  )rZ   rE  s     rA   Ú%prepare_decoder_input_ids_from_labelszFMusicgenForConditionalGeneration.prepare_decoder_input_ids_from_labels  s$   € Ý! &¨$¬+Ô*=Ô*JÈDÌKÔL_ÔLlÑmÔmÐmr@   c                 ó    — t          d¦  «        ‚)NzèResizing the embedding layers via the EncoderDecoderModel directly is not supported. Please use the respective methods of the wrapped objects (model.encoder.resize_token_embeddings(...) or model.decoder.resize_token_embeddings(...)))ÚNotImplementedError)rZ   Úargsr‘   s      rA   Úresize_token_embeddingsz8MusicgenForConditionalGeneration.resize_token_embeddings  s   € Ý!ð;ñ
ô 
ð 	
r@   c                 ód   — | j                              ¦   «         D ]	}d|_        Œ
d| j         _        dS )z3
        Freeze the audio encoder weights.
        FN)r²  rÂ  Úrequires_gradÚ_requires_grad©rZ   Úparams     rA   Úfreeze_audio_encoderz5MusicgenForConditionalGeneration.freeze_audio_encoder  s>   € ð Ô'×2Ò2Ñ4Ô4ð 	(ð 	(ˆEØ"'ˆEÔÐØ,1ˆÔÔ)Ð)Ð)r@   c                 ód   — | j                              ¦   «         D ]	}d|_        Œ
d| j         _        dS )z2
        Freeze the text encoder weights.
        FN)r±  rÂ  r3  r4  r5  s     rA   Úfreeze_text_encoderz4MusicgenForConditionalGeneration.freeze_text_encoder"  s>   € ð Ô&×1Ò1Ñ3Ô3ð 	(ð 	(ˆEØ"'ˆEÔÐØ+0ˆÔÔ(Ð(Ð(r@   rt  c                 óÊ  — |�|S |                      d¦  «        }|�K|d                              ¦   «         dd…         }t          j        |t          j        | j        ¬¦  «        dz  S |€t          d¦  «        ‚d}|                     ¦   «         D ]+}t          |t          j	        ¦  «        r|j
        d         } nŒ,t          j        |dft          j        | j        ¬¦  «        |z  S )	z3Initializes input ids for generation, if necessary.Nr2   r   rF   r_   rH   zB`bos_token_id` has to be defined when no `input_ids` are provided.r,   )r¸   r|   r:   r`  ra  ra   rM   r½   r¶   r‡   rK   )rZ   rt  rL  r¦  r2   rK   rƒ  rŽ   s           rA   Ú*_maybe_initialize_input_ids_for_generationzKMusicgenForConditionalGeneration._maybe_initialize_input_ids_for_generation*  sï   € ð ÐØˆMà&×*Ò*Ð+<Ñ=Ô=ˆØÐ&à# AÔ&×+Ò+Ñ-Ô-¨c¨r¨cÔ2ˆEÝ”:˜e­5¬:¸d¼kÐJÑJÔJÈTÑQÐQàÐÝÐaÑbÔbÐbð ˆ
Ø!×(Ò(Ñ*Ô*ð 	ð 	ˆEÝ˜%¥¤Ñ.Ô.ð Ø"œ[¨œ^�
Ø�ðõ Œz˜: q˜/µ´ÀDÄKÐPÑPÔPÐS_Ñ_Ð_r@   c                 óp   — |�|n| j         j        }|�|n| j         j        }|�|S |�|S t          d¦  «        ‚)Nz\`decoder_start_token_id` or `bos_token_id` has to be defined for encoder-decoder generation.)rY  rD   rL  rM   )rZ   rD   rL  s      rA   rù  z<MusicgenForConditionalGeneration._get_decoder_start_token_idF  sc   € ð
 &Ð1ð #Ð"àÔ'Ô>ð 	ð
 (4Ð'?�|�|ÀTÔE[ÔEhˆà!Ð-Ø)Ð)ØÐ%ØÐÝØjñ
ô 
ð 	
r@   ru  rv  rw  rx  r/   c                 óF
  — |                       d|ddd¦  «        } | j        |fi |¤Ž\  }}	|                     ¦   «         }
|
t          j        t          j        fvrt          d¦  «        ‚|                      |	                     ¦   «         ¦  «         |  	                    |
||¦  «         |	 
                    d¦  «        �;t          |	d         ¦  «        t          u rt          |	d         d         ¬¦  «        |	d<   |�|nt          ¦   «         }|�|nt          ¦   «         }d|	v}|	 
                    dd¦  «        du}|                      ||j        |	¦  «        \  }}}	|j        d         }|                      |||j        ¬¦  «         |j        |	d	<   |j        |	d
<   |	 
                    dd¦  «        €|r|                      |||	¦  «        |	d<   d|	vr|                      ||	||¦  «        }	d|	vr d|	v r|                      |	d         |	¦  «        }	|                      |||	|j        |j        |j        ¬¦  «        \  }}	|j        d         }| 
                    d¦  «        du o|j        du}| 
                    d¦  «        du o|j        du}|                      ||||||¬¦  «        }| j          !                    ||j        |j        ¬¦  «        \  }}||	d<   |�'| "                    | #                    ¦   «         ¦  «         |                     ¦   «         }
|j        �9|j        dk    r.| $                    tK          |j        ¦  «        ¦  «         d|_        |  &                    |||d||j        ¬¦  «        }|  '                    ||¬¦  «        } | j(        d||j)        | j*        j+        dœ|	¤Ž\  }}	|  ,                    |||	¦  «        |d<    | j-        |f|||dœ|¤|	¤Ž}|j.        r|j/        }n|}| j          0                    ||	d         ¦  «        }|||j1        k              2                    || j         j3        d¦  «        }|d         }|	 
                    d¦  «        }|€dg|z  }| j         j*        j4        dk    r"| j5         6                    ||¬¦  «        j7        }n„| j5         6                    |dd…dd…ddd…dd…f         |¬¦  «        }|j7        }| j5         6                    |dd…dd…ddd…dd…f         |¬¦  «        }|j7        }tq          j9        ||gd¬¦  «        }|j.        r	||_/        |S |S ) rz  NFr‹  r2   r   r  r3   rI  rá   r4   ræ  rä  )rƒ  r  r¦  rD   rL  ra   rF   rV  r{  r|  rU  r÷  r,   r…  r‰  )rB   rŠ  r•  Úprefill_outputs)ru  rv  rY  )N.r"  )r"  r(   rj   r?   ):Ú_extract_generation_mode_kwargsÚ_prepare_generation_configrš  r   rž  rŸ  rM   r�  rŒ  Ú_validate_generation_moder¸   Útyper9   r   r   r   r�  rL  rK   r‘  ra   rá   r4   r’  r  r+  rþ  r—  Ú_bos_token_tensorrV  r{  r“  r(  rX  r˜  r™  r›  r   rœ  r�  r   r¡  r¦   r•  Ú_prefillr¢  r£  r¤  rZ  r¥  rÁ   r  rb  r²  ÚdecodeÚaudio_valuesr:   rr   )rZ   rt  rY  ru  rv  rw  rx  r‘   Úgeneration_mode_kwargsr¦  r‚  r§  r¨  r€  r  rƒ  rB   r�  r}  r~  r÷  rO  r©  r"  Úoutput_valuesÚcodec_outputs_leftÚoutput_values_leftÚcodec_outputs_rightÚoutput_values_rights                                rA   rª  z)MusicgenForConditionalGeneration.generateX  s§  € ðV "&×!EÒ!EÀdÈFÐTYÐ[_ÐaeÑ!fÔ!fÐØ*I¨$Ô*IÐJ[Ð*fÐ*fÐ_eÐ*fÐ*fÑ'Ð˜<Ø+×?Ò?ÑAÔAˆØ¥>Ô#8½.Ô:VÐ"WÐWÐWÝðTñô ð ð
 	×#Ò# L×$5Ò$5Ñ$7Ô$7Ñ8Ô8Ð8Ø×&Ò& Ð8IÐKaÑbÔbÐbà×ÒÐ-Ñ.Ô.Ð:½tÀLÐQbÔDcÑ?dÔ?dÕhmÐ?mÐ?må.=ÐP\Ð]nÔPoÐpqÔPrÐ.sÑ.sÔ.sˆLÐ*Ñ+ð 0@Ð/KÐ+Ð+ÕQdÑQfÔQfÐØ1BÐ1NÐ-Ð-ÕThÑTjÔTjÐà"3¸<Ð"GÐØ$0×$4Ò$4Ð5EÀtÑ$LÔ$LÐTXÐ$XÐ!ð 9=×8RÒ8RØÐ%Ô2°Lñ9
ô 9
Ñ5ˆÐ'¨ð #Ô(¨Ô+ˆ
Ø×$Ò$Ð%6Ð8QÐZgÔZnÐ$ÑoÔoÐoð %6Ô$?ˆ�[Ñ!Ø):Ô)IˆÐ%Ñ&à×ÒÐ,¨dÑ3Ô3Ð;Ð@WÐ;Ø-1×-XÒ-XØÐ0°,ñ.ô .ˆLÐ)Ñ*ð  LÐ0Ð0à×KÒKØ˜|Ð-=Ð?Pñô ˆLð  lÐ2Ð2°~ÈÐ7UÐ7UØ×LÒLØ˜^Ô,Øñô ˆLð #'×"PÒ"PØ!Ø-Ø%Ø#4Ô#PØ*Ô<Ø Ô'ð #Qñ #
ô #
Ñˆ	�<ð %œ?¨2Ô.ÐØ!'§¢¨LÑ!9Ô!9¸TÐ!AÐ!nÐFWÔFbÐjnÐFnÐØ!'§¢¨LÑ!9Ô!9¸TÐ!AÐ!nÐFWÔFbÐjnÐFnÐØ ×:Ò:Ø/Ø#9Ø#9Ø-Ø'Ø-ð ;ñ 
ô 
Ðð 15´×0UÒ0UØØ*ÔFØ(Ô3ð 1Vñ 1
ô 1
Ñ-ˆ	Ð-ð 6PˆÐ1Ñ2ð ÐØ�LŠL˜Ÿš™œÑ)Ô)Ð)ð ,×?Ò?ÑAÔAˆð Ô+Ð7Ð<MÔ<\Ð_`Ò<`Ð<`Ø×#Ò#Õ$IÐJ[ÔJjÑ$kÔ$kÑlÔlÐlØ/3ÐÔ,ð  ×5Ò5Ø/Ø!1Ø+Ø%)Ø-ØÔ#ð 6ñ 
ô 
Ðð !×7Ò7Ø/ÐCTð 8ñ 
ô 
Ðð
 #E $Ô"Dð #
ØØ)Ô>Ø#œ{Ô=ð#
ð #
ð ð	#
ð #
Ñˆ	�<ð 59·M²MÀ)ÐM^Ð`lÑ4mÔ4mÐÐ0Ñ1ð �$”,Øð
à-Ø/Ø/ð	
ð 
ð
 %ð
ð ð
ð 
ˆð Ô4ð 	!Ø Ô*ˆJˆJà ˆJð ”\×:Ò:¸:À|ÐTpÔGqÑrÔrˆ
ð   
Ð.?Ô.QÒ QÔR×ZÒZØ˜œÔ2°Bñ
ô 
ˆ
ð
   	Ô*ˆ
à#×'Ò'¨Ñ7Ô7ˆØÐØ ˜6 JÑ.ˆLàŒ<ÔÔ-°Ò2Ð2Ø Ô.×5Ò5ØØ)ð 6ñ ô ô ð ˆMð
 "&Ô!3×!:Ò!:¸:ÀaÀaÀaÈÈÈÈCÈCÈaÈCÐQRÐQRÐQRÀlÔ;SÐbnÐ!:Ñ!oÔ!oÐØ!3Ô!@Ðà"&Ô"4×";Ò";¸JÀqÀqÀqÈ!È!È!ÈQÈTÐPQÈTÐSTÐSTÐSTÀ}Ô<UÐdpÐ";Ñ"qÔ"qÐØ"5Ô"BÐå!œIÐ'9Ð;NÐ&OÐUVÐWÑWÔWˆMàÔ4ð 	!Ø -ˆGÔØˆNà Ð r@   r,   c                 óÞ   — t          j        |d| j        j        j        f| j        | j        ¬¦  «        }t          j        |df| j        t           j        ¬¦  «        }t          |f|d¬¦  «        S )aá  
        Helper function to get null inputs for unconditional generation, enabling the model to be used without the
        feature extractor or tokenizer.

        Args:
            num_samples (int, *optional*):
                Number of audio samples to unconditionally generate.
            max_new_tokens (int, *optional*):
                Number of tokens to generate for each sample. More tokens means longer audio samples, at the expense of
                longer inference (since more audio tokens need to be generated per sample).

        Example:
        ```python
        >>> from transformers import MusicgenForConditionalGeneration

        >>> model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-small")

        >>> # get the unconditional (or 'null') inputs for the model
        >>> unconditional_inputs = model.get_unconditional_inputs(num_samples=1)
        >>> audio_samples = model.generate(**unconditional_inputs, max_new_tokens=256)
        ```r,   )ra   r`   rù   )r2   r3   r4   )	r:   rv   r¦   r±  rÐ   ra   r`   ra  r1   )rZ   Únum_samplesr  r3   s       rA   Úget_unconditional_inputsz9MusicgenForConditionalGeneration.get_unconditional_inputsN  s}   € õ, "œKØ˜!˜Tœ[Ô5ÔAÐBÈ4Ì;Ð^bÔ^hð
ñ 
ô 
Ðõ œ k°1Ð%5¸d¼kÕQVÔQ[Ð\Ñ\Ô\ˆå)Ø.Ð0Ø)Øð
ñ 
ô 
ð 	
r@   )NNNN)NNN)NNNNNNNNNNNNr«  rV   )NNr¬  )r,   )7r5   r6   r7   r-   r<   r­  rì   r  rí   r   r5  rX   r-  r@  rD  ÚclassmethodÚstrrã  r$   r"   r:   r=   Ú
BoolTensorr;   r9   r   rÌ   r    r!   r   rƒ   r„   r]  Údictr‡   ra   rþ  r   r   r  r+  r-  r1  r7  r9  r;  Úlistrù  r†   r   r   r   rª  rO  rˆ   r‰   s   @rA   r¯  r¯  Q  sË  ø€ € € € € € ð ÐÐÑØ"ÐØ)ÐØ!€OØ&*Ð#ð )-Ø/3Ø04Ø.2ðeð eà Ñ%ðeð &¨Ñ,ðeð '¨Ñ-ð	eð
 % tÑ+ðeð eð eð eð eð eðN8ð 8ð 8ð4ð 4ð 4ðBð Bð Bð ð BFØBFØ<@ð	Bkð Bkà47¸$±JðBkð 69¸4±ZðBkð 03°T©zð	Bkð 
ðBkð Bkð Bkñ „[ðBkðH Øð .2Ø26Ø15Ø04Ø59Ø:>Ø;?Ø(,Ø26Ø:>Ø*.Ø!%ð`
ð `
àÔ# dÑ*ð`
ð Ô(¨4Ñ/ð`
ð Ô'¨$Ñ.ð	`
ð
 Ô&¨Ñ-ð`
ð !Ô+¨dÑ2ð`
ð !&Ô 0°4Ñ 7ð`
ð ˜uÔ0Ô1°DÑ8ð`
ð  ™ð`
ð Ô(¨4Ñ/ð`
ð  %Ô0°4Ñ7ð`
ð Ô  4Ñ'ð`
ð ˜$‘;ð`
ð Ð+Ô,ð`
ð 
�Ñ	 ð`
ð `
ð `
ñ „^ñ Ôð`
ðJ ,0ØØØ#ØØØ#'Øð,
ð ,
ð " D™jð,
ð ,
ð ,
ð ,
ðf .2Ø#'Ø&*ð-/ð -/àð-/ð ð-/ð ˜3 ¤Ð,Ô-ð	-/ð
 !$ d¡
ð-/ð ˜D‘jð-/ð ”˜tÑ#ð-/ð 
ˆuÔ  c¨5¬<Ð&7Ô!8Ð8Ô	9ð-/ð -/ð -/ð -/ð^/à”|ð/ð  ™*ð	/ð
 ,ð/ð 
ˆc�3ˆhŒð/ð /ð /ð /ðd JNðJð JØ<?À$¹JðJð Jð Jð JðXn¸E¼Lð nð nð nð nð
ð 
ð 
ð2ð 2ð 2ð1ð 1ð 1ð`à”˜tÑ#ð`ð ˜D‘jð`ð ˜3 ¤Ð,Ô-ð	`ð
 
Ô	ð`ð `ð `ð `ð: aeð
ð 
Ø&)¨D°¬I¡o¸Ñ&<ð
ØSVÐY]ÑS]ð
à	ð
ð 
ð 
ð 
ð$ €U„]�_„_ð '+Ø59Ø7;Ø9=Ø#'Ø-1ðs!ð s!à”˜tÑ#ðs!ð ,¨dÑ2ðs!ð .°Ñ4ð	s!ð
 0°$Ñ6ðs!ð ˜D‘[ðs!ð ˜>Ô*ðs!ð s!ð s!ñ „_ðs!ðj 
ð  
ð  
ð  
ð  
ð  
ð  
ð  
r@   r¯  )r¯  r5  r&  ræ   )NrŠ   )Yr8   rŒ  rÀ  rl   r  Úcollections.abcr   Údataclassesr   Útypingr   r   r   r:   Útorch.nnr˜   r   Ú r
   rê   Úactivationsr   Úcache_utilsr   r   r   Ú
generationr   r   r   r   r   r   Úmasking_utilsr   r   Úmodeling_flash_attention_utilsr   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   r   Úmodeling_utilsr   r   Úprocessing_utilsr    Úutilsr!   r"   r#   Úutils.genericr$   r%   Úutils.output_capturingr&   r'   Úauto.configuration_autor)   r¸  r+   Úconfiguration_musicgenr-   r.   Úgeneration.streamersr/   Ú
get_loggerr5   r¼  r1   r‡   r„   rP   ÚModulerR   r>   rž   r    rÎ   ræ   ró   r&  r5  r¯  Ú__all__r?   r@   rA   ú<module>rl     s¬  ðð Ð à €€€Ø €€€Ø €€€Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø !Ð !Ð !Ð !Ð !Ð !Ø /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à €€€Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à &Ð &Ð &Ð &Ð &Ð &Ø !Ð !Ð !Ð !Ð !Ð !Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð KÐ JÐ JÐ JÐ JÐ JÐ JÐ Jðð ð ð ð ð ð :Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð GÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ &Ð &Ð &Ð &Ð &Ð &Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IØ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø *Ð *Ð *Ð *Ð *Ð *Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ið ð 5Ø4Ð4Ð4Ð4Ð4Ð4à	ˆÔ	˜HÑ	%Ô	%€ð Ø
ð(ð (ð (ð (ð ( ñ (ô (ñ „ñ „ð(ð" %¤,ð ¸cð Ð[^ð ð ð ð ð()Lð )Lð )Lð )Lð )L¨B¬Iñ )Lô )Lð )Lðf !Øð%ð %ØŒIð%àŒ<ð%ð 
Œð%ð Œ<ð	%ð
 ”L 4Ñ'ð%ð �T‰\ð%ð ð%ð Ð'Ô(ð%ð %ð %ð %ð8m)ð m)ð m)ð m)ð m)˜œ	ñ m)ô m)ð m)ð`\ð \ð \ð \ð \Ð5ñ \ô \ð \ð~ ð4ð 4ð 4ð 4ð 4˜oñ 4ô 4ñ „ð4ð"O
ð O
ð O
ð O
ð O
Ð-ñ O
ô O
ð O
ðd ðEð Eð Eð Eð EÐ+ñ Eô Eñ „ðEðP €ððñ ô ð
Zð Zð Zð Zð ZÐ1°?ñ Zô Zñô ð
Zðz €ððñ ô ð
X
ð X
ð X
ð X
ð X
Ð'>Àñ X
ô X
ñô ð
X
ðv  rÐ
qÐ
q€€€r@   