Ë
    ÛÓ^j{I  ã                   ó€  — d Z ddlmZ ddlmZ ddl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 ed¬«      e G d„ de«      «       «       Z ed¬«      e G d„ de«      «       «       Zg d¢Zy)zFLAVA model configurationsé    )ÚAny)Ústricté   )ÚPreTrainedConfig)Úauto_docstringÚloggingzfacebook/flava-full)Ú
checkpointc                   ó0  — 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z  ed<   dZeez  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d<   dZeed<   y) ÚFlavaImageConfigaT  
    mask_token (`bool`, *optional*, defaults to `True`):
        Whether to use a mask token or not. Used in MIM (Masked Image Modeling) loss for FLAVA.

    Example:

    ```python
    >>> from transformers import FlavaImageConfig, FlavaImageModel

    >>> # Initializing a FlavaImageModel with  style configuration
    >>> configuration = FlavaImageConfig()

    >>> # Initializing a FlavaImageModel model (with random weights) from the style configuration
    >>> model = FlavaImageModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úflava_image_modelÚimage_configé   Úhidden_sizeé   Únum_hidden_layersÚnum_attention_headsé   Úintermediate_sizeÚgeluÚ
hidden_actç        Úhidden_dropout_probÚattention_probs_dropout_probç{®Gáz”?Úinitializer_rangeçê-�™—q=Úlayer_norm_epséà   Ú
image_sizeé   Ú
patch_sizer   Únum_channelsTÚqkv_biasÚ
mask_tokené    Ú
vocab_sizeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
model_typeÚbase_config_keyr   ÚintÚ__annotations__r   r   r   r   Ústrr   Úfloatr   r   r   r   ÚlistÚtupler!   r"   r#   Úboolr$   r&   © ó    úx/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/flava/configuration_flava.pyr   r      sá   … ñð& %€JØ$€Oà€K�ÓØÐ�sÓØ!Ð˜Ó!Ø!Ð�sÓ!Ø€J�ÓØ'*Ð˜ ™Ó*Ø03Ð  %¨#¡+Ó3Ø#Ð�uÓ#Ø!€N�EÓ!Ø47€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó7Ø46€J��d˜3‘i‘ %¨¨S¨¡/Ñ1Ó6Ø€L�#ÓØ€HˆdÓØ€J�ÓØ€J�Ôr5   r   c                   óð   — 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d<   dZeed<   dZeed<   dZeez  ed<   dZeez  ed<   dZeed<   dZeed<   dZedz  ed<   dZeed<   y)ÚFlavaTextConfiga´  
    Example:

    ```python
    >>> from transformers import FlavaTextConfig, FlavaTextModel

    >>> # Initializing a FlavaTextModel with  style configuration
    >>> configuration = FlavaTextConfig()

    >>> # Initializing a FlavaTextModel model (with random weights) from the style configuration
    >>> model = FlavaTextModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úflava_text_modelÚtext_configi:w  r&   é   Útype_vocab_sizei   Úmax_position_embeddingsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   NÚpad_token_idTr#   )r'   r(   r)   r*   r+   r,   r&   r-   r.   r<   r=   r   r   r   r   r   r/   r   r0   r   r   r   r>   r#   r3   r4   r5   r6   r8   r8   E   s²   … ñð  $€JØ#€Oà€J�ÓØ€O�SÓØ#&Ð˜SÓ&Ø€K�ÓØÐ�sÓØ!Ð˜Ó!Ø!Ð�sÓ!Ø€J�ÓØ'*Ð˜ ™Ó*Ø03Ð  %¨#¡+Ó3Ø#Ð�uÓ#Ø!€N�EÓ!Ø €L�#˜‘*Ó Ø€HˆdÔr5   r8   c                   óÀ   — 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z  ed<   dZeez  ed<   dZeed<   dZeed<   dZeed<   dZeed<   y)ÚFlavaMultimodalConfiga{  
    use_cls_token (`bool`, *optional*, defaults to `True`):
        Whether to use an extra CLS token for multimodal settings. Usually needed by the FLAVA model.

    Example:

    ```python
    >>> from transformers import FlavaMultimodalConfig, FlavaMultimodalModel

    >>> # Initializing a FlavaMultimodalModel with  style configuration
    >>> configuration = FlavaMultimodalConfig()

    >>> # Initializing a FlavaMultimodalModel model (with random weights) from the style configuration
    >>> model = FlavaMultimodalModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```Úflava_multimodal_modelÚmultimodal_configr   r   é   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Tr#   Úuse_cls_tokenN)r'   r(   r)   r*   r+   r,   r   r-   r.   r   r   r   r   r/   r   r0   r   r   r   r#   r3   rD   r4   r5   r6   r@   r@   k   s�   … ñð& *€JØ)€Oà€K�ÓØÐ�sÓØ!Ð˜Ó!Ø!Ð�sÓ!Ø€J�ÓØ'*Ð˜ ™Ó*Ø03Ð  %¨#¡+Ó3Ø#Ð�uÓ#Ø!€N�EÓ!Ø€HˆdÓØ€M�4Ôr5   r@   c                   ót   — e Zd ZU 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<   y)ÚFlavaImageCodebookConfigas  
    num_groups (`int`, *optional*, defaults to 4):
        Number of groups to be created. This parameter as of now doesn't affect the model and is used for some
        internal calculation and estimations.
    num_blocks_per_group (`int`, *optional*, defaults to 2):
        Number of conv-based blocks per group.
    freeze (`bool`, defaults to `True`):
        Whether to freeze the weights of the model.

    Example:

    ```python
    >>> from transformers import FlavaImageCodebookConfig, FlavaImageCodebook

    >>> # Initializing a FlavaImageCodebook with style configuration
    >>> configuration = FlavaImageCodebookConfig()

    >>> # Initializing a FlavaImageCodebook model (with random weights) from the style configuration
    >>> model = FlavaImageCodebook(configuration)
    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```
    é   Ú
num_groupsr   Úinput_channelsr;   Únum_blocks_per_groupé   r   r%   r&   TÚfreezer   r   N)r'   r(   r)   r*   rH   r-   r.   rI   rJ   r   r&   rL   r3   r   r0   r4   r5   r6   rF   rF   ‘   sQ   … ñð0 €J�ÓØ€N�CÓØ !Ð˜#Ó!Ø€K�ÓØ€J�ÓØ€FˆDÓØ#Ð�uÔ#r5   rF   c                   óÂ  ‡ — e Zd ZU dZdZeeeedœZ	dZ
eeef   ez  dz  ed<   dZeeef   ez  dz  ed<   dZeeef   ez  dz  ed<   dZeeef   ez  dz  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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d<   dZ&eed <   dZ'eed!<   ˆ fd"„Z(ˆ xZ)S )#ÚFlavaConfiga 
  
    image_config (`dict`, *optional*):
        Dictionary of configuration options used to initialize [`FlavaImageConfig`].
    multimodal_config (`dict`, *optional*):
        Dictionary of configuration options used to initialize [`FlavaMultimodalConfig`].
    image_codebook_config (`dict`, *optional*):
        Dictionary of configuration options used to initialize [`FlavaCodebookConfig`].
    init_codebook (`bool`, *optional*, defaults to `True`):
        Whether to initialize the codebook
    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 FLAVA/CLIP
        implementation.
    ce_ignore_index (`int`, *optional*, defaults to -100):
        Cross entropy index to ignore.
    mim_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to MIM (Masked Image Modeling) unimodal loss
    mlm_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to MLM (Masked Language Modeling) unimodal loss
    global_contrastive_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to global contrastive cross-alignment loss.
    itm_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to image-text matching multimodal loss.
    mmm_image_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to MMM loss's image part.
    mmm_text_weight (`float`, *optional*, defaults to 1.0):
        Weight to be assigned to MMM loss's text part.
    global_backprop_contrastive (`bool`, *optional*, defaults to `True`):
        Whether to use global backpropgation through all workers in contrastive loss.
    skip_unmasked_multimodal_encoder (`bool`, *optional*, defaults to `True`):
        Whether to skip running unmasked multimodal encoder whose outputs are not used by FLAVA losses.
    return_loss (`bool`, *optional*, defaults to `True`):
        Whether to return loss or not

    Example:

    ```python
    >>> from transformers import FlavaConfig, FlavaModel, FlavaForPreTraining

    >>> # Initializing a FlavaConfig with style configuration
    >>> configuration = FlavaConfig()

    >>> # Initializing a FlavaModel and FlavaForPreTraining model (with random weights) from the style configuration
    >>> model = FlavaModel(configuration)
    >>> model_pre = FlavaForPreTraining(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    >>> configuration_pre = model_pre.config
    ```
    Úflava)r:   r   rB   Úimage_codebook_configNr   r:   rB   rP   r   r   r   r   Úprojection_dimTÚinit_codebookgƒ/L¦
F@Úlogit_scale_init_valuer   r   iœÿÿÿÚce_ignore_indexg      ð?Ú
mim_weightÚ
mlm_weightÚglobal_contrastive_weightÚ
itm_weightÚmmm_image_weightÚmmm_text_weightÚglobal_backprop_contrastiveÚ skip_unmasked_multimodal_encoderÚreturn_lossÚtie_word_embeddingsÚinitializer_factorc                 óÞ  •— | j                   €i }t        j                  d«       nAt        | j                   t        «      r| j                   j                  «       }n| j                   }| j                  €i }t        j                  d«       nAt        | j                  t        «      r| j                  j                  «       }n| j                  }| j                  €i }t        j                  d«       nAt        | j                  t        «      r| j                  j                  «       }n| j                  }| j                  €i }t        j                  d«       nAt        | j                  t        «      r| j                  j                  «       }n| j                  }|j                  dd «      }|j                  dd «      }|j                  dd «      }|j                  dd «      }	|�t	        di |¤Žj                  «       }
|
j                  «       D ]B  \  }}||v sŒ|||   k7  sŒ|d	k7  sŒ||v r
d
|› d|› d�}nd|› d�}t        j                  |«       ŒD |j                  |
«       |�¶t        di |¤Žj                  «       }d|v r3|d   j                  «       D ��ci c]  \  }}t        |«      |“Œ c}}|d<   |j                  «       D ]B  \  }}||v sŒ|||   k7  sŒ|d	k7  sŒ||v r
d
|› d|› d�}nd|› d�}t        j                  |«       ŒD |j                  |«       |�t        di |¤Žj                  «       }|j                  «       D ]B  \  }}||v sŒ|||   k7  sŒ|d	k7  sŒ||v r
d
|› d|› d�}nd|› d�}t        j                  |«       ŒD |j                  |«       |	�t        di |	¤Žj                  «       }|j                  «       D ]B  \  }}||v sŒ|||   k7  sŒ|d	k7  sŒ||	v r
d
|› d|› d�}nd|› d�}t        j                  |«       ŒD |j                  |«       t	        di |¤Ž| _         t        di |¤Ž| _        t        di |¤Ž| _        t        di |¤Ž| _
        t!        ‰| �D  di |¤Ž y c c}}w )NzP`text_config` is `None`. Initializing the `FlavaTextConfig` with default values.zR`image_config` is `None`. initializing the `FlavaImageConfig` with default values.z\`multimodal_config` is `None`. Initializing the `FlavaMultimodalConfig` with default values.zc`image_codebook_config` is `None`. initializing the `FlavaImageCodebookConfig` with default values.Útext_config_dictÚimage_config_dictÚmultimodal_config_dictÚimage_codebook_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.zk`text_config_dict` is provided which will be used to initialize `FlavaTextConfig`. The value `text_config["z"]` will be overridden.Úid2labelzs` is found in both `image_config_dict` and `image_config` but with different values. The value `image_config_dict["zn`image_config_dict` is provided which will be used to initialize `FlavaImageConfig`. The value `image_config["z‚` is found in both `multimodal_config_dict` and `multimodal_config` but with different values. The value `multimodal_config_dict["z}`multimodal_config_dict` is provided which will be used to initialize `FlavaMultimodalConfig`. The value `multimodal_config["zŽ` is found in both `image_codebook_config_dict` and `image_codebook_config` but with different values. The value `image_codebook_config_dict["zˆ`image_codebook_config_dict` is provided which will be used to initialize `FlavaImageCodebookConfig`. The value `image_codebook_config["r4   )r:   ÚloggerÚinfoÚ
isinstancer8   Úto_dictr   r   rB   r@   rP   rF   ÚpopÚitemsÚupdater/   ÚsuperÚ__post_init__)ÚselfÚkwargsr:   r   rB   rP   ra   rb   rc   rd   Ú_text_config_dictÚkeyÚvalueÚmessageÚ_image_config_dictÚ_multimodal_config_dictÚ_image_codebook_config_dictÚ	__class__s                    €r6   rp   zFlavaConfig.__post_init__
  s  ø€ Ø×ÑÐ#ØˆKÜ�K‰KÐjÕkÜ˜×(Ñ(¬/Ô:Ø×*Ñ*×2Ñ2Ó4‰Kà×*Ñ*ˆKà×ÑÐ$ØˆLÜ�K‰KÐlÕmÜ˜×)Ñ)Ô+;Ô<Ø×,Ñ,×4Ñ4Ó6‰Là×,Ñ,ˆLà×!Ñ!Ð)Ø "ÐÜ�K‰KÐvÕwÜ˜×.Ñ.Ô0EÔFØ $× 6Ñ 6× >Ñ >Ó @Ñà $× 6Ñ 6Ðà×%Ñ%Ð-Ø$&Ð!Ü�K‰KØuõô ˜×2Ñ2Ô4LÔMØ$(×$>Ñ$>×$FÑ$FÓ$HÑ!à$(×$>Ñ$>Ð!ð "Ÿ:™:Ð&8¸$Ó?ÐØ"ŸJ™JÐ':¸DÓAÐØ!'§¡Ð,DÀdÓ!KÐØ%+§Z¡ZÐ0LÈdÓ%SÐ"ð
 Ð'ä /Ñ CÐ2BÑ C× KÑ KÓ MÐð 0×5Ñ5Ó7ò )‘
��UØ˜+Ò%¨%°;¸sÑ3CÓ*CÈÐOeÓHeàÐ.Ñ.à ˜uð %<Ø<?¸5Ð@Yð[ñ  ð3Ø36°%Ð7NðPð  ô —K‘K Õ(ð)ð" ×ÑÐ0Ô1àÐ(ä!1Ñ!FÐ4EÑ!F×!NÑ!NÓ!PÐàÐ/Ñ/à6HÈÑ6T×6ZÑ6ZÓ6\÷2Ù(2¨¨U”C˜“H˜e‘Oó2Ð" :Ñ.ð
 1×6Ñ6Ó8ò )‘
��UØ˜,Ò&¨5°LÀÑ4EÓ+EÈ#ÐQgÓJgàÐ/Ñ/à ˜uð %EØEHÀEÐIbðdñ  ð8Ø8;°uÐ<SðUð  ô —K‘K Õ(ð)ð" ×ÑÐ 2Ô3à!Ð-ä&;Ñ&UÐ>TÑ&U×&]Ñ&]Ó&_Ð#ð 6×;Ñ;Ó=ò )‘
��UØÐ+Ò+°Ð9JÈ3Ñ9OÓ0OÐTWÐ[qÓTqàÐ4Ñ4à ˜uð %TØTWÐSXÐXqðsñ  ðVØVYÐUZÐZqðsð  ô —K‘K Õ(ð)ð" ×$Ñ$Ð%<Ô=à%Ð1ä*BÑ*`ÐE_Ñ*`×*hÑ*hÓ*jÐ'ð :×?Ñ?ÓAò )‘
��UàÐ0Ò0ØÐ!6°sÑ!;Ó;ØÐ5Ó5ð Ð8Ñ8à ˜uð %]Ø]`Ð\að b'ð'ñ  ð]Ø]`Ð\aÐaxðzð  ô —K‘K Õ(ð')ð, "×(Ñ(Ð)DÔEô +Ñ9¨[Ñ9ˆÔÜ,Ñ<¨|Ñ<ˆÔÜ!6Ñ!KÐ9JÑ!KˆÔÜ%=Ñ%VÐ@UÑ%VˆÔ"ä‰ÑÑ' Ó'ùók2s   ÊQ))*r'   r(   r)   r*   r+   r8   r   r@   rF   Úsub_configsr   Údictr/   r   r   r.   r:   rB   rP   r   r-   r   r0   rQ   rR   r3   rS   r   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   rp   Ú__classcell__)rz   s   @r6   rN   rN   µ   sd  ø… ñ1ðf €Jà&Ø(Ø2Ø!9ñ	€Kð >B€L�$�s˜C�x‘.Ð#3Ñ3°dÑ:ÓAØ<@€K��c˜3�h‘Ð"2Ñ2°TÑ9Ó@ØBFÐ�t˜C ˜H‘~Ð(8Ñ8¸4Ñ?ÓFØFJÐ˜4  S ™>Ð,<Ñ<¸tÑCÓJØ€K�ÓØ!€N�EÓ!Ø€N�CÓØ€M�4ÓØ$*Ð˜EÓ*Ø#Ð�uÓ#Ø€O�SÓØ€J�ÓØ€J�ÓØ'*Ð˜uÓ*Ø€J�ÓØ!Ð�eÓ!Ø €O�UÓ Ø(,Ð Ó,Ø-1Ð$ dÓ1Ø€K�ÓØ $Ð˜Ó$Ø #Ð˜Ó#÷^(ð ^(r5   rN   )rN   rF   r   r@   r8   N)r*   Útypingr   Úhuggingface_hub.dataclassesr   Úconfiguration_utilsr   Úutilsr   r   Ú
get_loggerr'   rh   r   r8   r@   rF   rN   Ú__all__r4   r5   r6   ú<module>r„      s  ðñ !å å .å 3ß ,ð 
ˆ×	Ñ	˜HÓ	%€ñ Ð0Ô1Øô%Ð'ó %ó ó 2ð%ñP Ð0Ô1Øô!Ð&ó !ó ó 2ð!ñH Ð0Ô1Øô!Ð,ó !ó ó 2ð!ñH Ð0Ô1Øô$Ð/ó $ó ó 2ð$ñD Ð0Ô1Øôq(Ð"ó q(ó ó 2ðq(òh v�r5   