Ë
    T^(h’B  ã                   óè   — d Z ddlmZ ddlmZmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZ erddlmZ dd	lmZ dd
lmZ  ej*                  e«      Zg d¢Zg d¢Z G d„ de
«      Z G d„ de«      ZddgZy)zWhisper model configurationé    )ÚOrderedDict)ÚTYPE_CHECKINGÚAnyÚMappingÚOptionalÚUnioné   )ÚPretrainedConfig)Ú
OnnxConfigÚOnnxSeq2SeqConfigWithPast)Úlogging)ÚFeatureExtractionMixin)ÚPreTrainedTokenizerBase)Ú
TensorType)Xé   é   é   é   é	   é
   é   é   é   é   é   é   é   é:   é;   é<   é=   é>   é?   éZ   é[   é\   é]   ie  in  i¶  i  i­  iÁ  i  i¢  i"  iÄ  ió  iÿ  i  i?  ia  io  ic  iö  iS  ir  i9	  i¸	  i‹  i¨  is  iø  iÈ  i³  iß  i¹  i#  i‰%  iç&  iC)  i"*  iœ,  i½-  iƒ.  ik3  i�5  i„5  iØ9  iÊ;  i@  i—A  iHF  iK  i6L  iôP  i!W  i—Y  ii  i�u  iÔv  i�‚  i…ˆ  i[�  i-ž  iež  i²¸  iú¿  éQÄ  i·Ä  é¸Ä  é¹Ä  )Vr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   ig  i÷  i
  i  ii  i}  i†  i–  iš  i£  iF  i=  i¾  iœ	  iC
  i®  iµ  iÄ  iÐ  i  iy  iW  i;  i¹  i÷  ii  ie#  i§$  i¼(  i±*  i¢.  i/  i+0  i1  iá5  iM7  i+9  i¡;  i=  i©@  iÜ@  iºG  iJ  ikN  i«T  iøW  if  i1f  iCg  iwn  is  i¢{  i.~  iÖ~  i�  io§  iA¹  iÎÂ  iNÄ  iRÄ  r)   r*   iºÄ  c            %       óˆ   ‡ — e Zd ZdZdZdgZddddœZddd	d
d	d
ddddddddddddddddddddddgddddddddddf%ˆ fd„	Zˆ xZS )ÚWhisperConfiga#  
    This is the configuration class to store the configuration of a [`WhisperModel`]. It is used to instantiate a
    Whisper 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 Whisper
    [openai/whisper-tiny](https://huggingface.co/openai/whisper-tiny) 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 51865):
            Vocabulary size of the Whisper model. Defines the number of different tokens that can be represented by the
            `decoder_input_ids` passed when calling [`WhisperModel`]
        num_mel_bins (`int`, *optional*, defaults to 80):
            Number of mel features used per input features. Should correspond to the value used in the
            `WhisperProcessor` class.
        encoder_layers (`int`, *optional*, defaults to 4):
            Number of encoder layers.
        decoder_layers (`int`, *optional*, defaults to 4):
            Number of decoder layers.
        encoder_attention_heads (`int`, *optional*, defaults to 6):
            Number of attention heads for each attention layer in the Transformer encoder.
        decoder_attention_heads (`int`, *optional*, defaults to 6):
            Number of attention heads for each attention layer in the Transformer decoder.
        encoder_ffn_dim (`int`, *optional*, defaults to 1536):
            Dimensionality of the "intermediate" (often named feed-forward) layer in encoder.
        decoder_ffn_dim (`int`, *optional*, defaults to 1536):
            Dimensionality of the "intermediate" (often named feed-forward) layer in decoder.
        encoder_layerdrop (`float`, *optional*, defaults to 0.0):
            The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        decoder_layerdrop (`float`, *optional*, defaults to 0.0):
            The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
            for more details.
        decoder_start_token_id (`int`, *optional*, defaults to 50257):
            Corresponds to the "<|startoftranscript|>" token, which is automatically used when no `decoder_input_ids`
            are provided to the `generate` function. It is used to guide the model`s generation process depending on
            the task.
        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`):
            Whether the model is used as an encoder/decoder or not.
        activation_function (`str`, *optional*, defaults to `"gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"silu"` and `"gelu_new"` are supported.
        d_model (`int`, *optional*, defaults to 384):
            Dimensionality of the layers.
        dropout (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        activation_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for activations inside the fully connected layer.
        init_std (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        scale_embedding (`bool`, *optional*, defaults to False):
            Scale embeddings by diving by sqrt(d_model).
        max_source_positions (`int`, *optional*, defaults to 1500):
            The maximum sequence length of log-mel filter-bank features that this model might ever be used with.
        max_target_positions (`int`, *optional*, defaults to 448):
            The maximum sequence length that this model might ever be used with. Typically set this to something large
            just in case (e.g., 512 or 1024 or 2048).
        pad_token_id (`int`, *optional*, defaults to 50256):
            Padding token id.
        bos_token_id (`int`, *optional*, defaults to 50256):
            Begin of stream token id.
        eos_token_id (`int`, *optional*, defaults to 50256):
            End of stream token id.
        suppress_tokens (`List[int]`, *optional*):
            A list containing the non-speech tokens that will be used by the logit processor in the `generate`
            function. NON_SPEECH_TOKENS and NON_SPEECH_TOKENS_MULTI each correspond to the `english-only` and the
            `multilingual` model.
        begin_suppress_tokens (`List[int]`, *optional*, defaults to `[220,50256]`):
            A list containing tokens that will be supressed at the beginning of the sampling process. Initialized as
            the token for `" "` (`blank_token_id`) and the `eos_token_id`
        use_weighted_layer_sum (`bool`, *optional*, defaults to `False`):
            Whether to use a weighted average of layer outputs with learned weights. Only relevant when using an
            instance of [`WhisperForAudioClassification`].
        classifier_proj_size (`int`, *optional*, defaults to 256):
            Dimensionality of the projection before token mean-pooling for classification. Only relevant when using an
            instance of [`WhisperForAudioClassification`].
        apply_spec_augment (`bool`, *optional*, defaults to `False`):
            Whether to apply *SpecAugment* data augmentation to the outputs of the feature encoder. For reference see
            [SpecAugment: A Simple Data Augmentation Method for Automatic Speech
            Recognition](https://arxiv.org/abs/1904.08779).
        mask_time_prob (`float`, *optional*, defaults to 0.05):
            Percentage (between 0 and 1) of all feature vectors along the time axis which will be masked. The masking
            procecure generates `mask_time_prob*len(time_axis)/mask_time_length` independent masks over the axis. If
            reasoning from the propability of each feature vector to be chosen as the start of the vector span to be
            masked, *mask_time_prob* should be `prob_vector_start*mask_time_length`. Note that overlap may decrease the
            actual percentage of masked vectors. This is only relevant if `apply_spec_augment == True`.
        mask_time_length (`int`, *optional*, defaults to 10):
            Length of vector span along the time axis.
        mask_time_min_masks (`int`, *optional*, defaults to 2),:
            The minimum number of masks of length `mask_feature_length` generated along the time axis, each time step,
            irrespectively of `mask_feature_prob`. Only relevant if ''mask_time_prob*len(time_axis)/mask_time_length <
            mask_time_min_masks''
        mask_feature_prob (`float`, *optional*, defaults to 0.0):
            Percentage (between 0 and 1) of all feature vectors along the feature axis which will be masked. The
            masking procecure generates `mask_feature_prob*len(feature_axis)/mask_time_length` independent masks over
            the axis. If reasoning from the propability of each feature vector to be chosen as the start of the vector
            span to be masked, *mask_feature_prob* should be `prob_vector_start*mask_feature_length`. Note that overlap
            may decrease the actual percentage of masked vectors. This is only relevant if `apply_spec_augment is
            True`.
        mask_feature_length (`int`, *optional*, defaults to 10):
            Length of vector span along the feature axis.
        mask_feature_min_masks (`int`, *optional*, defaults to 0),:
            The minimum number of masks of length `mask_feature_length` generated along the feature axis, each time
            step, irrespectively of `mask_feature_prob`. Only relevant if
            `mask_feature_prob*len(feature_axis)/mask_feature_length < mask_feature_min_masks`.
        median_filter_width (`int`, *optional*, defaults to 7):
            Width of the median filter used to smoothen to cross-attention outputs when computing token timestamps.
            Should be an odd number.

    Example:

    ```python
    >>> from transformers import WhisperConfig, WhisperModel

    >>> # Initializing a Whisper tiny style configuration
    >>> configuration = WhisperConfig()

    >>> # Initializing a model (with random weights) from the tiny style configuration
    >>> model = WhisperModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ÚwhisperÚpast_key_valuesÚencoder_attention_headsÚd_model)Únum_key_value_headsÚnum_attention_headsÚhidden_sizei™Ê  éP   é   é   i   g        r(   TÚgelui€  g{®Gáz”?FiÜ  iÀ  iPÄ  NéÜ   é   gš™™™™™©?r   r   r   r   c&                 óæ  •— || _         || _        || _        || _        || _        || _        || _        || _        || _        || _	        || _
        || _        || _        || _        |	| _        |
| _        || _        || _        || _        || _        || _        || _        || _        || _        || _        | | _        |!| _        |"| _        |#| _        |$| _        |%| _        t?        ‰'| �€  d|||||||dœ|&¤Ž y )N)Úpad_token_idÚbos_token_idÚeos_token_idÚis_encoder_decoderÚdecoder_start_token_idÚsuppress_tokensÚbegin_suppress_tokens© )!Ú
vocab_sizeÚnum_mel_binsr0   Úencoder_layersr/   Údecoder_layersÚdecoder_attention_headsÚdecoder_ffn_dimÚencoder_ffn_dimÚdropoutÚattention_dropoutÚactivation_dropoutÚactivation_functionÚinit_stdÚencoder_layerdropÚdecoder_layerdropÚ	use_cacheÚnum_hidden_layersÚscale_embeddingÚmax_source_positionsÚmax_target_positionsÚclassifier_proj_sizeÚuse_weighted_layer_sumÚapply_spec_augmentÚmask_time_probÚmask_time_lengthÚmask_time_min_masksÚmask_feature_probÚmask_feature_lengthÚmask_feature_min_masksÚmedian_filter_widthÚsuperÚ__init__)(ÚselfrC   rD   rE   r/   rF   rG   rH   rI   rO   rP   r?   rQ   r>   rM   r0   rJ   rK   rL   rN   rS   rT   rU   r;   r<   r=   r@   rA   rW   rV   rX   rY   rZ   r[   r\   r]   r^   r_   ÚkwargsÚ	__class__s(                                          €úo/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/whisper/configuration_whisper.pyra   zWhisperConfig.__init__Æ   s.  ø€ ðR %ˆŒØ(ˆÔØˆŒØ,ˆÔØ'>ˆÔ$Ø,ˆÔØ'>ˆÔ$Ø.ˆÔØ.ˆÔØˆŒØ!2ˆÔØ"4ˆÔØ#6ˆÔ Ø ˆŒØ!2ˆÔØ!2ˆÔØ"ˆŒØ!/ˆÔØ.ˆÔØ$8ˆÔ!Ø$8ˆÔ!ð %9ˆÔ!Ø&<ˆÔ#ð #5ˆÔØ,ˆÔØ 0ˆÔØ#6ˆÔ Ø!2ˆÔØ#6ˆÔ Ø&<ˆÔ#à#6ˆÔ ä‰Ñð 		
Ø%Ø%Ø%Ø1Ø#9Ø+Ø"7ñ		
ð ó		
ó    )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚkeys_to_ignore_at_inferenceÚattribute_mapra   Ú__classcell__©rd   s   @re   r,   r,   ;   s¬   ø„ ñ@ðD €JØ#4Ð"5Ðà8Ø8Ø ñ€Mð ØØØ !ØØ !ØØØØØ$ØØØ"ØØØØØØØ!Ø ØØØØØ" E˜lØ$Ø Ø ØØØØØØ Ø÷MW
ñ W
rf   r,   c                   óª   ‡ — e Zd Zedeeeeef   f   fd„«       Z	 	 	 	 	 	 	 dded   dedede	de
d	   d
edededeeef   fˆ fd„Zedefd„«       Zˆ xZS )ÚWhisperOnnxConfigÚreturnc                 ó    — t        dddddœfg«      }| j                  rddi|d<   nddd	œ|d<   | j                  r| j                  |d
¬«       |S )NÚinput_featuresÚbatchÚfeature_sizeÚencoder_sequence)r   r   r   r   Údecoder_input_idsÚdecoder_sequence)r   r   Úinputs)Ú	direction)r   Úuse_pastÚfill_with_past_key_values_)rb   Úcommon_inputss     re   rz   zWhisperOnnxConfig.inputs!  sj   € ä#à! w°>ÐFXÑ#YÐZðó
ˆð
 �=Š=Ø23°W°ˆMÐ-Ò.à5<ÐASÑ1TˆMÐ-Ñ.à�=Š=Ø×+Ñ+¨MÀXÐ+ÔNàÐrf   Úpreprocessor)r   r   Ú
batch_sizeÚ
seq_lengthÚis_pairÚ	frameworkr   Úsampling_rateÚtime_durationÚ	frequencyc	           	      ól  •— t        «       }	t        j                  | |j                  |||||¬«      }
|
d   j                  d   }| j
                  r|dz  n|}t        ‰| �	  |j                  ||||«      }|
j                  d«      |	d<   |j                  d«      |	d<   d|v r|j                  d«      |	d<   |	S )N)r   r€   rƒ   r„   r…   r†   rt   r   rx   r.   )	r   r   Úgenerate_dummy_inputsÚfeature_extractorÚshaper|   r`   Ú	tokenizerÚpop)rb   r   r€   r�   r‚   rƒ   r„   r…   r†   Údummy_inputsÚencoder_inputsÚencoder_sequence_lengthÚdecoder_inputsrd   s                €re   rˆ   z'WhisperOnnxConfig.generate_dummy_inputs2  sØ   ø€ ô #“}ˆÜ#×9Ñ9ØØ%×7Ñ7Ø!ØØ'Ø'Øô
ˆð #1Ð1AÑ"B×"HÑ"HÈÑ"KÐØ59·]²]Ð,°Ò1È
ˆ
ä™Ñ6Ø×"Ñ" J°
¸GÀYó
ˆð *8×);Ñ);Ð<LÓ)MˆÐ%Ñ&Ø,:×,>Ñ,>Ð?RÓ,SˆÐ(Ñ)à Ñ.Ø.<×.@Ñ.@ÐARÓ.SˆLÐ*Ñ+àÐrf   c                  ó   — y)Ngü©ñÒMbP?rB   )rb   s    re   Úatol_for_validationz%WhisperOnnxConfig.atol_for_validationV  s   € àrf   )éÿÿÿÿr“   FNi"V  g      @r8   )rg   rh   ri   Úpropertyr   ÚstrÚintrz   r   Úboolr   Úfloatr   rˆ   r’   rn   ro   s   @re   rq   rq      sÓ   ø„ Øð˜  W¨S°#¨XÑ%6Ð 6Ñ7ò ó ðð& ØØØ,0Ø"Ø"Øñ"àÐOÑPð"ð ð"ð ð	"ð
 ð"ð ˜LÑ)ð"ð ð"ð ð"ð ð"ð 
��c�Ñ	õ"ðH ð Uò ó ôrf   rq   N)rj   Úcollectionsr   Útypingr   r   r   r   r   Úconfiguration_utilsr
   Úonnxr   r   Úutilsr   Úfeature_extraction_utilsr   Útokenization_utils_baser   r   Ú
get_loggerrg   ÚloggerÚNON_SPEECH_TOKENSÚNON_SPEECH_TOKENS_MULTIr,   rq   Ú__all__rB   rf   re   ú<module>r¥      sw   ðñ "å #ß ?Õ ?å 3ß 9Ý ñ ÝBÝBÝ#à	ˆ×	Ñ	˜HÓ	%€ò
Ð ò
Ð ôb
Ð$ô b
ôJ8Ð1ô 8ðv Ð/Ð
0�rf   