Ë
    S^(h$J  ã                   óŽ   — 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
g d
¢Zy)zAltCLIP model configurationé   )ÚPretrainedConfig)Úloggingc                   óN   ‡ — e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚAltCLIPTextConfiga�  
    This is the configuration class to store the configuration of a [`AltCLIPTextModel`]. It is used to instantiate a
    AltCLIP text 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 AltCLIP
    [BAAI/AltCLIP](https://huggingface.co/BAAI/AltCLIP) 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 250002):
            Vocabulary size of the AltCLIP model. Defines the number of different tokens that can be represented by the
            `inputs_ids` passed when calling [`AltCLIPTextModel`].
        hidden_size (`int`, *optional*, defaults to 1024):
            Dimensionality of the encoder layers and the pooler layer.
        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.
        intermediate_size (`int`, *optional*, defaults to 4096):
            Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
        hidden_act (`str` or `Callable`, *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.
        hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
        attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
            The dropout ratio for the attention probabilities.
        max_position_embeddings (`int`, *optional*, defaults to 514):
            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).
        type_vocab_size (`int`, *optional*, defaults to 1):
            The vocabulary size of the `token_type_ids` passed when calling [`AltCLIPTextModel`]
        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 0.02):
            A factor for initializing all weight matrices (should be kept to 1, used internally for initialization
            testing).
        layer_norm_eps (`float`, *optional*, defaults to 1e-05):
            The epsilon used by the layer normalization layers.
        pad_token_id (`int`, *optional*, defaults to 1): The id of the *padding* token.
        bos_token_id (`int`, *optional*, defaults to 0): The id of the *beginning-of-sequence* token.
        eos_token_id (`Union[int, List[int]]`, *optional*, defaults to 2):
            The id of the *end-of-sequence* token. Optionally, use a list to set multiple *end-of-sequence* tokens.
        position_embedding_type (`str`, *optional*, defaults to `"absolute"`):
            Type of position embedding. Choose one of `"absolute"`, `"relative_key"`, `"relative_key_query"`. For
            positional embeddings use `"absolute"`. For more information on `"relative_key"`, please refer to
            [Self-Attention with Relative Position Representations (Shaw et al.)](https://arxiv.org/abs/1803.02155).
            For more information on `"relative_key_query"`, please refer to *Method 4* in [Improve Transformer Models
            with Better Relative Position Embeddings (Huang et al.)](https://arxiv.org/abs/2009.13658).
        use_cache (`bool`, *optional*, defaults to `True`):
            Whether or not the model should return the last key/values attentions (not used by all models). Only
            relevant if `config.is_decoder=True`.
        project_dim (`int`, *optional*, defaults to 768):
            The dimensions of the teacher model before the mapping layer.

    Examples:

    ```python
    >>> from transformers import AltCLIPTextModel, AltCLIPTextConfig

    >>> # Initializing a AltCLIPTextConfig with BAAI/AltCLIP style configuration
    >>> configuration = AltCLIPTextConfig()

    >>> # Initializing a AltCLIPTextModel (with random weights) from the BAAI/AltCLIP style configuration
    >>> model = AltCLIPTextModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úaltclip_text_modelc                 ó  •— t        ‰| �  d|||dœ|¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        |	| _
        |
| _        || _        || _        || _        || _        || _        || _        y )N)Úpad_token_idÚbos_token_idÚeos_token_id© )ÚsuperÚ__init__Ú
vocab_sizeÚhidden_sizeÚnum_hidden_layersÚnum_attention_headsÚ
hidden_actÚintermediate_sizeÚhidden_dropout_probÚattention_probs_dropout_probÚmax_position_embeddingsÚtype_vocab_sizeÚinitializer_rangeÚinitializer_factorÚlayer_norm_epsÚposition_embedding_typeÚ	use_cacheÚproject_dim)Úselfr   r   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/altclip/configuration_altclip.pyr   zAltCLIPTextConfig.__init__c   s�   ø€ ô. 	‰ÑÐs lÀÐ\hÑsÐlrÒsà$ˆŒØ&ˆÔØ!2ˆÔØ#6ˆÔ Ø$ˆŒØ!2ˆÔØ#6ˆÔ Ø,HˆÔ)Ø'>ˆÔ$Ø.ˆÔØ!2ˆÔØ"4ˆÔØ,ˆÔØ'>ˆÔ$Ø"ˆŒØ&ˆÕó    )i’Ð i   é   é   i   Úgeluçš™™™™™¹?r'   i  é   ç{®Gáz”?r)   çñhãˆµøä>r(   é    é   ÚabsoluteTé   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typer   Ú__classcell__©r!   s   @r"   r   r      sV   ø„ ñFðP &€Jð ØØØØØØØ%(Ø #ØØØØØØØØ *ØØ÷)('ñ ('r#   r   c                   óF   ‡ — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚAltCLIPVisionConfiga®  
    This is the configuration class to store the configuration of a [`AltCLIPModel`]. It is used to instantiate an
    AltCLIP 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 AltCLIP
    [BAAI/AltCLIP](https://huggingface.co/BAAI/AltCLIP) 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 768):
            Dimensionality of the encoder layers and the pooler layer.
        intermediate_size (`int`, *optional*, defaults to 3072):
            Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
        projection_dim (`int`, *optional*, defaults to 512):
            Dimensionality of text and vision projection layers.
        num_hidden_layers (`int`, *optional*, defaults to 12):
            Number of hidden layers in the Transformer encoder.
        num_attention_heads (`int`, *optional*, defaults to 12):
            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 32):
            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).

    Example:

    ```python
    >>> from transformers import AltCLIPVisionConfig, AltCLIPVisionModel

    >>> # Initializing a AltCLIPVisionConfig with BAAI/AltCLIP style configuration
    >>> configuration = AltCLIPVisionConfig()

    >>> # Initializing a AltCLIPVisionModel (with random weights) from the BAAI/AltCLIP style configuration
    >>> model = AltCLIPVisionModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úaltclip_vision_modelÚvision_configc                 óÚ   •— t        ‰| �  di |¤Ž || _        || _        || _        || _        || _        || _        || _        || _	        || _
        || _        || _        |
| _        |	| _        y )Nr   )r   r   r   r   Úprojection_dimr   r   Únum_channelsÚ
patch_sizeÚ
image_sizer   r   Úattention_dropoutr   r   )r   r   r   r;   r   r   r<   r>   r=   r   r   r?   r   r   r    r!   s                  €r"   r   zAltCLIPVisionConfig.__init__É   sz   ø€ ô" 	‰ÑÑ"˜6Ò"à&ˆÔØ!2ˆÔØ,ˆÔØ!2ˆÔØ#6ˆÔ Ø(ˆÔØ$ˆŒØ$ˆŒØ!2ˆÔØ"4ˆÔØ!2ˆÔØ,ˆÔØ$ˆ�r#   )r.   i   i   é   r@   r   éà   é    Ú
quick_gelur*   g        r)   ç      ð?)r/   r0   r1   r2   r3   Úbase_config_keyr   r4   r5   s   @r"   r7   r7   Ž   sH   ø„ ñ5ðn (€JØ%€Oð ØØØØØØØØØØØØ÷%ñ %r#   r7   c                   óN   ‡ — e Zd ZdZdZeedœZ	 dˆ fd„	Ze	dedefd„«       Z
ˆ xZS )	ÚAltCLIPConfigaë  
    This is the configuration class to store the configuration of a [`AltCLIPModel`]. It is used to instantiate an
    AltCLIP 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 AltCLIP
    [BAAI/AltCLIP](https://huggingface.co/BAAI/AltCLIP) architecture.

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

    Args:
        text_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`AltCLIPTextConfig`].
        vision_config (`dict`, *optional*):
            Dictionary of configuration options used to initialize [`AltCLIPVisionConfig`].
        projection_dim (`int`, *optional*, defaults to 768):
            Dimensionality of text and vision projection layers.
        logit_scale_init_value (`float`, *optional*, defaults to 2.6592):
            The initial value of the *logit_scale* parameter. Default is used as per the original CLIP implementation.
        kwargs (*optional*):
            Dictionary of keyword arguments.

    Example:

    ```python
    >>> from transformers import AltCLIPConfig, AltCLIPModel

    >>> # Initializing a AltCLIPConfig with BAAI/AltCLIP style configuration
    >>> configuration = AltCLIPConfig()

    >>> # Initializing a AltCLIPModel (with random weights) from the BAAI/AltCLIP style configuration
    >>> model = AltCLIPModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config

    >>> # We can also initialize a AltCLIPConfig from a AltCLIPTextConfig and a AltCLIPVisionConfig

    >>> # Initializing a AltCLIPText and AltCLIPVision configuration
    >>> config_text = AltCLIPTextConfig()
    >>> config_vision = AltCLIPVisionConfig()

    >>> config = AltCLIPConfig.from_text_vision_configs(config_text, config_vision)
    ```Úaltclip©Útext_configr9   c                 óÄ  •— |j                  dd «      }|j                  dd «      }t        ‰| �  di |¤Ž |�‚|€i }t        di |¤Žj	                  «       }|j                  «       D ]A  \  }	}
|	|v sŒ|
||	   k7  sŒ|	dvsŒ|	|v r
d|	› d|	› d�}nd|	› d�}t        j                  |«       ŒC |j                  |«       |�¹|€i }t        di |¤Žj	                  «       }d	|v r3|d	   j                  «       D �	�
ci c]  \  }	}
t        |	«      |
“Œ c}
}	|d	<   |j                  «       D ]A  \  }	}
|	|v sŒ|
||	   k7  sŒ|	dvsŒ|	|v r
d|	› d
|	› d�}nd|	› d�}t        j                  |«       ŒC |j                  |«       |€i }t        j                  d«       |€i }t        j                  d«       t        di |¤Ž| _        t        di |¤Ž| _        || _        || _        d| _        y c c}
}	w )NÚtext_config_dictÚvision_config_dict)Útransformers_versionú`zp` is found in both `text_config_dict` and `text_config` but with different values. The value `text_config_dict["z"]` will be used instead.zm`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The value `text_config["z"]` will be overridden.Úid2labelzv` is found in both `vision_config_dict` and `vision_config` but with different values. The value `vision_config_dict["zs`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. The value `vision_config["zR`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values.zV`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values.rD   r   )Úpopr   r   r   Úto_dictÚitemsÚloggerÚinfoÚupdater7   ÚstrrJ   r9   r;   Úlogit_scale_init_valuer   )r   rJ   r9   r;   rX   r    rL   rM   Ú_text_config_dictÚkeyÚvalueÚmessageÚ_vision_config_dictr!   s                €r"   r   zAltCLIPConfig.__init__  sp  ø€ ð "Ÿ:™:Ð&8¸$Ó?ÐØ#ŸZ™ZÐ(<¸dÓCÐä‰ÑÑ"˜6Ò"ð
 Ð'ØÐ"Ø �ô !2Ñ EÐ4DÑ E× MÑ MÓ OÐð 0×5Ñ5Ó7ò )‘
��UØ˜+Ò%¨%°;¸sÑ3CÓ*CÈÐSkÒHkàÐ.Ñ.à ˜uð %<Ø<?¸5Ð@Yð[ñ  ð3Ø36°%Ð7NðPð  ô —K‘K Õ(ð)ð" ×ÑÐ0Ô1àÐ)ØÐ$Ø "�ô #6Ñ"KÐ8JÑ"K×"SÑ"SÓ"UÐàÐ0Ñ0à6IÈ*Ñ6U×6[Ñ6[Ó6]÷3Ù(2¨¨U”C˜“H˜e‘Oó3Ð# JÑ/ð
 2×7Ñ7Ó9ò )‘
��UØ˜-Ò'¨E°]À3Ñ5GÓ,GÈCÐWoÒLoàÐ0Ñ0à ˜uð %FØFIÀUÐJcðeñ  ð9Ø9<¸Ð=TðVð  ô —K‘K Õ(ð)ð" × Ñ Ð!4Ô5àÐØˆKÜ�K‰KÐlÔmàÐ ØˆMÜ�K‰KÐpÔqä,Ñ;¨{Ñ;ˆÔÜ0ÑA°=ÑAˆÔà,ˆÔØ&<ˆÔ#Ø"%ˆÕùóK3s   Ã2GrJ   r9   c                 óP   —  | d|j                  «       |j                  «       dœ|¤ŽS )zó
        Instantiate a [`AltCLIPConfig`] (or a derived class) from altclip text model configuration and altclip vision
        model configuration.

        Returns:
            [`AltCLIPConfig`]: An instance of a configuration object
        rI   r   )rR   )ÚclsrJ   r9   r    s       r"   Úfrom_text_vision_configsz&AltCLIPConfig.from_text_vision_configss  s,   € ñ Ðf˜{×2Ñ2Ó4ÀM×DYÑDYÓD[ÑfÐ_eÑfÐfr#   )NNr.   gƒ/L¦
F@)r/   r0   r1   r2   r3   r   r7   Úsub_configsr   Úclassmethodr`   r4   r5   s   @r"   rG   rG   ë   sQ   ø„ ñ*ðX €JØ"3ÐFYÑZ€Kð `fõV&ðp ð	gÐ3Dð 	gÐUhò 	gó ô	gr#   rG   )r   r7   rG   N)r2   Úconfiguration_utilsr   Úutilsr   Ú
get_loggerr/   rT   r   r7   rG   Ú__all__r   r#   r"   ú<module>rg      s^   ðñ "å 3Ý ð 
ˆ×	Ñ	˜HÓ	%€ôs'Ð(ô s'ôlZ%Ð*ô Z%ôzRgÐ$ô Rgòj H�r#   