
    ^j^                         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 dd	lmZmZ  e	d
      e G d de                    ZdgZy)    N)strict   )PreTrainedConfig)RopeParameters)auto_docstring)interval   )CONFIG_MAPPING
AutoConfigzHKUSTAudio/xcodec2-hf)
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ed<   dZeed<     ed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z  dz  ed<   dZeed<   dZeez  dz  ed<   dZeed <   d!eiZd"Zeed#<   d$Z e!e   e"ed%f   z  ed&<   dZ#ee$z  dz  ed!<   d'Z%eed(<   d)Z&eed*<   d+Z'eed,<   d-Z(e!e   e"ed%f   z  ed.<    fd/Z)d0 Z*e+d1efd2       Z,e+d1efd3       Z- xZ.S )4Xcodec2Configa  
    downsampling_ratios (`list[int]`, *optional*, defaults to `[2, 2, 4, 4, 5]`):
        Ratios for downsampling in the encoder.
    semantic_model_config (`Union[Dict, Wav2Vec2BertConfig]`, *optional*):
        An instance of the configuration object for the semantic (Wav2Vec2BertConfig) model.
    quantization_dim (`int`, *optional*, defaults to 2048):
        Dimension for the vector quantization codebook.
    quantization_levels (`list[int]`, *optional*, defaults to `[4, 4, 4, 4, 4, 4, 4, 4]`):
        Levels for the vector quantization codebook.

    Example:

    ```python
    >>> from transformers import Xcodec2Config, Xcodec2Model

    >>> # Initializing configuration
    >>> configuration = Xcodec2Config()

    >>> # Initializing a model (with random weights) from the configuration
    >>> model = Xcodec2Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```xcodec2past_key_valuesi   hidden_sizei   intermediate_size   num_hidden_layers   num_attention_headsnum_key_value_headssilu
hidden_actmax_position_embeddingsg        g      ?)minmaxg{Gz?)defaultinitializer_rangegư>rms_norm_epsNpad_token_idFtie_word_embeddingsrope_parametersattention_biasattention_dropout@   head_dimsemantic_model_config0   encoder_hidden_size)r	   r	      r*      .downsampling_ratiosi>  sampling_rateg?activation_dropouti   quantization_dim)r*   r*   r*   r*   r*   r*   r*   r*   quantization_levelsc                    t        | j                  t              rT| j                  j                  dd      | j                  d<   t	        | j                  d      di | j                  | _        n | j                  t	        d   d      | _        | j
                  | j                  | j                  z  | _        | j                  | j                  | _        t        | (  di | y )N
model_typezwav2vec2-bertr   )r    )
isinstancer'   dictgetr
   r&   r   r   r   super__post_init__)selfkwargs	__class__s     |/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/xcodec2/configuration_xcodec2.pyr8   zXcodec2Config.__post_init__V   s    d00$77;7Q7Q7U7UVbds7tD&&|4)78R8RS_8`)a *,,*D& ''/)7)H[])^D&==  ,,0H0HHDM##+'+'?'?D$''    c                     | j                   | j                  z  dk7  r&t        d| j                    d| j                   d      y)zOPart of `@strict`-powered validation. Validates the architecture of the config.r   zThe hidden size (z6) is not a multiple of the number of attention heads (z).N)r   r   
ValueErrorr9   s    r<   validate_architecturez#Xcodec2Config.validate_architecturee   sS    d666!;#D$4$4#5 622327  <r=   returnc                 R    t        t        j                  | j                              S )N)intnpprodr,   r@   s    r<   
hop_lengthzXcodec2Config.hop_lengthm   s    277433455r=   c                      | j                   dz  S )Nr*   )rG   r@   s    r<   n_fftzXcodec2Config.n_fftq   s    ""r=   )/__name__
__module____qualname____doc__r2   keys_to_ignore_at_inferencer   rD   __annotations__r   r   r   r   r   strr   r   r   floatr   r    r!   boolr"   r   r5   r#   r$   r&   r   sub_configsr)   r,   listtupler'   r   r-   r.   r/   r0   r8   rA   propertyrG   rI   __classcell__)r;   s   @r<   r   r      s   2 J#4"5K!s!s!!!!J#'S'9xCS9$GuGL%#L#*# %%48O^d*T18 ND ,/sU{T)/Hc*J7K!!7FcU38_4F<@4"22T9@M3 ## c 7OcU38_4O( 6C 6 6 #s # #r=   r   )numpyrE   huggingface_hub.dataclassesr   configuration_utilsr   modeling_rope_utilsr   utilsr   utils.type_validatorsr   autor
   r   r   __all__r3   r=   r<   <module>r`      sT   *  . 3 1 # - - 23R#$ R#  4R#j 
r=   