o
    ¾e¦i÷'  ã                   @   sR   d 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	ddgZ
dS )	zParakeet model configuration.é   )ÚPreTrainedConfig)Úloggingc                       sV   e Zd ZdZdZdgZ										
														d‡ fdd„	Z‡  ZS )ÚParakeetEncoderConfiga¢  
    This is the configuration class to store the configuration of a [`ParakeetEncoder`]. It is used to instantiate a
    `ParakeetEncoder` model according to the specified arguments, defining the model architecture.

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

    Args:
        hidden_size (`int`, *optional*, defaults to 1024):
            Dimension of the layers and the hidden states.
        num_hidden_layers (`int`, *optional*, defaults to 24):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 8):
            Number of attention heads for each attention layer in the Transformer encoder.
        intermediate_size (`int`, *optional*, defaults to 4096):
            Dimension of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
        hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
            The non-linear activation function (function or string) in the encoder and pooler.
        attention_bias (`bool`, *optional*, defaults to `True`):
            Whether to use bias in the attention layers.
        convolution_bias (`bool`, *optional*, defaults to `True`):
            Whether to use bias in convolutions of the conformer's convolution module.
        conv_kernel_size (`int`, *optional*, defaults to 9):
            The kernel size of the convolution layers in the Conformer block.
        subsampling_factor (`int`, *optional*, defaults to 8):
            The factor by which the input sequence is subsampled.
        subsampling_conv_channels (`int`, *optional*, defaults to 256):
            The number of channels in the subsampling convolution layers.
        num_mel_bins (`int`, *optional*, defaults to 80):
            Number of mel features.
        subsampling_conv_kernel_size (`int`, *optional*, defaults to 3):
            The kernel size of the subsampling convolution layers.
        subsampling_conv_stride (`int`, *optional*, defaults to 2):
            The stride of the subsampling convolution layers.
        dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for all fully connected layers in the embeddings, encoder, and pooler.
        dropout_positions (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the positions in the input sequence.
        layerdrop (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the layers in the encoder.
        activation_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for activations inside the fully connected layer.
        attention_dropout (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention layers.
        max_position_embeddings (`int`, *optional*, defaults to 5000):
            The maximum sequence length that this model might ever be used with.
        scale_input (`bool`, *optional*, defaults to `True`):
            Whether to scale the input embeddings.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.

    Example:
        ```python
        >>> from transformers import ParakeetEncoderModel, ParakeetEncoderConfig

        >>> # Initializing a `ParakeetEncoder` configuration
        >>> configuration = ParakeetEncoderConfig()

        >>> # Initializing a model from the configuration
        >>> model = ParakeetEncoderModel(configuration)

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

    This configuration class is based on the ParakeetEncoder architecture from NVIDIA NeMo. You can find more details
    and pre-trained models at [nvidia/parakeet-ctc-1.1b](https://huggingface.co/nvidia/parakeet-ctc-1.1b).
    Úparakeet_encoderÚpast_key_valuesé   é   é   é   ÚsiluTé	   é   éP   r   é   çš™™™™™¹?ç        éˆ  ç{®Gáz”?c                    sš   || _ || _|| _|| _|| _|| _|| _|| _|| _|| _	|| _
|	| _|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _tƒ jdi |¤Ž d S ©N© )Úhidden_sizeÚnum_hidden_layersÚnum_attention_headsÚnum_key_value_headsÚintermediate_sizeÚ
hidden_actÚattention_biasÚconvolution_biasÚconv_kernel_sizeÚsubsampling_conv_kernel_sizeÚsubsampling_conv_strideÚsubsampling_factorÚsubsampling_conv_channelsÚnum_mel_binsÚdropoutÚdropout_positionsÚ	layerdropÚactivation_dropoutÚattention_dropoutÚmax_position_embeddingsÚscale_inputÚinitializer_rangeÚsuperÚ__init__)Úselfr   r   r   r   r   r   r   r   r!   r"   r#   r   r    r$   r%   r&   r'   r(   r)   r*   r+   Úkwargs©Ú	__class__r   úq/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/parakeet/configuration_parakeet.pyr-   `   s2   

ÿzParakeetEncoderConfig.__init__)r   r   r	   r
   r   TTr   r	   r   r   r   r   r   r   r   r   r   r   Tr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferencer-   Ú__classcell__r   r   r0   r2   r      s4    Eêr   c                       sT   e Zd ZdZdZdeiZ					ddeeB f‡ fd	d
„Ze	defdd„ƒZ
‡  ZS )ÚParakeetCTCConfigaã  
    This is the configuration class to store the configuration of a [`ParakeetForCTC`]. It is used to instantiate a
    Parakeet CTC model according to the specified arguments, defining the model 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 1025):
                Vocabulary size of the model.
            ctc_loss_reduction (`str`, *optional*, defaults to `"mean"`):
                Specifies the reduction to apply to the output of `torch.nn.CTCLoss`. Only relevant when training an
                instance of [`ParakeetForCTC`].
            ctc_zero_infinity (`bool`, *optional*, defaults to `True`):
                Whether to zero infinite losses and the associated gradients of `torch.nn.CTCLoss`. Infinite losses mainly
                occur when the inputs are too short to be aligned to the targets. Only relevant when training an instance
                of [`ParakeetForCTC`].
            encoder_config (`Union[dict, ParakeetEncoderConfig]`, *optional*):
                The config object or dictionary of the encoder.
            pad_token_id (`int`, *optional*, defaults to 1024):
                Padding token id. Also used as blank token id.

    Example:
        ```python
        >>> from transformers import ParakeetForCTC, ParakeetCTCConfig

        >>> # Initializing a Parakeet configuration
        >>> configuration = ParakeetCTCConfig()

        >>> # Initializing a model from the configuration
        >>> model = ParakeetForCTC(configuration)

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

    This configuration class is based on the Parakeet CTC architecture from NVIDIA NeMo. You can find more details
    and pre-trained models at [nvidia/parakeet-ctc-1.1b](https://huggingface.co/nvidia/parakeet-ctc-1.1b).
    Úparakeet_ctcÚencoder_configé  ÚmeanTNr   c                    sl   || _ || _|| _t|tƒrtdi |¤Ž| _n|d u rtƒ | _| j| _| jj| _|| _t	ƒ j
di |¤Ž d S r   )Ú
vocab_sizeÚctc_loss_reductionÚctc_zero_infinityÚ
isinstanceÚdictr   r<   r+   Úpad_token_idr,   r-   )r.   r?   r@   rA   r<   rD   r/   r0   r   r2   r-   Ä   s   	

zParakeetCTCConfig.__init__c                 K   s   | dd|  ¡ i|¤ŽS )zÐ
        Instantiate a [`ParakeetCTCConfig`] (or a derived class) from parakeet encoder model configuration.

        Returns:
            [`ParakeetCTCConfig`]: An instance of a configuration object
        r<   Nr   )Úto_dict)Úclsr<   r/   r   r   r2   Úfrom_encoder_configÜ   s   	z%ParakeetCTCConfig.from_encoder_config)r=   r>   TNr   )r3   r4   r5   r6   r7   r   Úsub_configsrC   r-   ÚclassmethodrG   r9   r   r   r0   r2   r:   ˜   s    (úûr:   N)r6   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerr3   Úloggerr   r:   Ú__all__r   r   r   r2   Ú<module>   s   
 P