o
    Zh                     @   sP   d Z ddlZddlZddlmZ ddlmZ ee	Z
G dd deZdgZdS )zDac model configuration    N   )PretrainedConfig)loggingc                
       sP   e Zd ZdZdZdg dddddd	d
ddf
 fdd	ZedefddZ  Z	S )	DacConfigaW	  
    This is the configuration class to store the configuration of an [`DacModel`]. It is used to instantiate a
    Dac 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
    [descript/dac_16khz](https://huggingface.co/descript/dac_16khz) architecture.

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

    Args:
        encoder_hidden_size (`int`, *optional*, defaults to 64):
            Intermediate representation dimension for the encoder.
        downsampling_ratios (`List[int]`, *optional*, defaults to `[2, 4, 8, 8]`):
            Ratios for downsampling in the encoder. These are used in reverse order for upsampling in the decoder.
        decoder_hidden_size (`int`, *optional*, defaults to 1536):
            Intermediate representation dimension for the decoder.
        n_codebooks (`int`, *optional*, defaults to 9):
            Number of codebooks in the VQVAE.
        codebook_size (`int`, *optional*, defaults to 1024):
            Number of discrete codes in each codebook.
        codebook_dim (`int`, *optional*, defaults to 8):
            Dimension of the codebook vectors. If not defined, uses `encoder_hidden_size`.
        quantizer_dropout (`bool`, *optional*, defaults to 0):
            Whether to apply dropout to the quantizer.
        commitment_loss_weight (float, *optional*, defaults to 0.25):
            Weight of the commitment loss term in the VQVAE loss function.
        codebook_loss_weight (float, *optional*, defaults to 1.0):
            Weight of the codebook loss term in the VQVAE loss function.
        sampling_rate (`int`, *optional*, defaults to 16000):
            The sampling rate at which the audio waveform should be digitalized expressed in hertz (Hz).
    Example:

    ```python
    >>> from transformers import DacModel, DacConfig

    >>> # Initializing a "descript/dac_16khz" style configuration
    >>> configuration = DacConfig()

    >>> # Initializing a model (with random weights) from the "descript/dac_16khz" style configuration
    >>> model = DacModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Zdac@   )         r	   i   	   i   r	   r   g      ?g      ?i>  c                    s   || _ || _|| _|d d d | _|| _|| _|| _|| _|
| _|dt	|  | _
tt|| _|| _|	| _t jdi | d S )Nr    )encoder_hidden_sizedownsampling_ratiosdecoder_hidden_sizeupsampling_ratiosn_codebookscodebook_sizecodebook_dimquantizer_dropoutsampling_ratelenZhidden_sizeintnpprod
hop_lengthcommitment_loss_weightcodebook_loss_weightsuper__init__)selfr   r   r   r   r   r   r   r   r   r   kwargs	__class__r   X/var/www/auris/lib/python3.10/site-packages/transformers/models/dac/configuration_dac.pyr   L   s   zDacConfig.__init__returnc                 C   s   t | j}t| j| S )N)r   r   r   mathceilr   )r   r   r   r   r#   
frame_ratel   s   zDacConfig.frame_rate)
__name__
__module____qualname____doc__Z
model_typer   propertyr   r'   __classcell__r   r   r!   r#   r      s     - r   )r+   r%   numpyr   Zconfiguration_utilsr   utilsr   Z
get_loggerr(   loggerr   __all__r   r   r   r#   <module>   s   

V