Ë
    T^(hh.  ã                   óŒ   — d 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	 G d„ d	e«      Z
d	gZy
)zKOSMOS-2 model configurationé   )ÚPretrainedConfig)Úloggingc                   ób   ‡ — e Zd ZdZdZdZdgZddddœZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d
ˆ fd	„	Zˆ xZ	S )ÚKosmos2TextConfiga©  
    This is the configuration class to store the configuration of a [`Kosmos2TextModel`]. It is used to instantiate a
    KOSMOS-2 text decoder according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the text decoder of the KOSMOS-2
    [microsoft/kosmos-2-patch14-224](https://huggingface.co/microsoft/kosmos-2-patch14-224) 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 65037):
            Vocabulary size of the Kosmos2 model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`Kosmos2Model`].
        max_position_embeddings (`int`, *optional*, defaults to 2048):
            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_dim (`int`, *optional*, defaults to 2048):
            Dimensionality of the layers and the pooler layer.
        layers (`int`, *optional*, defaults to 24):
            Number of hidden layers in the Transformer encoder.
        ffn_dim (`int`, *optional*, defaults to 8192):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
        attention_heads (`int`, *optional*, defaults to 32):
            Number of attention heads for each attention layer in the Transformer encoder.
        activation_function (`str` or `function`, *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.
        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 ratio for the attention probabilities.
        activation_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for activations inside the fully connected layer.
        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.
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        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 `True`):
            Scale embeddings by diving by sqrt(embed_dim).
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models).
        pad_token_id (`int`, *optional*, defaults to 1):
            Token id used for padding.
        bos_token_id (`int`, *optional*, defaults to 0):
            Token id used for beginning of string.
        eos_token_id (`int`, *optional*, defaults to 2):
            Token id used for end of string.
    ```Úkosmos_2_text_modelÚtext_configÚpast_key_valuesÚattention_headsÚ	embed_dimÚlayers)Únum_attention_headsÚhidden_sizeÚnum_hidden_layersc                 óþ   •— t        ‰| �  d|||dœ|¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        || _        || _        || _        y )N)Úpad_token_idÚbos_token_idÚeos_token_id© )ÚsuperÚ__init__Ú
vocab_sizeÚmax_position_embeddingsr   r   Úffn_dimr
   Úactivation_functionÚdropoutÚattention_dropoutÚactivation_dropoutÚ	layerdropÚlayer_norm_epsÚinit_stdÚscale_embeddingÚ	use_cache)Úselfr   r   r   r   r   r
   r   r   r   r   r   r   r    r!   r"   r   r   r   ÚkwargsÚ	__class__s                       €úo/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/kosmos2/configuration_kosmos2.pyr   zKosmos2TextConfig.__init__V   sœ   ø€ ô, 	‰Ñð 	
Ø%Ø%Ø%ñ	
ð ò		
ð %ˆŒØ'>ˆÔ$Ø"ˆŒØˆŒØˆŒØ.ˆÔØ#6ˆÔ ØˆŒØ!2ˆÔØ"4ˆÔØ"ˆŒØ,ˆÔØ ˆŒØ.ˆÔØ"ˆ�ó    )iþ  é   r(   é   i    é    Úgeluçš™™™™™¹?r,   ç        r-   çñhãˆµøä>ç{®Gáz”?TTé   é    é   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyÚkeys_to_ignore_at_inferenceÚattribute_mapr   Ú__classcell__©r%   s   @r&   r   r      sp   ø„ ñ2ðh '€JØ#€OØ#4Ð"5Ðà0Ø"Ø%ñ€Mð Ø $ØØØØØ"ØØØØØØØØØØØ÷'+#ñ +#r'   r   c                   óD   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚKosmos2VisionConfiga¡	  
    This is the configuration class to store the configuration of a [`Kosmos2VisionModel`]. It is used to instantiate a
    KOSMOS-2 vision encoder according to the specified arguments, defining the model architecture. Instantiating a
    configuration with the defaults will yield a similar configuration to that of the vision encoder of the KOSMOS-2
    [microsoft/kosmos-2-patch14-224](https://huggingface.co/microsoft/kosmos-2-patch14-224) 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):
            Dimensionality of the encoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 4096):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        num_hidden_layers (`int`, *optional*, defaults to 24):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 16):
            Number of attention heads for each attention layer in the Transformer encoder.
        num_channels (`int`, *optional*, defaults to 3):
            The number of input channels.
        image_size (`int`, *optional*, defaults to 224):
            The size (resolution) of each image.
        patch_size (`int`, *optional*, defaults to 14):
            The size (resolution) of each patch.
        hidden_act (`str` or `function`, *optional*, defaults to `"quick_gelu"`):
            The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
            `"relu"`, `"selu"` and `"gelu_new"` `"quick_gelu"` are supported.
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        attention_dropout (`float`, *optional*, defaults to 0.0):
            The dropout ratio for the attention probabilities.
        initializer_range (`float`, *optional*, defaults to 0.02):
            The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
        initializer_factor (`float`, *optional*, defaults to 1.0):
            A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
            testing).
    ```Úkosmos_2_vision_modelÚvision_configc                 óÌ   •— t        ‰| �  di |¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        || _
        |
| _        |	| _        || _        y )Nr   )r   r   r   Úintermediate_sizer   r   Únum_channelsÚ
patch_sizeÚ
image_sizeÚinitializer_rangeÚinitializer_factorr   r   Ú
hidden_act)r#   r   rB   r   r   rC   rE   rD   rH   r   r   rF   rG   r$   r%   s                 €r&   r   zKosmos2VisionConfig.__init__®   sr   ø€ ô  	‰ÑÑ"˜6Ò"à&ˆÔØ!2ˆÔØ!2ˆÔØ#6ˆÔ Ø(ˆÔØ$ˆŒØ$ˆŒØ!2ˆÔØ"4ˆÔØ!2ˆÔØ,ˆÔØ$ˆ�r'   )i   i   r)   é   r   éà   é   Ú
quick_gelur.   r-   r/   g      ð?)r3   r4   r5   r6   r7   r8   r   r;   r<   s   @r&   r>   r>   „   sE   ø„ ñ$ðL )€JØ%€Oð ØØØØØØØØØØØ÷%ñ %r'   r>   c                   ó8   ‡ — e Zd ZdZdZeedœZ	 	 	 dˆ fd„	Zˆ xZ	S )ÚKosmos2Configat  
    This is the configuration class to store the configuration of a [`Kosmos2Model`]. It is used to instantiate a
    KOSMOS-2 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 KOSMOS-2
    [microsoft/kosmos-2-patch14-224](https://huggingface.co/microsoft/kosmos-2-patch14-224) architecture.

    Args:
        text_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`Kosmos2TextConfig`].
        vision_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`Kosmos2VisionConfig`].
        latent_query_num (`int`, *optional*, defaults to 64):
            The number of latent query tokens that represent the image features used in the text decoder component.
        kwargs (*optional*):
            Dictionary of keyword arguments.

    Example:

    ```python
    >>> from transformers import Kosmos2Config, Kosmos2Model

    >>> # Initializing a Kosmos-2 kosmos-2-patch14-224 style configuration
    >>> configuration = Kosmos2Config()

    >>> # Initializing a model (with random weights) from the kosmos-2-patch14-224 style configuration
    >>> model = Kosmos2Model(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```zkosmos-2)r   r@   c                 óÖ   •— t        ‰| �  di |¤Ž |€i }t        j                  d«       |€i }t        j                  d«       t	        di |¤Ž| _        t        di |¤Ž| _        || _        y )NzR`text_config` is `None`. Initializing the `Kosmos2TextConfig` with default values.zV`vision_config` is `None`. Initializing the `Kosmos2VisionConfig` with default values.r   )	r   r   ÚloggerÚinfor   r   r>   r@   Úlatent_query_num)r#   r   r@   rR   r$   r%   s        €r&   r   zKosmos2Config.__init__ñ   sm   ø€ ô 	‰ÑÑ"˜6Ò"àÐØˆKÜ�K‰KÐlÔmàÐ ØˆMÜ�K‰KÐpÔqä,Ñ;¨{Ñ;ˆÔÜ0ÑA°=ÑAˆÔà 0ˆÕr'   )NNé@   )
r3   r4   r5   r6   r7   r   r>   Úsub_configsr   r;   r<   s   @r&   rN   rN   Î   s/   ø„ ñð> €JØ"3ÐFYÑZ€Kð ØØ÷	1ñ 1r'   rN   N)r6   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerr3   rP   r   r>   rN   Ú__all__r   r'   r&   ú<module>rY      s\   ðñ #å 3Ý ð 
ˆ×	Ñ	˜HÓ	%€ôi#Ð(ô i#ôXG%Ð*ô G%ôT71Ð$ô 71ðt Ð
�r'   