o
    ei                     @   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                       sV   e Zd ZdZdZddiZeedZdgZ						
	
	dde	dB f 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.
        tie_word_embeddings (`bool`, *optional*, defaults to `True`):
            Whether to tie weight embeddings

    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
    ```	paligemmaimage_token_idimage_token_index)text_configvision_configpast_key_valuesN      Ttie_word_embeddingsc           	   
      s*  || _ || _|| _|| _|| _d| _t| jtr-|dd|d< t	|d  di || _n|d u r@t	d dddddd	d
dd| _|| _
t| j
tr^|dd|d< t	|d  di || _
n|d u rpt	d dddddd|d| _
| j
jd u rzd| j
_| jj| jj d | j
_|| j_t jdi | d S )NF
model_typesiglip_vision_modeli   i              r   )intermediate_sizehidden_size
patch_size
image_sizenum_hidden_layersnum_attention_heads
vocab_sizevision_use_headgemmar      i @        )r   r   r   r   num_key_value_headsis_encoder_decoderr   Tr    )r
   projection_dimr   r   r   r%   
isinstancedictgetr   r   use_bidirectional_attentionr   r   num_image_tokenssuper__init__)	selfr   r   r
   r   r'   r   r   kwargs	__class__r&   s/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/transformers/models/paligemma/configuration_paligemma.pyr.   O   sN   zPaliGemmaConfig.__init__)NNr   r   r   r   T)__name__
__module____qualname____doc__r   attribute_mapr   sub_configskeys_to_ignore_at_inferenceboolr.   __classcell__r&   r&   r1   r3   r      s"    0
r   N)r7   configuration_utilsr   utilsr   autor   r   
get_loggerr4   loggerr   __all__r&   r&   r&   r3   <module>   s   

r