o
    ¾e¦i¥>  ã                   @   sn   d Z ddlmZ ddlmZ ddlmZ e e¡Z	G dd„ deƒZ
G dd„ deƒZG d	d
„ d
eƒZg d¢ZdS )zDia model configurationé   )ÚPreTrainedConfig)ÚRopeParameters)Úloggingc                       st   e Zd ZdZdZ											
		ddedededededededededededB def‡ fdd„Z	‡  Z
S )ÚDiaEncoderConfiga×	  
    This is the configuration class to store the configuration of a [`DiaEncoder`]. It is used to instantiate a Dia
    encoder according to the specified arguments, defining the encoder architecture.

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

    Args:
        max_position_embeddings (`int`, *optional*, defaults to 1024):
            The maximum sequence length that this model might ever be used with.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        hidden_size (`int`, *optional*, defaults to 1024):
            Dimensionality of the encoder layers and the pooler layer.
        num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer encoder.
        num_key_value_heads (`int`, *optional*, defaults to 16):
            Number of key and value heads for each attention layer in the Transformer encoder.
        head_dim (`int`, *optional*, defaults to 128):
            Dimensionality of the attention head.
        intermediate_size (`int`, *optional*, defaults to 4096):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
        norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the normalization layers.
        vocab_size (`int`, *optional*, defaults to 256):
            Vocabulary size of the Dia model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`DiaModel`].
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"swish"` and `"gelu_new"` are supported.
        rope_parameters (`RopeParameters`, *optional*):
            Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
            a value for `rope_theta` and optionally parameters used for scaling in case you want to use RoPE
            with longer `max_position_embeddings`.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
    Údia_encoderé   é   é   é€   é   çñhãˆµøä>é   ÚsiluNç{®Gáz”?Úmax_position_embeddingsÚnum_hidden_layersÚhidden_sizeÚnum_attention_headsÚnum_key_value_headsÚhead_dimÚintermediate_sizeÚnorm_epsÚ
vocab_sizeÚ
hidden_actÚrope_parametersÚinitializer_rangec                    s^   || _ || _|| _|| _|| _|| _|| _|	| _|| _|
| _	|| _
|| _tƒ jdi |¤Ž d S )N© )r   r   r   r   r   r   r   r   r   r   r   r   ÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r   r   r   r   Úkwargs©Ú	__class__r   úg/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/dia/configuration_dia.pyr   A   s   zDiaEncoderConfig.__init__)r   r   r   r	   r	   r
   r   r   r   r   Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚintÚfloatÚstrr   r   Ú__classcell__r   r   r!   r#   r      sP    &óþýüûúùø	÷
öõôór   c                -       s°   e Zd ZdZdZ													
										
	d,dedededededededededededed ed!ed"ed#edB d$ed%e	d&e	d'ed(ed)ef,‡ fd*d+„Z
‡  ZS )-ÚDiaDecoderConfiga•  
    This is the configuration class to store the configuration of a [`DiaDecoder`]. It is used to instantiate a Dia
    decoder according to the specified arguments, defining the decoder architecture.

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

    Args:
        max_position_embeddings (`int`, *optional*, defaults to 3072):
            The maximum sequence length that this model might ever be used with.
        num_hidden_layers (`int`, *optional*, defaults to 18):
            Number of hidden layers in the Transformer decoder.
        hidden_size (`int`, *optional*, defaults to 2048):
            Dimensionality of the decoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 8192):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer decoder.
        num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer decoder.
        num_key_value_heads (`int`, *optional*, defaults to 4):
            Number of key and value heads for each attention layer in the Transformer decoder.
        head_dim (`int`, *optional*, defaults to 128):
            Dimensionality of the attention head.
        cross_num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each cross-attention layer in the Transformer decoder.
        cross_head_dim (`int`, *optional*, defaults to 128):
            Dimensionality of the cross-attention head.
        cross_num_key_value_heads (`int`, *optional*, defaults to 16):
            Number of key and value heads for each cross-attention layer in the Transformer decoder.
        cross_hidden_size (`int`, *optional*, defaults to 1024):
            Dimensionality of the cross-attention layers.
        norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the normalization layers.
        vocab_size (`int`, *optional*, defaults to 1028):
            Vocabulary size of the Dia model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`DiaModel`].
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the decoder. If string, `"gelu"`, `"relu"`,
            `"swish"` and `"gelu_new"` are supported.
        num_channels (`int`, *optional*, defaults to 9):
            Number of channels for the Dia decoder.
        rope_parameters (`RopeParameters`, *optional*):
            Dictionary containing the configuration parameters for the RoPE embeddings. The dictionary should contain
            a value for `rope_theta` and optionally parameters used for scaling in case you want to use RoPE
            with longer `max_position_embeddings`.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
        is_encoder_decoder (`bool`, *optional*, defaults to `True`):
            Indicating that this model is part of an encoder-decoder architecture.
        pad_token_id (`int`, *optional*, defaults to 1025):
            The token id used for padding sequences to the same length within a batch.
        eos_token_id (`int`, *optional*, defaults to 1024):
            The token id representing the end-of-sequence token, indicating that generation should stop.
        bos_token_id (`int`, *optional*, defaults to 1026):
            The token id representing the beginning-of-sequence token, used to initialize decoding.
    Údia_decoderé   é   é   é    r	   é   r
   r   r   é  r   é	   Nr   Té  é  r   r   r   r   r   r   r   Úcross_num_attention_headsÚcross_head_dimÚcross_num_key_value_headsÚcross_hidden_sizer   r   r   Únum_channelsr   r   Ú	use_cacheÚis_encoder_decoderÚpad_token_idÚeos_token_idÚbos_token_idc                    s˜   || _ || _|| _|| _|| _|| _|| _|
| _|| _|	| _	|| _
|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _tƒ jdd|i|¤Ž d S )Nr>   r   )r   r   r   r   r   r   r   r:   r8   r9   r;   r   r   r   r<   r   r=   r   r?   r@   rA   r   r   )r   r   r   r   r   r   r   r   r8   r9   r:   r;   r   r   r   r<   r   r   r=   r>   r?   r@   rA   r    r!   r   r#   r   ž   s,   zDiaDecoderConfig.__init__)r/   r0   r1   r2   r	   r3   r
   r	   r
   r	   r   r   r4   r   r5   Nr   TTr6   r   r7   )r$   r%   r&   r'   r(   r)   r*   r+   r   Úboolr   r,   r   r   r!   r#   r-   a   sŒ    :éþýüûúùø	÷
öõôóòñðïîíìëêér-   c                       s˜   e Zd ZdZdZdgZeedœZ										dd	edB d
edB de	de
dedB dedB dedB dee dB de	de
f‡ fdd„Zdd„ Z‡  ZS )Ú	DiaConfigav
  
    This is the configuration class to store the configuration of a [`DiaModel`]. It is used to instantiate a
    Dia 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
    [nari-labs/Dia-1.6B](https://huggingface.co/nari-labs/Dia-1.6B) 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_config (`DiaEncoderConfig`, *optional*):
            Configuration for the encoder part of the model. If not provided, a default `DiaEncoderConfig` will be used.
        decoder_config (`DiaDecoderConfig`, *optional*):
            Configuration for the decoder part of the model. If not provided, a default `DiaDecoderConfig` will be used.
        norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the normalization layers.
        is_encoder_decoder (`bool`, *optional*, defaults to `True`):
            Indicating that this model uses an encoder-decoder architecture.
        pad_token_id (`int`, *optional*):
            Deprecated. Please set this on `DiaDecoderConfig` directly. If provided, it will be forwarded
            to `decoder_config`.
        eos_token_id (`int`, *optional*):
            Deprecated. Please set this on `DiaDecoderConfig` directly. If provided, it will be forwarded
            to `decoder_config`.
        bos_token_id (`int`, *optional*):
            Deprecated. Please set this on `DiaDecoderConfig` directly. If provided, it will be forwarded
            to `decoder_config`.
        delay_pattern (`list[int]`, *optional*, defaults to `[0, 8, 9, 10, 11, 12, 13, 14, 15]`):
            The delay pattern for the decoder. The length of this list must match `decoder_config.num_channels`.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).

    Example:

    ```python
    >>> from transformers import DiaConfig, DiaModel

    >>> # Initializing a DiaConfig with default values
    >>> configuration = DiaConfig()

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

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```
    ÚdiaÚpast_key_values)Úencoder_configÚdecoder_configNr   Tr   rF   rG   r   r>   r?   r@   rA   Údelay_patternr   r=   c                    s  t |tƒrtdi |¤Ž}t |tƒrtdi |¤Ž}|d ur|ntƒ | _|d ur(|ntƒ | _|| _|d ur5|ng d¢| _|	| _|
| _	|d urMt
 d¡ || j_|d urZt
 d¡ || j_|d urgt
 d¡ || j_| jjt| jƒkstJ dƒ‚tƒ jdd|i|¤Ž d S )N)	é    é   r5   é
   é   r   é   é   é   zjPassing `pad_token_id` to `DiaConfig` is deprecated. Please set it directly on `DiaDecoderConfig` instead.zjPassing `eos_token_id` to `DiaConfig` is deprecated. Please set it directly on `DiaDecoderConfig` instead.zjPassing `bos_token_id` to `DiaConfig` is deprecated. Please set it directly on `DiaDecoderConfig` instead.z3Number of channels must match delay pattern length.r>   r   )Ú
isinstanceÚdictr   r-   rF   rG   r   rH   r   r=   ÚloggerÚwarning_oncer?   r@   rA   r<   Úlenr   r   )r   rF   rG   r   r>   r?   r@   rA   rH   r   r=   r    r!   r   r#   r     s:   

ÿÿÿÿzDiaConfig.__init__c                 O   s   | j S )z^Defaulting to audio config as it's the decoder in this case which is usually the text backbone)rG   )r   Úargsr    r   r   r#   Úget_text_config<  s   zDiaConfig.get_text_config)
NNr   TNNNNr   T)r$   r%   r&   r'   r(   Úkeys_to_ignore_at_inferencer   r-   Úsub_configsr*   rB   r)   Úlistr   rV   r,   r   r   r!   r#   rC   Ñ   sJ    2
õþýüûúùø
	÷
öõ4rC   )rC   r   r-   N)r'   Úconfiguration_utilsr   Úmodeling_rope_utilsr   Úutilsr   Ú
get_loggerr$   rR   r   r-   rC   Ú__all__r   r   r   r#   Ú<module>   s   
Ipp