Ë
    T^(h|*  ã                   ó„   — d Z ddlmZ ddlmZ ddlmZ  ej                  e«      Z	 G d„ de«      Z
 G d„ d	e«      Zd	dgZy
)zMusicGen model configurationé   )ÚPretrainedConfig)Úloggingé   )Ú
AutoConfigc                   óZ   ‡ — e Zd ZdZdZdZdgZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚMusicgenDecoderConfigaÿ  
    This is the configuration class to store the configuration of an [`MusicgenDecoder`]. It is used to instantiate a
    MusicGen decoder according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the MusicGen
    [facebook/musicgen-small](https://huggingface.co/facebook/musicgen-small) architecture.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.


    Args:
        vocab_size (`int`, *optional*, defaults to 2048):
            Vocabulary size of the MusicgenDecoder model. Defines the number of different tokens that can be
            represented by the `inputs_ids` passed when calling [`MusicgenDecoder`].
        hidden_size (`int`, *optional*, defaults to 1024):
            Dimensionality of the layers and the pooler layer.
        num_hidden_layers (`int`, *optional*, defaults to 24):
            Number of decoder layers.
        num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer block.
        ffn_dim (`int`, *optional*, defaults to 4096):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer block.
        activation_function (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the decoder and pooler. If string, `"gelu"`,
            `"relu"`, `"silu"` and `"gelu_new"` are supported.
        dropout (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, text_encoder, and pooler.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        activation_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for activations inside the fully connected layer.
        max_position_embeddings (`int`, *optional*, defaults to 2048):
            The maximum sequence length that this model might ever be used with. Typically, set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        initializer_factor (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        layerdrop (`float`, *optional*, defaults to 0.0):
            The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        scale_embedding (`bool`, *optional*, defaults to `False`):
            Scale embeddings by diving by sqrt(hidden_size).
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether the model should return the last key/values attentions (not used by all models)
        num_codebooks (`int`, *optional*, defaults to 4):
            The number of parallel codebooks forwarded to the model.
        tie_word_embeddings(`bool`, *optional*, defaults to `False`):
            Whether input and output word embeddings should be tied.
        audio_channels (`int`, *optional*, defaults to 1
            Number of channels in the audio data. Either 1 for mono or 2 for stereo. Stereo models generate a separate
            audio stream for the left/right output channels. Mono models generate a single audio stream output.
    Úmusicgen_decoderÚdecoder_configÚpast_key_valuesc                 ó4  •— || _         || _        |	| _        || _        || _        || _        |
| _        || _        || _        || _	        || _
        || _        || _        || _        || _        |dvrt        d|› d�«      ‚|| _        t#        ‰| �H  d||||dœ|¤Ž y )N)é   r   z4Expected 1 (mono) or 2 (stereo) audio channels, got z
 channels.)Úpad_token_idÚbos_token_idÚeos_token_idÚtie_word_embeddings© )Ú
vocab_sizeÚmax_position_embeddingsÚhidden_sizeÚffn_dimÚnum_hidden_layersÚnum_attention_headsÚdropoutÚattention_dropoutÚactivation_dropoutÚactivation_functionÚinitializer_factorÚ	layerdropÚ	use_cacheÚscale_embeddingÚnum_codebooksÚ
ValueErrorÚaudio_channelsÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r#   r   r   r   r   ÚkwargsÚ	__class__s                         €úq/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/musicgen/configuration_musicgen.pyr%   zMusicgenDecoderConfig.__init__R   sÈ   ø€ ð0 %ˆŒØ'>ˆÔ$Ø&ˆÔØˆŒØ!2ˆÔØ#6ˆÔ ØˆŒØ!2ˆÔØ"4ˆÔØ#6ˆÔ Ø"4ˆÔØ"ˆŒØ"ˆŒØ.ˆÔØ*ˆÔà Ñ'ÜÐSÐTbÐScÐcmÐnÓoÐoØ,ˆÔä‰Ñð 	
Ø%Ø%Ø%Ø 3ñ		
ð
 ó	
ó    )é   r+   é   i   é   ç        TÚgelui   gš™™™™™¹?r.   r.   g{®Gáz”?Fé   r   r+   r+   NF)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyÚkeys_to_ignore_at_inferencer%   Ú__classcell__©r(   s   @r)   r   r      sf   ø„ ñ2ðh $€JØ&€OØ#4Ð"5Ðð Ø $ØØØØØØ"ØØØØØØØØØØØØ!÷+2
ñ 2
r*   r   c                   ód   ‡ — e Zd ZdZdZeeedœZdZˆ fd„Z	e
dededefd	„«       Zed
„ «       Zˆ xZS )ÚMusicgenConfigaj	  
    This is the configuration class to store the configuration of a [`MusicgenModel`]. It is used to instantiate a
    MusicGen model according to the specified arguments, defining the text encoder, audio encoder and MusicGen decoder
    configs.

    Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
    documentation from [`PretrainedConfig`] for more information.

    Args:
        kwargs (*optional*):
            Dictionary of keyword arguments. Notably:

                - **text_encoder** ([`PretrainedConfig`], *optional*) -- An instance of a configuration object that
                  defines the text encoder config.
                - **audio_encoder** ([`PretrainedConfig`], *optional*) -- An instance of a configuration object that
                  defines the audio encoder config.
                - **decoder** ([`PretrainedConfig`], *optional*) -- An instance of a configuration object that defines
                  the decoder config.

    Example:

    ```python
    >>> from transformers import (
    ...     MusicgenConfig,
    ...     MusicgenDecoderConfig,
    ...     T5Config,
    ...     EncodecConfig,
    ...     MusicgenForConditionalGeneration,
    ... )

    >>> # Initializing text encoder, audio encoder, and decoder model configurations
    >>> text_encoder_config = T5Config()
    >>> audio_encoder_config = EncodecConfig()
    >>> decoder_config = MusicgenDecoderConfig()

    >>> configuration = MusicgenConfig.from_sub_models_config(
    ...     text_encoder_config, audio_encoder_config, decoder_config
    ... )

    >>> # Initializing a MusicgenForConditionalGeneration (with random weights) from the facebook/musicgen-small style configuration
    >>> model = MusicgenForConditionalGeneration(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    >>> config_text_encoder = model.config.text_encoder
    >>> config_audio_encoder = model.config.audio_encoder
    >>> config_decoder = model.config.decoder

    >>> # Saving the model, including its configuration
    >>> model.save_pretrained("musicgen-model")

    >>> # loading model and config from pretrained folder
    >>> musicgen_config = MusicgenConfig.from_pretrained("musicgen-model")
    >>> model = MusicgenForConditionalGeneration.from_pretrained("musicgen-model", config=musicgen_config)
    ```Úmusicgen©Útext_encoderÚaudio_encoderÚdecoderTc                 ó–  •— t        ‰| �  di |¤Ž d|vsd|vsd|vrt        d«      ‚|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }t	        j
                  |fi |¤Ž| _        t	        j
                  |fi |¤Ž| _        t        di |¤Ž| _	        d| _
        y )Nr>   r?   r@   zPConfig has to be initialized with text_encoder, audio_encoder and decoder configr5   Tr   )r$   r%   r"   Úpopr   Ú	for_modelr>   r?   r   r@   Úis_encoder_decoder)r&   r'   Útext_encoder_configÚtext_encoder_model_typeÚaudio_encoder_configÚaudio_encoder_model_typer
   r(   s          €r)   r%   zMusicgenConfig.__init__È   sÏ   ø€ Ü‰ÑÑ"˜6Ò"Ø Ñ'¨?À&Ñ+HÈIÐ]cÑLcÜÐoÓpÐpà$Ÿj™j¨Ó8ÐØ"5×"9Ñ"9¸,Ó"GÐà%Ÿz™z¨/Ó:ÐØ#7×#;Ñ#;¸LÓ#IÐ àŸ™ IÓ.ˆä&×0Ñ0Ð1HÑ`ÐL_Ñ`ˆÔÜ'×1Ñ1Ð2JÑcÐNbÑcˆÔÜ,Ñ>¨~Ñ>ˆŒØ"&ˆÕr*   rE   rG   r
   c                 ón   —  | d|j                  «       |j                  «       |j                  «       dœ|¤ŽS )zä
        Instantiate a [`MusicgenConfig`] (or a derived class) from text encoder, audio encoder and decoder
        configurations.

        Returns:
            [`MusicgenConfig`]: An instance of a configuration object
        r=   r   )Úto_dict)ÚclsrE   rG   r
   r'   s        r)   Úfrom_sub_models_configz%MusicgenConfig.from_sub_models_configÚ   sD   € ñ  ð 
Ø,×4Ñ4Ó6Ø.×6Ñ6Ó8Ø"×*Ñ*Ó,ñ
ð ñ	
ð 	
r*   c                 ó.   — | j                   j                  S )N)r?   Úsampling_rate)r&   s    r)   rN   zMusicgenConfig.sampling_rateñ   s   € ð ×!Ñ!×/Ñ/Ð/r*   )r1   r2   r3   r4   r5   r   r   Úsub_configsÚis_compositionr%   Úclassmethodr   rL   ÚpropertyrN   r8   r9   s   @r)   r;   r;   ‡   sp   ø„ ñ6ðp €Jà"Ø#Ø(ñ€Kð
 €Nô'ð$ ð
à-ð
ð /ð
ð .ò	
ó ð
ð, ñ0ó ô0r*   r;   N)r4   Úconfiguration_utilsr   Úutilsr   Úauto.configuration_autor   Ú
get_loggerr1   Úloggerr   r;   Ú__all__r   r*   r)   ú<module>rY      sT   ðñ #å 3Ý Ý 0ð 
ˆ×	Ñ	˜HÓ	%€ôk
Ð,ô k
ô\m0Ð%ô m0ð` Ð4Ð
5�r*   