o
    ZhR                     @   sP   d Z ddlmZ ddlmZ ddlmZmZ ee	Z
G dd deZdgZdS )	zPaliGemmamodel configuration   )PretrainedConfig)logging   )CONFIG_MAPPING
AutoConfigc                       sJ   e Zd ZdZdZddiZeedZdgZ						
	
d fdd	Z	  Z
S )PaliGemmaConfiga  
    This is the configuration class to store the configuration of a [`PaliGemmaForConditionalGeneration`]. It is used to instantiate an
    PaliGemmamodel according to the specified arguments, defining the model architecture. Instantiating a configuration
    with the defaults will yield a similar configuration to that of the PaliGemma-2B.

    e.g. [paligemma-hf/paligemma-2b](https://huggingface.co/paligemma-hf/paligemma-2b)

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

    Args:
        vision_config (`PaliGemmaVisionConfig`,  *optional*):
            Custom vision config or dict
        text_config (`Union[AutoConfig, dict]`, *optional*):
            The config object of the text backbone. Can be any of `LlamaConfig` or `MistralConfig`.
        image_token_index (`int`, *optional*, defaults to 256000):
            The image token index to encode the image prompt.
        vocab_size (`int`, *optional*, defaults to 257152):
            Vocabulary size of the PaliGemmamodel. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`~PaliGemmaForConditionalGeneration`]
        projection_dim (`int`, *optional*, defaults to 2048):
            Dimension of the multimodal projection space.
        hidden_size (`int`, *optional*, defaults to 2048):
            Dimension of the hidden layer of the Language model.

    Example:

    ```python
    >>> from transformers import PaliGemmaForConditionalGeneration, PaliGemmaConfig, SiglipVisionConfig, GemmaConfig

    >>> # Initializing a Siglip-like vision config
    >>> vision_config = SiglipVisionConfig()

    >>> # Initializing a PaliGemma config
    >>> text_config = GemmaConfig()

    >>> # Initializing a PaliGemma paligemma-3b-224 style configuration
    >>> configuration = PaliGemmaConfig(vision_config, text_config)

    >>> # Initializing a model from the paligemma-3b-224 style configuration
    >>> model = PaliGemmaForConditionalGeneration(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Z	paligemmaZimage_token_idimage_token_index)text_configvision_configZpast_key_valuesN      c              
      s   || _ || _|| _|| _d| _t| jtr.d|v r|d nd|d< t|d  di || _n|d u rAtd dddddd	d
dd| _|| _t| jtrcd|v rR|d nd|d< t|d  di || _n|d u rutd dddddd|d| _| jj	| jj
 d | j_|| j_t jdi | d S )NF
model_typeZsiglip_vision_modeli   i              r   )intermediate_sizehidden_size
patch_size
image_sizenum_hidden_layersnum_attention_heads
vocab_sizeZvision_use_headZgemmar      i @        )r   r   r   r   Znum_key_value_headsis_encoder_decoderr   r    )r   projection_dimr   r
   r   
isinstancedictr   r	   r   r   Znum_image_tokenssuper__init__)selfr
   r	   r   r   r   r   kwargs	__class__r   d/var/www/auris/lib/python3.10/site-packages/transformers/models/paligemma/configuration_paligemma.pyr#   N   sJ   
	zPaliGemmaConfig.__init__)NNr   r   r   r   )__name__
__module____qualname____doc__r   Zattribute_mapr   Zsub_configsZkeys_to_ignore_at_inferencer#   __classcell__r   r   r&   r(   r      s    .
r   N)r,   Zconfiguration_utilsr   utilsr   autor   r   Z
get_loggerr)   loggerr   __all__r   r   r   r(   <module>   s   

j