Ë
    S^(hcO  ã                   ó¬   — d Z ddlZddlmZmZ er	 ddlmZ ddlmZ  ej                  e
«      Z G d„ de«      Z G d	„ d
e«      Z G d„ de«      Zg d¢Zy)zCLVP model configurationé    N)ÚTYPE_CHECKINGÚUnioné   )ÚPretrainedConfig)Úloggingc                   ó�   ‡ — e Zd ZdZdZddgZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Ze	 ddee	e
j                  f   de	dd	fd
„«       Zˆ xZS )ÚClvpEncoderConfigak  
    This is the configuration class to store the configuration of a [`ClvpEncoder`]. It is used to instantiate a CLVP
    text or CLVP speech encoder according to the specified arguments. Instantiating a configuration with the defaults
    will yield a similar configuration to that of the encoder of the CLVP
    [susnato/clvp_dev](https://huggingface.co/susnato/clvp_dev) 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 256):
            Vocabulary size of the CLVP Encoder model.
        hidden_size (`int`, *optional*, defaults to 768):
            Dimensionality of the encoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 1536):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        projection_dim (`int`, *optional*, defaults to 768):
            Dimensionality of the projection vector.
        num_hidden_layers (`int`, *optional*, defaults to 20):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            Number of attention heads for each attention layer in the Transformer encoder.
        hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        attention_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention probabilities.
        dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the feed-forward layers in [`ClvpEncoderMLP`].
        use_rotary_embedding (`bool`, *optional*, defaults to `True`):
            Whether to use rotary_embedding or not.
        use_attention_bias (`bool`, *optional*, defaults to `False`):
            Whether to use bias in Query, Key and Value layers during self attention.
        summary_type (`str`, *optional*, defaults to `"mean"`):
            What strategy to use to get pooler_output from the last_hidden_state. `"last"`, `"first"`, `"mean"` and
            `"cls_index"` are supported.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1.0, used internally for initialization
            testing).
        bos_token_id (`int`, *optional*, defaults to 255):
            Beginning of sequence token id.
        eos_token_id (`int`, *optional*, defaults to 0):
            End of sequence token id.

    Example:

    ```python
    >>> from transformers import ClvpEncoderConfig, ClvpEncoder

    >>> # Initializing a ClvpEncoderConfig with susnato/clvp_dev style configuration
    >>> encoder_configuration = ClvpEncoderConfig()

    >>> # Initializing a ClvpEncoder (with random weights) from the susnato/clvp_dev style configuration
    >>> model = ClvpEncoder(encoder_configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úclvp_encoderÚtext_configÚspeech_configc                 ó
  •— || _         || _        || _        || _        || _        || _        || _        || _        || _        |	| _	        |
| _
        || _        || _        || _        || _        || _        t!        ‰| �D  d||dœ|¤Ž y ©N)Úbos_token_idÚeos_token_id© )Ú
vocab_sizeÚhidden_sizeÚintermediate_sizeÚprojection_dimÚnum_hidden_layersÚnum_attention_headsÚlayer_norm_epsÚ
hidden_actÚinitializer_factorÚattention_dropoutÚdropoutÚuse_rotary_embeddingÚuse_attention_biasÚsummary_typer   r   ÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚkwargsÚ	__class__s                     €úi/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/clvp/configuration_clvp.pyr!   zClvpEncoderConfig.__init__`   sš   ø€ ð( %ˆŒØ&ˆÔØ!2ˆÔØ,ˆÔØ!2ˆÔØ#6ˆÔ Ø,ˆÔØ$ˆŒØ"4ˆÔØ!2ˆÔØˆŒØ$8ˆÔ!Ø"4ˆÔØ(ˆÔØ(ˆÔØ(ˆÔä‰ÑÐX lÀÑXÐQWÓXó    Úpretrained_model_name_or_pathÚconfig_typeÚreturnr   c                 óv  — | j                  |«        | j                  |fi |¤Ž\  }}|| j                  vrt        d|› �«      ‚|j	                  d«      dk(  r||   }d|v rGt        | d«      r;|d   | j                  k7  r)t        j                  d|d   › d| j                  › d�«        | j                  |fi |¤ŽS )NzSWe can only load either 'text_config' or 'speech_config' but you are trying to loadÚ
model_typeÚclvpzYou are using a model of type z  to instantiate a model of type zN. This is not supported for all configurations of models and can yield errors.)
Ú_set_token_in_kwargsÚget_config_dictÚbase_config_keyÚ
ValueErrorÚgetÚhasattrr+   ÚloggerÚwarningÚ	from_dict)Úclsr'   r(   r#   Úconfig_dicts        r%   Úfrom_pretrainedz!ClvpEncoderConfig.from_pretrained‡   sâ   € ð 	× Ñ  Ô(à1˜c×1Ñ1Ð2OÑZÐSYÑZÑˆ�Vð ˜c×1Ñ1Ñ1ÜØeÐfqÐerÐsóð ð
 �?‰?˜<Ó(¨FÒ2Ø% kÑ2ˆKà˜;Ñ&¬7°3¸Ô+EÈ+ÐVbÑJcÐgj×guÑguÒJuÜ�N‰NØ0°¸\Ñ1JÐ0KÐKkØ—>‘>Ð"Ð"pðrôð
 ˆs�}‰}˜[Ñ3¨FÑ3Ð3r&   )é   é   i   r:   é   é   Úgeluçñhãˆµøä>çš™™™™™¹?r?   TFÚmeanç      ð?éÿ   r   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+   r/   r!   Úclassmethodr   ÚstrÚosÚPathLiker8   Ú__classcell__©r$   s   @r%   r	   r	      s�   ø„ ñ;ðz  €JØ$ oÐ6€Oð ØØØØØØØØØØ!Ø ØØØØõ#%YðN àXeñ4Ø,1°#°r·{±{Ð2BÑ,Cð4ØRUð4à	ò4ó ô4r&   r	   c                   ód   ‡ — e Zd ZdZdZdZdddddd	d
dddddddddd
ddddddddg d¢fˆ fd„	Zˆ xZS )ÚClvpDecoderConfigaN  
    This is the configuration class to store the configuration of a [`ClvpDecoder`]. It is used to instantiate a CLVP
    Decoder Model according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the Decoder part of the CLVP
    [susnato/clvp_dev](https://huggingface.co/susnato/clvp_dev) architecture.

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

    The architecture is similar to GPT2.

    Args:
        vocab_size (`int`, *optional*, defaults to 8194):
            Vocabulary size of the model.
        max_position_embeddings (`int`, *optional*, defaults to 608):
            The maximum sequence length of mel tokens that this model might ever be used with. Similar to `n_positions`
            in `GPT2Config`.
        max_text_tokens (`int`, *optional*, defaults to 404):
            The maximum sequence length of text tokens that this model might ever be used with. Similar to
            `n_positions` in `GPT2Config`.
        hidden_size (`int`, *optional*, defaults to 1024):
            Dimensionality of the embeddings and hidden states.
        num_hidden_layers (`int`, *optional*, defaults to 30):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer encoder.
        n_inner (`int`, *optional*):
            Dimensionality of the inner feed-forward layers. `None` will set it to 4 times `hidden_size`.
        num_mel_attn_blocks (`int`, *optional*, defaults to 6):
            Denotes the number of self attention layers in [`ClvpConditioningEncoder`].
        activation_function (`str`, *optional*, defaults to `"gelu_new"`):
            Activation function, to be selected in the list `["relu", "silu", "gelu", "tanh", "gelu_new"]`.
        resid_pdrop (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        embd_pdrop (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the embeddings.
        attention_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention.
        layer_norm_epsilon (`float`, *optional*, defaults to 1e-05):
            The epsilon to use in the layer normalization layers.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        summary_type (`string`, *optional*, defaults to `"cls_index"`):
            Argument used when doing sequence summary.

            Has to be one of the following options:

                - `"last"`: Take the last token hidden state (like XLNet).
                - `"first"`: Take the first token hidden state (like BERT).
                - `"mean"`: Take the mean of all tokens hidden states.
                - `"cls_index"`: Supply a Tensor of classification token position (like GPT/GPT-2).
                - `"attn"`: Not implemented now, use multi-head attention.
        summary_use_proj (`bool`, *optional*, defaults to `True`):
            Whether or not to add a projection after the vector extraction.
        summary_activation (`str`, *optional*):
            Pass `"tanh"` for a tanh activation to the output, any other value will result in no activation.
        summary_proj_to_labels (`bool`, *optional*, defaults to `True`):
            Whether the projection outputs should have `config.num_labels` or `config.hidden_size` classes.
        summary_first_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio to be used after the projection and activation.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
        bos_token_id (`int`, *optional*, defaults to 8192):
            Beginning of sequence token id, used at the start of the generation.
        eos_token_id (`int`, *optional*, defaults to 8193):
            End of sequence token id, used in the method
            [`ClvpModelForConditionalGeneration.fix_speech_decoder_output()`] to correct decoder outputs.
        feature_size (`int`, *optional*, defaults to 80):
            The feature dimension of the extracted mel features. This value is used in [`ClvpConditioningEncoder`].
        use_attention_bias (`bool`, *optional*, defaults to `True`):
            Whether to use bias in Query, Key and Value layers during self attention.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1.0, used internally for initialization
            testing).
        decoder_fixing_codes (`list`, *optional*, defaults to `[83, 45, 45, 248]`):
            These values are used in the method `fix_speech_decoder_output` to fix decoder generated outputs.

    Example:

    ```python
    >>> from transformers import ClvpDecoderConfig, ClvpDecoder

    >>> # Initializing a ClvpDecoderConfig with susnato/clvp_dev style configuration
    >>> decoder_configuration = ClvpDecoderConfig()

    >>> # Initializing a ClvpDecoder (with random weights) from the susnato/clvp_dev style configuration
    >>> model = ClvpDecoder(decoder_configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úclvp_decoderÚdecoder_configi   i`  i”  i   é   é   Né   Úgelu_newr?   r>   g{®Gáz”?Ú	cls_indexTi    i   éP   rA   )éS   é-   rX   éø   c                 ó–  •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        t5        ‰| �l  d||dœ|¤Ž y r   )r   Úmax_position_embeddingsÚmax_text_tokensr   r   r   Ún_innerÚnum_mel_attn_blocksÚactivation_functionÚresid_pdropÚ
embd_pdropr   Úlayer_norm_epsilonÚinitializer_ranger   Úsummary_use_projÚsummary_activationÚsummary_first_dropoutÚsummary_proj_to_labelsÚ	use_cacheÚfeature_sizer   r   Údecoder_fixing_codesr   r   r    r!   )r"   r   r[   r\   r   r   r   r]   r^   r_   r`   ra   r   rb   rc   r   rd   re   rg   rf   rh   r   r   ri   r   r   rj   r#   r$   s                               €r%   r!   zClvpDecoderConfig.__init__  sé   ø€ ð< %ˆŒØ'>ˆÔ$Ø.ˆÔØ&ˆÔØ!2ˆÔØ#6ˆÔ ØˆŒØ#6ˆÔ Ø#6ˆÔ Ø&ˆÔØ$ˆŒØ!2ˆÔØ"4ˆÔØ!2ˆÔØ(ˆÔØ 0ˆÔØ"4ˆÔØ%:ˆÔ"Ø&<ˆÔ#Ø"ˆŒØ(ˆÔØ"4ˆÔØ"4ˆÔØ$8ˆÔ!à(ˆÔØ(ˆÔä‰ÑÐX lÀÑXÐQWÓXr&   )rC   rD   rE   rF   r+   r/   r!   rK   rL   s   @r%   rN   rN   £   sr   ø„ ñZðx  €JØ&€Oð Ø #ØØØØØØØ&ØØØØØØ ØØØ#Ø!ØØØØØØÚ.÷7:Yñ :Yr&   rN   c                   ó^   ‡ — e Zd ZdZdZeeedœZ	 	 	 	 	 	 d	ˆ fd„	Ze	dededefd„«       Z
ˆ xZS )
Ú
ClvpConfigaQ
  
    [`ClvpConfig`] is the configuration class to store the configuration of a [`ClvpModelForConditionalGeneration`]. It
    is used to instantiate a CLVP model according to the specified arguments, defining the text model, speech model and
    decoder model configs. Instantiating a configuration with the defaults will yield a similar configuration to that
    of the CLVP [susnato/clvp_dev](https://huggingface.co/susnato/clvp_dev) architecture.

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

    Args:
        text_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize the CLVP text encoder.
        speech_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize CLVP speech encoder.
        decoder_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`ClvpDecoderConfig`].
        projection_dim (`int`, *optional*, defaults to 768):
            Dimensionality of text and speech projection layers.
        logit_scale_init_value (`float`, *optional*, defaults to 2.6592):
            The initial value of the *logit_scale* parameter. Default is used as per the original CLVP implementation.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1.0, used internally for initialization
            testing).
        kwargs (*optional*):
            Dictionary of keyword arguments.

    Example:

    ```python
    >>> from transformers import ClvpConfig, ClvpModelForConditionalGeneration

    >>> # Initializing a ClvpConfig with susnato/clvp_dev style configuration
    >>> configuration = ClvpConfig()

    >>> # Initializing a ClvpModelForConditionalGeneration (with random weights) from the susnato/clvp_dev style configuration
    >>> model = ClvpModelForConditionalGeneration(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config

    >>> # We can also initialize a CLVPConfig from a CLVPTextConfig, CLVPSpeechConfig and a CLVPAutoRegressiveConfig
    >>> from transformers import ClvpEncoderConfig, ClvpDecoderConfig

    >>> # Initializing a CLVP text, CLVP speech and CLVP decoder configuration
    >>> config_text = ClvpEncoderConfig()
    >>> config_speech = ClvpEncoderConfig()
    >>> decoder_config = ClvpDecoderConfig()

    >>> config = ClvpConfig.from_sub_model_configs(config_text, config_speech, decoder_config)
    ```r,   ©r   r   rP   c                 óD  •— t        ‰| �  di |¤Ž |€i }t        j                  d«       |€i }t        j                  d«       |€i }t        j                  d«       t	        di |¤Ž| _        t	        di |¤Ž| _        t        di |¤Ž| _        || _	        || _
        || _        y )NzR`text_config` is `None`. Initializing the `ClvpEncoderConfig` with default values.zT`speech_config` is `None`. initializing the `ClvpEncoderConfig` with default values.zU`decoder_config` is `None`. initializing the `ClvpDecoderConfig` with default values.r   )r    r!   r3   Úinfor	   r   r   rN   rP   r   Úlogit_scale_init_valuer   )	r"   r   r   rP   r   rp   r   r#   r$   s	           €r%   r!   zClvpConfig.__init__{  s¥   ø€ ô 	‰ÑÑ"˜6Ò"àÐØˆKÜ�K‰KÐlÔmàÐ ØˆMÜ�K‰KÐnÔoàÐ!ØˆNÜ�K‰KÐoÔpä,Ñ;¨{Ñ;ˆÔÜ.Ñ?°Ñ?ˆÔÜ/ÑA°.ÑAˆÔà,ˆÔØ&<ˆÔ#Ø"4ˆÕr&   r   r   rP   c                 ón   —  | d|j                  «       |j                  «       |j                  «       dœ|¤ŽS )a‡  
        Instantiate a [`ClvpConfig`] (or a derived class) from CLVP text model configuration, CLVP speech model
        configuration and CLVP decoder model configuration.

        Args:
            text_config (`ClvpEncoderConfig`):
                Text model configuration of type [`ClvpEncoderConfig`].
            speech_config (`ClvpEncoderConfig`):
                Speech model configuration of type [`ClvpEncoderConfig`].
            decoder_config (`ClvpDecoderConfig`):
                Decoder model configuration of type [`ClvpDecoderConfig`].

        Returns:
            [`ClvpConfig`]: An instance of a configuration object
        rm   r   )Úto_dict)r6   r   r   rP   r#   s        r%   Úfrom_sub_model_configsz!ClvpConfig.from_sub_model_configs›  sD   € ñ0 ð 
Ø#×+Ñ+Ó-Ø'×/Ñ/Ó1Ø)×1Ñ1Ó3ñ
ð ñ	
ð 	
r&   )NNNr:   gƒ/L¦
F@rA   )rC   rD   rE   rF   r+   r	   rN   Úsub_configsr!   rG   rs   rK   rL   s   @r%   rl   rl   @  sj   ø„ ñ1ðf €Jà(Ø*Ø+ñ€Kð ØØØØ%Øõ5ð@ ð
à&ð
ð )ð
ð *ò	
ó ô
r&   rl   )rl   rN   r	   )rF   rI   Útypingr   r   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerrC   r3   r	   rN   rl   Ú__all__r   r&   r%   ú<module>rz      sl   ðñ ã 	ß 'ñ Øå 3Ý ð 
ˆ×	Ñ	˜HÓ	%€ôA4Ð(ô A4ôHZYÐ(ô ZYôzx
Ð!ô x
òv C�r&   