
    i                        d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
  ej                  e      Z ed	      e G d
 de                    Z ed	      e G d de                    Z ed	      e G d de                    ZdgZy)zIdefics2 model configuration    )strict   )PreTrainedConfig)auto_docstringlogging   )CONFIG_MAPPING
AutoConfigzHuggingFaceM4/idefics2-8b)
checkpointc                       e Zd ZU dZdZdZdZeed<   dZ	eed<   dZ
eed	<   dZeed
<   dZeed<   dZeee   z  eeef   z  ed<   dZeee   z  eeef   z  ed<   dZeed<   dZeed<   dZeez  ed<   dZeed<   y)Idefics2VisionConfiga  
    Example:

    ```python
    >>> from transformers.models.idefics2.modeling_idefics2 import Idefics2VisionTransformer
    >>> from transformers.models.idefics2.configuration_idefics2 import Idefics2VisionConfig

    >>> # Initializing a Idefics2VisionConfig with google/siglip-base-patch16-224 style configuration
    >>> configuration = Idefics2VisionConfig()

    >>> # Initializing a Idefics2VisionTransformer (with random weights) from the google/siglip-base-patch16-224 style configuration
    >>> model = Idefics2VisionTransformer(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```idefics2_visionvision_configi   hidden_sizei   intermediate_size   num_hidden_layersnum_attention_headsr   num_channels   
image_size    
patch_sizegelu_pytorch_tanh
hidden_actư>layer_norm_eps        attention_dropout{Gz?initializer_rangeN)__name__
__module____qualname____doc__
model_typebase_config_keyr   int__annotations__r   r   r   r   r   listtupler   r   strr   floatr   r!        /var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/transformers/models/idefics2/configuration_idefics2.pyr   r      s    " #J%OK!s!s!!L#47Jd3i%S/1746Jd3i%S/16)J) NE %(us{(#u#r/   r   c                       e Zd ZU dZdZdZeed<   dZe	ed<   dZ
eed<   d	Ze	ed
<   dZe	ed<   dZe	ed<   dZe	ed<   dZe	ed<   dZee	z  ed<   dZeed<   d Zy)Idefics2PerceiverConfigaX  
    resampler_n_latents (`int`, *optional*, defaults to 64):
        Number of latent embeddings to resample ("compress") the input sequence to (usually < 128).
    resampler_depth (`int`, *optional*, defaults to 3):
        Depth of the Perceiver Resampler (Transformer w/ cross attention). Should be shallow (<= 3).
    resampler_n_heads (`int`, *optional*, defaults to 16):
        Number of heads in each Transformer block (for multi-headed self-attention).
    resampler_head_dim (`int`, *optional*, defaults to 96):
        Dimensionality of each head projection in the Transformer block.
    idefics2_perceiversilur   i   r   r   rms_norm_eps@   resampler_n_latentsr   resampler_depth   resampler_n_heads`   resampler_head_dim   num_key_value_headsr   r   r    r!   c                     | j                   | j                  kD  r%t        d| j                    d| j                         y)zOPart of `@strict`-powered validation. Validates the architecture of the config.znum_key_value_heads=z1 must be less than or equal to resampler_n_heads=N)r>   r:   
ValueError)selfs    r0   validate_architecturez-Idefics2PerceiverConfig.validate_architectureX   sM    ##d&<&<<&t'?'?&@ A&&*&<&<%=?  =r/   N)r"   r#   r$   r%   r&   r   r,   r)   r   r(   r5   r-   r7   r8   r:   r<   r>   r   r!   rB   r.   r/   r0   r2   r2   =   s    	 &JJKL%!!OSs    %(us{(#u#r/   r2   c                        e Zd ZU dZdZeeedZdZ	e
ed<   dZeed<   dZe
ed	<   d
Zeez  d
z  ed<   d
Zeez  d
z  ed<   d
Zeez  d
z  ed<    fdZ xZS )Idefics2Configa  
    perceiver_config (`IdeficsPerceiverConfig` or `dict`, *optional*):
        Custom perceiver config or dict

    Example:
    ```python
    >>> from transformers import Idefics2Model, Idefics2Config
    >>> # Initializing configuration
    >>> configuration = Idefics2Config()
    >>> # Initializing a model from the configuration
    >>> model = Idefics2Model(configuration)
    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```idefics2)text_configperceiver_configr   T	use_cachei}  image_token_idFtie_word_embeddingsNr   rG   rF   c                    | j                   %t               | _         t        j                  d       n4t	        | j                   t
              rt        di | j                   | _         | j                  %t               | _        t        j                  d       n4t	        | j                  t
              rt        di | j                  | _        t	        | j                  t
              rT| j                  j                  dd      | j                  d<   t        | j                  d      di | j                  | _        n7| j                  +t        j                  d       t        d   ddd	      | _        | j                  j                  | j                   j                  k7  r_| j                  j                  | j                   _        | j                  j                  | j                   _        t        j                  d
       t        | <  di | y )Nz7perciver_config is None, using default perceiver configz2vision_config is None, using default vision configr&   mistralz.text_config is None, using default text configi   gh㈵>r   )max_position_embeddingsr5   pad_token_idzPerceiver config has a different `hidden_size` than text config, which means default values were used. In your model's config on the hub, add `hidden_size` and `rms_norm_eps` keys under the `perceiver_config` dict. r.   )rG   r2   loggerinfo
isinstancedictr   r   rF   getr	   r   r5   warning_oncesuper__post_init__)rA   kwargs	__class__s     r0   rV   zIdefics2Config.__post_init__   s     ($;$=D!KKQR--t4$;$Td>S>S$TD!%!5!7DKKLM**D1!5!K8J8J!KDd&&--1-=-=-A-A,PY-ZD\*-d.>.>|.LMaPTP`P`aD%KKHI-i8(0!	 D ''4+@+@+L+LL040@0@0L0LD!!-151A1A1N1ND!!.C
 	''r/   )r"   r#   r$   r%   r&   r
   r2   r   sub_configsrH   boolr)   rI   r(   rJ   r   rR   r   rG   rF   rV   __classcell__)rX   s   @r0   rD   rD   a   s     J!3-K It NC  %%48M4**T187;d--4;26K((4/6!( !(r/   rD   N)r%   huggingface_hub.dataclassesr   configuration_utilsr   utilsr   r   autor	   r
   
get_loggerr"   rO   r   r2   rD   __all__r.   r/   r0   <module>rb      s    # . 3 , - 
		H	% 67$+ $  8$D 67.   8D 67?(% ?(  8?(D 
r/   