
    fTh2B                         S SK Jr  S SKJr  S SKJr  SSKJrJr  \R                  " \
5      r " S S\5      r " S S	\5      r " S
 S\5      r/ SQrg)   )PretrainedConfig)!MODEL_FOR_CAUSAL_LM_MAPPING_NAMES)logging   )CONFIG_MAPPING
AutoConfigc                   N   ^  \ rS rSrSrSrSr           SU 4S jjrSrU =r	$ )InstructBlipVideoVisionConfig    a
  
This is the configuration class to store the configuration of a [`InstructBlipVideoVisionModel`]. It is used to
instantiate a InstructBlipVideo vision encoder according to the specified arguments, defining the model architecture.
Instantiating a configuration defaults will yield a similar configuration to that of the InstructBlipVideo
[Salesforce/instruct-blip-flan-t5](https://huggingface.co/Salesforce/instruct-blip-flan-t5) 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 1408):
        Dimensionality of the encoder layers and the pooler layer.
    intermediate_size (`int`, *optional*, defaults to 6144):
        Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
    num_hidden_layers (`int`, *optional*, defaults to 39):
        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.
    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 `"gelu"`):
        The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
        `"relu"`, `"selu"` and `"gelu_new"` `"gelu"` are supported. to 1e-5): The epsilon used by the layer
        normalization layers.
    layer_norm_eps (`float`, *optional*, defaults to 1e-06):
        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 1e-10):
        The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
    qkv_bias (`bool`, *optional*, defaults to `True`):
        Whether to add a bias to the queries and values in the self-attention layers.

Example:

```python
>>> from transformers import InstructBlipVideoVisionConfig, InstructBlipVideoVisionModel

>>> # Initializing a InstructBlipVideoVisionConfig with Salesforce/instruct-blip-flan-t5 style configuration
>>> configuration = InstructBlipVideoVisionConfig()

>>> # Initializing a InstructBlipVideoVisionModel (with random weights) from the Salesforce/instruct-blip-flan-t5 style configuration
>>> model = InstructBlipVideoVisionModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```instructblipvideo_vision_modelvision_configc                    > [         TU ]  " S0 UD6  Xl        X l        X0l        X@l        X`l        XPl        Xl        Xl	        Xl
        Xpl        Xl        g )N )super__init__hidden_sizeintermediate_sizenum_hidden_layersnum_attention_heads
patch_size
image_sizeinitializer_rangeattention_dropoutlayer_norm_eps
hidden_actqkv_bias)selfr   r   r   r   r   r   r   r   r   r   r   kwargs	__class__s                }/var/www/auris/envauris/lib/python3.13/site-packages/transformers/models/instructblipvideo/configuration_instructblipvideo.pyr   &InstructBlipVideoVisionConfig.__init__V   sS     	"6"&!2!2#6 $$!2!2,$     )r   r   r   r   r   r   r   r   r   r   r   )  i   '            gelugư>g        g|=T
__name__
__module____qualname____firstlineno____doc__
model_typebase_config_keyr   __static_attributes____classcell__r   s   @r    r
   r
       sB    0d 2J%O ! !r"   r
   c                   V   ^  \ rS rSrSrSrSr               SU 4S jjrSrU =r	$ )InstructBlipVideoQFormerConfigt   a
  
This is the configuration class to store the configuration of a [`InstructBlipVideoQFormerModel`]. It is used to
instantiate a InstructBlipVideo Querying Transformer (Q-Former) 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 InstructBlipVideo [Salesforce/instruct-blip-flan-t5](https://huggingface.co/Salesforce/instruct-blip-flan-t5)
architecture. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs.
Read the documentation from [`PretrainedConfig`] for more information.

Note that [`InstructBlipVideoQFormerModel`] is very similar to [`BertLMHeadModel`] with interleaved cross-attention.

Args:
    vocab_size (`int`, *optional*, defaults to 30522):
        Vocabulary size of the Q-Former model. Defines the number of different tokens that can be represented by
        the `inputs_ids` passed when calling the model.
    hidden_size (`int`, *optional*, defaults to 768):
        Dimensionality of the encoder layers and the pooler layer.
    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.
    intermediate_size (`int`, *optional*, defaults to 3072):
        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 512):
        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).
    initializer_range (`float`, *optional*, defaults to 0.02):
        The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
    layer_norm_eps (`float`, *optional*, defaults to 1e-12):
        The epsilon used by the layer normalization layers.
    pad_token_id (`int`, *optional*, defaults to 0):
        Token id used for padding sequences.
    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).
    cross_attention_frequency (`int`, *optional*, defaults to 2):
        The frequency of adding cross-attention to the Transformer layers.
    encoder_hidden_size (`int`, *optional*, defaults to 1408):
        The hidden size of the hidden states for cross-attention.

Examples:

```python
>>> from transformers import InstructBlipVideoQFormerConfig, InstructBlipVideoQFormerModel

>>> # Initializing a InstructBlipVideo Salesforce/instruct-blip-flan-t5 style configuration
>>> configuration = InstructBlipVideoQFormerConfig()

>>> # Initializing a model (with random weights) from the Salesforce/instruct-blip-flan-t5 style configuration
>>> model = InstructBlipVideoQFormerModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
```instructblipvideo_qformerqformer_configc                    > [         TU ]  " SSU0UD6  Xl        X l        X0l        X@l        X`l        XPl        Xpl        Xl	        Xl
        Xl        Xl        Xl        Xl        Xl        g )Npad_token_idr   )r   r   
vocab_sizer   r   r   r   r   hidden_dropout_probattention_probs_dropout_probmax_position_embeddingsr   r   position_embedding_typecross_attention_frequencyencoder_hidden_size)r   r;   r   r   r   r   r   r<   r=   r>   r   r   r:   r?   r@   rA   r   r   s                    r    r   'InstructBlipVideoQFormerConfig.__init__   sl    & 	=l=f=$&!2#6 $!2#6 ,H)'>$!2,'>$)B&#6 r"   )r=   r@   rA   r   r<   r   r   r   r   r>   r   r   r?   r;   )i:w  i      rC   i   r(   皙?rD   i   {Gz?g-q=    absoluter   r#   r)   r3   s   @r    r5   r5   t   sN    =~ -J&O %( # *"# !"7 "7r"   r5   c                   r   ^  \ rS rSrSrSrSS0r\\\	S.r
     SU 4S jjr\S\	S	\S
\4S j5       rSrU =r$ )InstructBlipVideoConfig   a
  
[`InstructBlipVideoConfig`] is the configuration class to store the configuration of a
[`InstructBlipVideoForConditionalGeneration`]. It is used to instantiate a Instructblipvideo model according to the specified
arguments, defining the vision model, Q-Former model and language model configs. Instantiating a configuration with
the defaults will yield a similar configuration to that of the Instructblipvideo
[Salesforce/instruct-blip-flan-t5](https://huggingface.co/Salesforce/instruct-blip-flan-t5) architecture.

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 (`dict`, *optional*):
        Dictionary of configuration options used to initialize [`InstructBlipVideoVisionConfig`].
    qformer_config (`dict`, *optional*):
        Dictionary of configuration options used to initialize [`InstructBlipVideoQFormerConfig`].
    text_config (`dict`, *optional*):
        Dictionary of configuration options used to initialize any [`PretrainedConfig`].
    num_query_tokens (`int`, *optional*, defaults to 32):
        The number of query tokens passed through the Transformer.

    video_token_index (`int`, *optional*):
        Token index of special video token.
    kwargs (*optional*):
        Dictionary of keyword arguments.

Example:

```python
>>> from transformers import (
...     InstructBlipVideoVisionConfig,
...     InstructBlipVideoQFormerConfig,
...     OPTConfig,
...     InstructBlipVideoConfig,
...     InstructBlipVideoForConditionalGeneration,
... )

>>> # Initializing a InstructBlipVideoConfig with Salesforce/instruct-blip-flan-t5 style configuration
>>> configuration = InstructBlipVideoConfig()

>>> # Initializing a InstructBlipVideoForConditionalGeneration (with random weights) from the Salesforce/instruct-blip-flan-t5 style configuration
>>> model = InstructBlipVideoForConditionalGeneration(configuration)

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

>>> # We can also initialize a InstructBlipVideoConfig from a InstructBlipVideoVisionConfig, InstructBlipVideoQFormerConfig and any PretrainedConfig

>>> # Initializing Instructblipvideo vision, Instructblipvideo Q-Former and language model configurations
>>> vision_config = InstructBlipVideoVisionConfig()
>>> qformer_config = InstructBlipVideoQFormerConfig()
>>> text_config = OPTConfig()

>>> config = InstructBlipVideoConfig.from_text_vision_configs(vision_config, qformer_config, text_config)
```instructblipvideovideo_token_idvideo_token_index)text_configr8   r   c                   > [         TU ]  " S0 UD6  Uc  0 n[        R                  S5        Uc  0 n[        R                  S5        Uc  0 n[        R                  S5        [	        S0 UD6U l        [        S0 UD6U l        SU;   a  US   OSn[        U   " S0 UD6U l	        X@l
        XPl        U R
                  R                  U R                  l        U R                  R                  [        ;   U l        SU l        SU l        g )	NzZvision_config is None. initializing the InstructBlipVideoVisionConfig with default values.z\qformer_config is None. Initializing the InstructBlipVideoQFormerConfig with default values.zTtext_config is None. Initializing the text config with default values (`OPTConfig`).r/   optg      ?rE   r   )r   r   loggerinfor
   r   r5   r8   r   rN   num_query_tokensrM   r   rA   r/   r   use_decoder_only_language_modelinitializer_factorr   )	r   r   r8   rN   rS   rM   r   text_model_typer   s	           r    r    InstructBlipVideoConfig.__init__  s     	"6" MKKtu!NKKvwKKKno:K]K<N~N7C{7R+l3X])/:I[I 0!2262D2D2P2P//3/?/?/J/JNo/o,"%!%r"   r   r8   rN   c                 n    U " SUR                  5       UR                  5       UR                  5       S.UD6$ )z
Instantiate a [`InstructBlipVideoConfig`] (or a derived class) from a InstructBlipVideo vision model, Q-Former and
language model configurations.

Returns:
    [`InstructBlipVideoConfig`]: An instance of a configuration object
)r   r8   rN   r   )to_dict)clsr   r8   rN   r   s        r     from_vision_qformer_text_configs8InstructBlipVideoConfig.from_vision_qformer_text_configsA  sD       
'//1)113#++-
 	
 	
r"   )rU   r   rS   r8   rN   rT   rM   r   )NNNr   N)r*   r+   r,   r-   r.   r/   attribute_mapr   r5   r
   sub_configsr   classmethodr   r[   r1   r2   r3   s   @r    rI   rI      sv    5n %J-M "86K !&F 
4
 7
 &	
 
r"   rI   )rI   r5   r
   N)configuration_utilsr   models.auto.modeling_autor   utilsr   autor   r   
get_loggerr*   rQ   r
   r5   rI   __all__r   r"   r    <module>rf      s]   . 4 J  - 
		H	%Q!$4 Q!he7%5 e7Pz
. z
z ir"   