Ë
    T^(h-+  ã                   óœ   — d 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
  e
j                  e«      Z G d„ d	e«      Z G d
„ de«      Zd	dgZy)zXLM configurationé    )ÚOrderedDict)ÚMappingé   )ÚPretrainedConfig)Ú
OnnxConfig)Úloggingc                   óx   ‡ — e Zd ZdZdZdddddœZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	ˆ fd„	Zˆ xZS )
Ú	XLMConfiga  
    This is the configuration class to store the configuration of a [`XLMModel`] or a [`TFXLMModel`]. It is used to
    instantiate a XLM 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
    [FacebookAI/xlm-mlm-en-2048](https://huggingface.co/FacebookAI/xlm-mlm-en-2048) 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 30145):
            Vocabulary size of the BERT model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`XLMModel`] or [`TFXLMModel`].
        emb_dim (`int`, *optional*, defaults to 2048):
            Dimensionality of the encoder layers and the pooler layer.
        n_layer (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        n_head (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer encoder.
        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.1):
            The dropout probability for the attention mechanism
        gelu_activation (`bool`, *optional*, defaults to `True`):
            Whether or not to use *gelu* for the activations instead of *relu*.
        sinusoidal_embeddings (`bool`, *optional*, defaults to `False`):
            Whether or not to use sinusoidal positional embeddings instead of absolute positional embeddings.
        causal (`bool`, *optional*, defaults to `False`):
            Whether or not the model should behave in a causal manner. Causal models use a triangular attention mask in
            order to only attend to the left-side context instead if a bidirectional context.
        asm (`bool`, *optional*, defaults to `False`):
            Whether or not to use an adaptive log softmax projection layer instead of a linear layer for the prediction
            layer.
        n_langs (`int`, *optional*, defaults to 1):
            The number of languages the model handles. Set to 1 for monolingual models.
        use_lang_emb (`bool`, *optional*, defaults to `True`)
            Whether to use language embeddings. Some models use additional language embeddings, see [the multilingual
            models page](http://huggingface.co/transformers/multilingual.html#xlm-language-embeddings) for information
            on how to use them.
        max_position_embeddings (`int`, *optional*, defaults to 512):
            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).
        embed_init_std (`float`, *optional*, defaults to 2048^-0.5):
            The standard deviation of the truncated_normal_initializer for initializing the embedding matrices.
        init_std (`int`, *optional*, defaults to 50257):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices except the
            embedding matrices.
        layer_norm_eps (`float`, *optional*, defaults to 1e-12):
            The epsilon used by the layer normalization layers.
        bos_index (`int`, *optional*, defaults to 0):
            The index of the beginning of sentence token in the vocabulary.
        eos_index (`int`, *optional*, defaults to 1):
            The index of the end of sentence token in the vocabulary.
        pad_index (`int`, *optional*, defaults to 2):
            The index of the padding token in the vocabulary.
        unk_index (`int`, *optional*, defaults to 3):
            The index of the unknown token in the vocabulary.
        mask_index (`int`, *optional*, defaults to 5):
            The index of the masking token in the vocabulary.
        is_encoder(`bool`, *optional*, defaults to `True`):
            Whether or not the initialized model should be a transformer encoder or decoder as seen in Vaswani et al.
        summary_type (`string`, *optional*, defaults to "first"):
            Argument used when doing sequence summary. Used in the sequence classification and multiple choice models.

            Has to be one of the following options:

                - `"last"`: Take the last token hidden state (like XLNet).
                - `"first"`: Take the first token hidden state (like BERT).
                - `"mean"`: Take the mean of all tokens hidden states.
                - `"cls_index"`: Supply a Tensor of classification token position (like GPT/GPT-2).
                - `"attn"`: Not implemented now, use multi-head attention.
        summary_use_proj (`bool`, *optional*, defaults to `True`):
            Argument used when doing sequence summary. Used in the sequence classification and multiple choice models.

            Whether or not to add a projection after the vector extraction.
        summary_activation (`str`, *optional*):
            Argument used when doing sequence summary. Used in the sequence classification and multiple choice models.

            Pass `"tanh"` for a tanh activation to the output, any other value will result in no activation.
        summary_proj_to_labels (`bool`, *optional*, defaults to `True`):
            Used in the sequence classification and multiple choice models.

            Whether the projection outputs should have `config.num_labels` or `config.hidden_size` classes.
        summary_first_dropout (`float`, *optional*, defaults to 0.1):
            Used in the sequence classification and multiple choice models.

            The dropout ratio to be used after the projection and activation.
        start_n_top (`int`, *optional*, defaults to 5):
            Used in the SQuAD evaluation script.
        end_n_top (`int`, *optional*, defaults to 5):
            Used in the SQuAD evaluation script.
        mask_token_id (`int`, *optional*, defaults to 0):
            Model agnostic parameter to identify masked tokens when generating text in an MLM context.
        lang_id (`int`, *optional*, defaults to 1):
            The ID of the language used by the model. This parameter is used when generating text in a given language.

    Examples:

    ```python
    >>> from transformers import XLMConfig, XLMModel

    >>> # Initializing a XLM configuration
    >>> configuration = XLMConfig()

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

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```ÚxlmÚemb_dimÚn_headsÚn_layersÚ
vocab_size)Úhidden_sizeÚnum_attention_headsÚnum_hidden_layersÚn_wordsc"                 óø  •— || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        || _        d|"v r
|"d   | _        tA        ‰#| �„  d| |!dœ|"¤Ž y)zConstructs XLMConfig.r   )Úpad_token_idÚbos_token_idN© )"r   r   r   r   ÚdropoutÚattention_dropoutÚgelu_activationÚsinusoidal_embeddingsÚcausalÚasmÚn_langsÚuse_lang_embÚlayer_norm_epsÚ	bos_indexÚ	eos_indexÚ	pad_indexÚ	unk_indexÚ
mask_indexÚ
is_encoderÚmax_position_embeddingsÚembed_init_stdÚinit_stdÚsummary_typeÚsummary_use_projÚsummary_activationÚsummary_proj_to_labelsÚsummary_first_dropoutÚstart_n_topÚ	end_n_topÚmask_token_idÚlang_idr   ÚsuperÚ__init__)$Úselfr   r   r   r   r   r   r   r   r   r   r   r   r'   r(   r    r)   r!   r"   r#   r$   r%   r&   r*   r+   r,   r-   r.   r/   r0   r1   r2   r   r   ÚkwargsÚ	__class__s$                                      €úg/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/xlm/configuration_xlm.pyr4   zXLMConfig.__init__”   s  ø€ ðL %ˆŒØˆŒØ ˆŒØˆŒØˆŒØ!2ˆÔØ.ˆÔØ%:ˆÔ"ØˆŒØˆŒØˆŒØ(ˆÔØ,ˆÔØ"ˆŒØ"ˆŒØ"ˆŒØ"ˆŒØ$ˆŒØ$ˆŒØ'>ˆÔ$Ø,ˆÔØ ˆŒØ(ˆÔØ 0ˆÔØ"4ˆÔØ&<ˆÔ#Ø%:ˆÔ"Ø&ˆÔØ"ˆŒØ*ˆÔØˆŒà˜ÑØ! )Ñ,ˆDŒLä‰ÑÐX lÀÑXÐQWÓXó    )!iÁu  i   é   é   çš™™™™™¹?r<   TFFFé   Ti   gÍ;fž –?gê-�™—q=g{®Gáz”?r   r=   é   r   é   TÚfirstTNTr<   r?   r?   r   r   r>   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚattribute_mapr4   Ú__classcell__)r7   s   @r8   r
   r
      s˜   ø„ ñmð^ €Jà Ø(Ø'Øñ	€Mð ØØØØØØØ#ØØØØØ #Ø!ØØØØØØØØØØØØ#Ø!ØØØØØØ÷EIYñ IYr9   r
   c                   ó6   — e Zd Zedeeeeef   f   fd„«       Zy)ÚXLMOnnxConfigÚreturnc                 ó`   — | j                   dk(  rddddœ}ndddœ}t        d|fd|fd	|fg«      S )
Nzmultiple-choiceÚbatchÚchoiceÚsequence)r   r=   r>   )r   r=   Ú	input_idsÚattention_maskÚtoken_type_ids)Útaskr   )r5   Údynamic_axiss     r8   ÚinputszXLMOnnxConfig.inputsâ   sO   € à�9‰9Ð)Ò)Ø&¨8¸
ÑC‰Là&¨:Ñ6ˆLÜà˜lÐ+Ø! <Ð0Ø! <Ð0ðó
ð 	
r9   N)rA   rB   rC   Úpropertyr   ÚstrÚintrT   r   r9   r8   rI   rI   á   s.   „ Øð
˜  W¨S°#¨XÑ%6Ð 6Ñ7ò 
ó ñ
r9   rI   N)rD   Úcollectionsr   Útypingr   Úconfiguration_utilsr   Úonnxr   Úutilsr   Ú
get_loggerrA   Úloggerr
   rI   Ú__all__r   r9   r8   ú<module>r`      sW   ðñ å #Ý å 3Ý Ý ð 
ˆ×	Ñ	˜HÓ	%€ôAYÐ ô AYôJ
�Jô 
ð  ˜Ð
(�r9   