Ë
    ÜÓ^j1!  ã                   ó¼   — d 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
  ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       ZddgZy)zMoshi model configurationé    )Ústricté   )ÚPreTrainedConfig)ÚRopeParameters)Úauto_docstringé   )Ú
AutoConfigzkmhf/hf-moshiko)Ú
checkpointc                   óŠ  ‡ — e Zd ZU dZdZdgZdZeed<   dZ	eed<   dZ
eed	<   d
Zeed<   dZeed<   dZedz  ed<   dZeed<   dZeed<   dZeed<   dZedz  ed<   dZeed<   dZeed<   dZeed<   dZeez  ed<   dZeed <   d!Zeed"<   dZeed#<   d$Zeed%<   dZedz  ed&<   dZedz  ed'<   dZee e   z  dz  ed(<   ˆ fd)„Z!d*„ Z"ˆ xZ#S )+ÚMoshiDepthConfigaê  
    input_size (`int`, *optional*, defaults to 4096):
        Dimensionality of the input hidden states. Used to connect the main decoder to the depth decoder.
    audio_vocab_size (`int`, *optional*, defaults to 2048):
        Vocabulary size of the audio part of model. Defines the number of different tokens that can be
        represented by the `audio_codes` passed when calling the Moshi models.
    ffn_dim (`int`, *optional*, defaults to 5632):
        Dimensionality of the "intermediate" (often named feed-forward) layer in the depth decoder block. Must be even.

    Example:

    ```python
    >>> from transformers import (
    ...     MoshiDepthConfig,
    ...     MoshiDepthDecoder,
    ... )

    >>> configuration = MoshiDepthConfig()

    >>> # Initializing a MoshiDepthDecoder (with random weights) from the kmhf/hf-moshiko style configuration
    >>> model = MoshiDepthDecoder(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úmoshi_depthÚpast_key_valuesé }  Ú
vocab_sizei   Úhidden_sizeé   Ú
input_sizeé   Únum_hidden_layersé   Únum_attention_headsNÚnum_key_value_headsi   Úaudio_vocab_sizeé	   Úmax_position_embeddingsÚsiluÚ
hidden_actÚhead_dimç{®Gáz”?Úinitializer_rangeTÚ	use_cacheé   Úsliding_windowç        Úattention_dropouti   Úffn_dimç:Œ0âŽyE>Úrms_norm_epsÚnum_codebooksFÚtie_word_embeddingsÚpad_token_idÚbos_token_idÚeos_token_idc                 óÎ   •— | j                   �| j                   n| j                  | _         | j                  xs | j                  | j                  z  | _        t	        ‰| �  di |¤Ž y )N© )r   r   r   r   ÚsuperÚ__post_init__)ÚselfÚkwargsÚ	__class__s     €úx/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/moshi/configuration_moshi.pyr1   zMoshiDepthConfig.__post_init__N   s[   ø€ à(,×(@Ñ(@Ð(LˆD×$Ò$ÐRV×RjÑRjð 	Ô ð Ÿ™ÒU¨×)9Ñ)9¸T×=UÑ=UÑ)UˆŒÜ‰ÑÑ' Ó'ó    c                 óZ   — | j                   dz  dk(  rt        d| j                   › d�«      ‚y)úOPart of `@strict`-powered validation. Validates the architecture of the config.r   é   ú	`ffn_dim=ú` must be even.N)r&   Ú
ValueError©r2   s    r5   Úvalidate_architecturez&MoshiDepthConfig.validate_architectureU   s0   € à�<‰<˜!Ñ˜qÒ Ü˜y¨¯©¨°oÐFÓGÐGð !r6   )$Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferencer   ÚintÚ__annotations__r   r   r   r   r   r   r   r   Ústrr   r    Úfloatr!   Úboolr#   r%   r&   r(   r)   r*   r+   r,   r-   Úlistr1   r>   Ú__classcell__©r4   s   @r5   r   r      s  ø… ñð4 €JØ#4Ð"5Ðà€J�ÓØ€K�ÓØ€J�ÓØÐ�sÓØ!Ð˜Ó!Ø&*Ð˜˜t™Ó*Ø Ð�cÓ Ø#$Ð˜SÓ$Ø€J�ÓØ€Hˆc�D‰jÓØ#Ð�uÓ#Ø€IˆtÓØ€N�CÓØ%(Ð�u˜s‘{Ó(Ø€GˆSÓØ€L�%ÓØ€M�3ÓØ %Ð˜Ó%Ø#€L�#˜‘*Ó#Ø#€L�#˜‘*Ó#Ø+/€L�#˜˜S™	‘/ DÑ(Ó/ô(öHr6   r   c                   ó   ‡ — e Zd ZU dZdZdgZeedœZdZ	e
ed<   dZe
ed<   d	Ze
ed
<   d	Ze
ed<   dZe
dz  ed<   dZe
dz  ed<   dZe
ed<   dZeez  dz  ed<   dZeed<   dZe
dz  ed<   dZeed<   dZeed<   dZe
ed<   dZee
z  ed<   dZe
ed<   dZeed<   d Z e
ed!<   d"Z!eed#<   dZ"e
dz  ed$<   dZ#e
dz  ed%<   dZ$e
e%e
   z  dz  ed&<   dZ&ee'z  dz  ed'<   dZ(ee'z  dz  ed(<   ˆ fd)„Z)d*„ Z*e+d+„ «       Z,e-d'e'fd,„«       Z.ˆ xZ/S )-ÚMoshiConfiga�  
    audio_vocab_size (`int`, *optional*):
        Vocabulary size of the audio part of model. Defines the number of different tokens that can be
        represented by the `audio_codes` passed when calling the Moshi models.
    ffn_dim (`int`, *optional*, defaults to 22528):
        Dimensionality of the "intermediate" (often named feed-forward) layer in the main decoder block. Must be even.
    audio_encoder_config (`PreTrainedConfig | dict`, *optional*):
        Configuration for the audio encoder.
    depth_decoder_config (`PreTrainedConfig | dict`, *optional*):
        Configuration for the depth decoder.

    Example:

    ```python
    >>> from transformers import (
    ...     MoshiConfig,
    ...     MoshiForConditionalGeneration,
    ... )

    >>> configuration = MoshiConfig()

    >>> # Initializing a MoshiForConditionalGeneration (with random weights) from the kmhf/hf-moshiko style configuration
    >>> model = MoshiForConditionalGeneration(configuration)

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

    >>> # Saving the model, including its configuration
    >>> model.save_pretrained("kmhf/hf-moshiko")

    >>> # loading model and config from pretrained folder
    >>> moshi_config = MoshiConfig.from_pretrained("kmhf/hf-moshiko")
    >>> model = MoshiForConditionalGeneration.from_pretrained("kmhf/hf-moshiko", config=moshi_config)
    ```Úmoshir   )Úaudio_encoder_configÚdepth_decoder_configr   r   r   r   é    r   r   Nr   r   i¸  r   Úrope_parametersr   r   r   r   r    Tr!   r#   r$   r%   i X  r&   r'   r(   r"   r)   Fr*   r+   r,   r-   rP   rQ   c                 óh  •— | j                   �| j                   n| j                  | _         | j                  xs | j                  | j                  z  | _        t	        | j
                  t        «      rB| j
                  j                  dd«      }t        j                  |fi | j
                  ¤Ž| _        n&| j
                  €t        j                  d«      | _        | j                  €| j
                  j                  n| j                  | _
        t	        | j                  t        «      rc| j                  j                  | j                  | j                  | j                  | j                  dœ«       t!        di | j                  ¤Ž| _        n| j                  €t!        «       | _        t#        ‰| �H  di |¤Ž y )NrC   Úmimi)r   r   r   r)   r/   )r   r   r   r   Ú
isinstancerP   ÚdictÚpopr	   Ú	for_modelr   Úcodebook_sizerQ   Úupdater   r)   r   r0   r1   )r2   r3   Úaudio_encoder_model_typer4   s      €r5   r1   zMoshiConfig.__post_init__�   sm  ø€ à(,×(@Ñ(@Ð(LˆD×$Ò$ÐRV×RjÑRjð 	Ô ð Ÿ™ÒU¨×)9Ñ)9¸T×=UÑ=UÑ)UˆŒä�d×/Ñ/´Ô6Ø'+×'@Ñ'@×'DÑ'DÀ\ÐSYÓ'ZÐ$Ü(2×(<Ñ(<Ð=UÑ(sÐY]×YrÑYrÑ(sˆDÕ%Ø×&Ñ&Ð.Ü(2×(<Ñ(<¸VÓ(DˆDÔ%ð 8<×7LÑ7LÐ7TˆD×%Ñ%×3Ò3ÐZ^×ZoÑZoð 	Ôô �d×/Ñ/´Ô6Ø×%Ñ%×,Ñ,à(,×(=Ñ(=Ø"&×"2Ñ"2Ø"&§/¡/Ø%)×%7Ñ%7ñ	ôô )9Ñ(U¸4×;TÑ;TÑ(UˆDÕ%Ø×&Ñ&Ð.Ü(8Ó(:ˆDÔ%Ü‰ÑÑ' Ó'r6   c                 ó   — | j                   dz  dk(  rt        d| j                   › d�«      ‚| j                  | j                  j                  kD  r0t        d| j                  › d| j                  j                  › d�«      ‚y)	r8   r   r9   r:   r;   z`num_codebooks=zX` is greater than the maximum number of codebooks that the audio encoder can deal with (z). Please lower it.N)r&   r<   r)   rP   r=   s    r5   r>   z!MoshiConfig.validate_architecture»   s£   € à�<‰<˜!Ñ˜qÒ Ü˜y¨¯©¨°oÐFÓGÐGà×Ñ × 9Ñ 9× GÑ GÒGÜØ! $×"4Ñ"4Ð!5ð  6Nð  OS÷  Ohñ  Oh÷  Ovñ  Ovð  Nwð  wJð  Kóð ð Hr6   c                 ó.   — | j                   j                  S )N)rP   Úsampling_rater=   s    r5   r_   zMoshiConfig.sampling_rateÅ   s   € à×(Ñ(×6Ñ6Ð6r6   c                 ó2   —  | dd|j                  «       i|¤ŽS )z¾
        Instantiate a [`MoshiConfig`] (or a derived class) from an audio encoder configuration.

        Returns:
            [`MoshiConfig`]: An instance of a configuration object
        rP   r/   )Úto_dict)ÚclsrP   r3   s      r5   Úfrom_audio_encoder_configz%MoshiConfig.from_audio_encoder_configÉ   s*   € ñ ñ 
Ø!5×!=Ñ!=Ó!?ð
àñ
ð 	
r6   )0r?   r@   rA   rB   rC   rD   r	   r   Úsub_configsr   rE   rF   r   r   r   r   r   r   rS   r   rW   r   rG   r   r    rH   r!   rI   r#   r%   r&   r(   r)   r*   r+   r,   r-   rJ   rP   r   rQ   r1   r>   Úpropertyr_   Úclassmethodrc   rK   rL   s   @r5   rN   rN   [   s“  ø… ñ!ðF €JØ#4Ð"5ÐØ+5ÐO_Ñ`€Kà€J�ÓØ€K�ÓØÐ�sÓØ!Ð˜Ó!Ø&*Ð˜˜t™Ó*Ø#'Ð�c˜D‘jÓ'Ø#'Ð˜SÓ'Ø48€O�^ dÑ*¨TÑ1Ó8Ø€J�ÓØ€Hˆc�D‰jÓØ#Ð�uÓ#Ø€IˆtÓØ€N�CÓØ%(Ð�u˜s‘{Ó(Ø€GˆSÓØ€L�%ÓØ€M�3ÓØ %Ð˜Ó%Ø#€L�#˜‘*Ó#Ø#€L�#˜‘*Ó#Ø+/€L�#˜˜S™	‘/ DÑ(Ó/Ø;?Ð˜$Ð!1Ñ1°DÑ8Ó?Ø;?Ð˜$Ð!1Ñ1°DÑ8Ó?ô(ò<ð ñ7ó ð7ð ð
à.ò
ó ô
r6   rN   N)rB   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úmodeling_rope_utilsr   Úutilsr   Úauto.configuration_autor	   r   rN   Ú__all__r/   r6   r5   ú<module>rm      s‚   ðñ  å .å 3Ý 1Ý #Ý 0ñ Ð,Ô-Øô>HÐ'ó >Hó ó .ð>HñB Ð,Ô-Øô|
Ð"ó |
ó ó .ð|
ð~ Ð,Ð
-�r6   