§
    ‚Štj
Æ  ã                   ó¼  — d Z ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	m
Z dd	lmZ dd
lmZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+  ej,        e-¦  «        Z.dej/        dej/        fd„Z0dej/        dej/        fd„Z1 ed¬¦  «        e G d„ de¦  «        ¦   «         ¦   «         Z2 ed¬¦  «        e G d„ de¦  «        ¦   «         ¦   «         Z3 ed ¬¦  «        e G d!„ d"e¦  «        ¦   «         ¦   «         Z4ee G d#„ d$e¦  «        ¦   «         ¦   «         Z5 G d%„ d&ej6        ¦  «        Z7 G d'„ d(ej6        ¦  «        Z8 G d)„ d*ej6        ¦  «        Z9 G d+„ d,ej6        ¦  «        Z: G d-„ d.e¦  «        Z;e G d/„ d0e¦  «        ¦   «         Z< G d1„ d2ej6        ¦  «        Z= G d3„ d4e<¦  «        Z> ed5¬¦  «         G d6„ d7e<¦  «        ¦   «         Z? ed8¬¦  «         G d9„ d:e<e¦  «        ¦   «         Z@ ed;¬¦  «         G d<„ d=e<e¦  «        ¦   «         ZA ed>¬¦  «         G d?„ d@e<¦  «        ¦   «         ZBg dA¢ZCdS )BzPyTorch BLIP model.é    )Ú	dataclass)ÚAnyN)Únn)Ú	normalizeé   )Úinitialization)ÚACT2FN)ÚGenerationMixin)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚ,BaseModelOutputWithPoolingAndCrossAttentions)ÚPreTrainedModel)ÚUnpack)ÚModelOutputÚTransformersKwargsÚauto_docstringÚcan_return_tupleÚloggingÚ	torch_int)Úmerge_with_config_defaults)Úcapture_outputsé   )Ú
BlipConfigÚBlipTextConfigÚBlipVisionConfig)ÚBlipTextLMHeadModelÚBlipTextModelÚlogitsÚreturnc                 óŽ   — t           j                             | t          j        t          | ¦  «        | j        ¬¦  «        ¦  «        S )N©Údevice)r   Ú
functionalÚcross_entropyÚtorchÚarangeÚlenr#   )r   s    úd/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/blip/modeling_blip.pyÚcontrastive_lossr*   -   s3   € ÝŒ=×&Ò& v­u¬|½CÀ¹K¼KÐPVÔP]Ð/^Ñ/^Ô/^Ñ_Ô_Ð_ó    Ú
similarityc                 óX   — t          | ¦  «        }t          | j        ¦  «        }||z   dz  S )Ng       @)r*   ÚT)r,   Úcaption_lossÚ
image_losss      r)   Úimage_text_contrastive_lossr1   2   s.   € Ý# JÑ/Ô/€LÝ! *¤,Ñ/Ô/€JØ˜:Ñ%¨Ñ,Ð,r+   zÌ
    Adapted from the base class for vision model's outputs that also contains image embeddings of the pooling of the
    last hidden states. This class also adds the loss term from the text decoder.
    )Úcustom_introc                   ó   — e Zd ZU dZdZeej                 dz  ed<   dZ	eej                 dz  ed<   dZ
ej        dz  ed<   dZej        dz  ed<   dZeej        df         dz  ed<   dZeej        df         dz  ed	<   dS )
Ú'BlipForConditionalGenerationModelOutputa+  
    loss (`torch.FloatTensor`, *optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
        Language modeling loss from the text decoder.
    logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`, *optional*):
        Prediction scores of the language modeling head of the text decoder model.
    image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)`, *optional*):
        The image embeddings obtained after applying the Vision Transformer model to the input image.
    NÚlossr   Úimage_embedsÚlast_hidden_state.Úhidden_statesÚ
attentions)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r5   Útupler&   ÚFloatTensorÚ__annotations__r   r6   r7   r8   r9   © r+   r)   r4   r4   8   sÍ   € € € € € € ðð ð -1€Dˆ%�Ô!Ô
" TÑ
)Ð0Ð0Ñ0Ø.2€FˆE�%Ô#Ô$ tÑ+Ð2Ð2Ñ2Ø-1€L�%Ô# dÑ*Ð1Ð1Ñ1Ø26Ð�uÔ(¨4Ñ/Ð6Ð6Ñ6Ø:>€M�5˜Ô*¨CÐ/Ô0°4Ñ7Ð>Ð>Ñ>Ø7;€J��eÔ'¨Ð,Ô-°Ñ4Ð;Ð;Ñ;Ð;Ð;r+   r4   c                   óÊ   — e Zd ZU dZdZej        dz  ed<   dZej        dz  ed<   dZ	ej        dz  ed<   dZ
eej        df         dz  ed<   dZeej        df         dz  ed<   dS )	ÚBlipTextVisionModelOutputaŽ  
    loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
        Language modeling loss from the text decoder.
    image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
        The image embeddings obtained by applying the projection layer to the pooler_output.
    Nr5   r6   r7   .r8   r9   )r:   r;   r<   r=   r5   r&   r?   r@   r6   r7   r8   r>   r9   rA   r+   r)   rC   rC   Q   s«   € € € € € € ðð ð &*€Dˆ%Ô
˜dÑ
"Ð)Ð)Ñ)Ø-1€L�%Ô# dÑ*Ð1Ð1Ñ1Ø26Ð�uÔ(¨4Ñ/Ð6Ð6Ñ6Ø:>€M�5˜Ô*¨CÐ/Ô0°4Ñ7Ð>Ð>Ñ>Ø7;€J��eÔ'¨Ð,Ô-°Ñ4Ð;Ð;Ñ;Ð;Ð;r+   rC   zü
    Adapted from the base class for vision model's outputs that also contains image embeddings of the pooling of the
    last hidden states. This class also adds the loss term from the text decoder as well as the image-text similarity
    scores.
    c                   ó0  — e Zd ZU dZdZej        dz  ed<   dZej        dz  ed<   dZ	ej        dz  ed<   dZ
ej        dz  ed<   dZeej        df         dz  ed<   dZej        dz  ed	<   dZeej        df         dz  ed
<   dZeej                 dz  ed<   dS )Ú BlipImageTextMatchingModelOutputa  
    itm_score (`torch.FloatTensor`):
        The image-text similarity scores.
    loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
        Language modeling loss from the text decoder.
    image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_projection=True`):
        The image embeddings obtained by applying the projection layer to the pooler_output.
    vision_pooler_output (`torch.FloatTensor` of shape `(batch_size, hidden_size)`, *optional*):
        Last layer hidden-state of the vision of the vision-only branch of the model.
    question_embeds (`torch.FloatTensor`):
        The question embeddings obtained by the text projection layer.
    NÚ	itm_scorer5   r6   r7   .r8   Úvision_pooler_outputr9   Úquestion_embeds)r:   r;   r<   r=   rF   r&   r?   r@   r5   r6   r7   r8   r>   rG   r9   rH   rA   r+   r)   rE   rE   g   sù   € € € € € € ðð ð +/€IˆuÔ  4Ñ'Ð.Ð.Ñ.Ø%)€Dˆ%Ô
˜dÑ
"Ð)Ð)Ñ)Ø-1€L�%Ô# dÑ*Ð1Ð1Ñ1Ø26Ð�uÔ(¨4Ñ/Ð6Ð6Ñ6Ø:>€M�5˜Ô*¨CÐ/Ô0°4Ñ7Ð>Ð>Ñ>Ø59Ð˜%Ô+¨dÑ2Ð9Ð9Ñ9Ø7;€J��eÔ'¨Ð,Ô-°Ñ4Ð;Ð;Ñ;Ø7;€O�U˜5Ô,Ô-°Ñ4Ð;Ð;Ñ;Ð;Ð;r+   rE   c                   óÞ   — e Zd ZU dZdZej        dz  ed<   dZej        dz  ed<   dZ	ej        dz  ed<   dZ
ej        dz  ed<   dZej        dz  ed<   dZeed<   dZeed	<   d
ee         fd„ZdS )Ú
BlipOutputa©  
    loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `return_loss` is `True`):
        Contrastive loss for image-text similarity.
    logits_per_image (`torch.FloatTensor` of shape `(image_batch_size, text_batch_size)`):
        The scaled dot product scores between `image_embeds` and `text_embeds`. This represents the image-text
        similarity scores.
    logits_per_text (`torch.FloatTensor` of shape `(text_batch_size, image_batch_size)`):
        The scaled dot product scores between `text_embeds` and `image_embeds`. This represents the text-image
        similarity scores.
    text_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
        The text embeddings obtained by applying the projection layer to the pooled output of [`BlipTextModel`].
    image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim`):
        The image embeddings obtained by applying the projection layer to the pooled output of [`BlipVisionModel`].
    text_model_output (`BaseModelOutputWithPooling`):
        The output of the [`BlipTextModel`].
    vision_model_output (`BaseModelOutputWithPooling`):
        The output of the [`BlipVisionModel`].
    Nr5   Úlogits_per_imageÚlogits_per_textÚtext_embedsr6   Útext_model_outputÚvision_model_outputr    c                 ó^   ‡ — t          ˆ fd„‰                      ¦   «         D ¦   «         ¦  «        S )Nc              3   ót   •K  — | ]2}|d vr‰|         n!t          ‰|¦  «                             ¦   «         V — Œ3dS ))rN   rO   N)ÚgetattrÚto_tuple)Ú.0ÚkÚselfs     €r)   ú	<genexpr>z&BlipOutput.to_tuple.<locals>.<genexpr>¦   sc   øè è € ð 
ð 
àð Ð LÐLÐLˆD�ŒGˆGÕRYÐZ^Ð`aÑRbÔRb×RkÒRkÑRmÔRmð
ð 
ð 
ð 
ð 
ð 
r+   )r>   Úkeys©rV   s   `r)   rS   zBlipOutput.to_tuple¥   sC   ø€ Ýð 
ð 
ð 
ð 
à—Y’Y‘[”[ð
ñ 
ô 
ñ 
ô 
ð 	
r+   )r:   r;   r<   r=   r5   r&   r?   r@   rK   rL   rM   r6   rN   r   rO   r>   r   rS   rA   r+   r)   rJ   rJ   ‡   sÞ   € € € € € € ðð ð& &*€Dˆ%Ô
˜dÑ
"Ð)Ð)Ñ)Ø15Ð�eÔ'¨$Ñ.Ð5Ð5Ñ5Ø04€O�UÔ&¨Ñ-Ð4Ð4Ñ4Ø,0€K�Ô" TÑ)Ð0Ð0Ñ0Ø-1€L�%Ô# dÑ*Ð1Ð1Ñ1Ø48ÐÐ1Ð8Ð8Ñ8Ø6:ÐÐ3Ð:Ð:Ñ:ð
˜% œ*ð 
ð 
ð 
ð 
ð 
ð 
r+   rJ   c                   óz   ‡ — e Zd Zdefˆ fd„Zdej        dededej        fd„Zdd	ej	        d
e
dej        fd„Zˆ xZS )ÚBlipVisionEmbeddingsÚconfigc                 ó  •— t          ¦   «                              ¦   «          || _        |j        | _        |j        | _        |j        | _        t          j        t          j
        dd| j        ¦  «        ¦  «        | _        t          j        d| j        | j        | j        ¬¦  «        | _        | j        | j        z  dz  | _        | j        dz   | _        t          j        t          j
        d| j        | j        ¦  «        ¦  «        | _        d S )Nr   r   )Úin_channelsÚout_channelsÚkernel_sizeÚstrideé   )ÚsuperÚ__init__r\   Úhidden_sizeÚ	embed_dimÚ
image_sizeÚ
patch_sizer   Ú	Parameterr&   ÚrandnÚclass_embeddingÚConv2dÚpatch_embeddingÚnum_patchesÚnum_positionsÚposition_embedding©rV   r\   Ú	__class__s     €r)   rd   zBlipVisionEmbeddings.__init__­   sß   ø€ Ý‰Œ×ÒÑÔÐØˆŒØÔ+ˆŒØ Ô+ˆŒØ Ô+ˆŒå!œ|­E¬K¸¸1¸d¼nÑ,MÔ,MÑNÔNˆÔå!œyØ¨¬ÀDÄOÐ\`Ô\kð 
ñ  
ô  
ˆÔð !œO¨t¬Ñ>À1ÑDˆÔØ!Ô-°Ñ1ˆÔå"$¤,­u¬{¸1¸dÔ>PÐRVÔR`Ñ/aÔ/aÑ"bÔ"bˆÔÐÐr+   Ú
embeddingsÚheightÚwidthr    c                 ó”  — |j         d         dz
  }| j        j         d         dz
  }t          j                             ¦   «         s||k    r||k    r| j        S | j        dd…dd…f         }| j        dd…dd…f         }|j         d         }|| j        z  }	|| j        z  }
t          |dz  ¦  «        }|                     d|||¦  «        }|                     dddd¦  «        }t          j
                             ||	|
fdd	¬
¦  «        }|                     dddd¦  «                             dd|¦  «        }t          j        ||fd¬¦  «        S )a   
        This method allows to interpolate the pre-trained position encodings, to be able to use the model on higher resolution
        images. This method is also adapted to support torch.jit tracing.

        Adapted from:
        - https://github.com/facebookresearch/dino/blob/de9ee3df6cf39fac952ab558447af1fa1365362a/vision_transformer.py#L174-L194, and
        - https://github.com/facebookresearch/dinov2/blob/e1277af2ba9496fbadf7aec6eba56e8d882d1e35/dinov2/models/vision_transformer.py#L179-L211
        r   Néÿÿÿÿg      à?r   r   rb   ÚbicubicF)ÚsizeÚmodeÚalign_corners©Údim)Úshaperp   r&   ÚjitÚ
is_tracingrh   r   ÚreshapeÚpermuter   r$   ÚinterpolateÚviewÚcat)rV   rs   rt   ru   rn   ro   Úclass_pos_embedÚpatch_pos_embedr}   Ú
new_heightÚ	new_widthÚsqrt_num_positionss               r)   Úinterpolate_pos_encodingz-BlipVisionEmbeddings.interpolate_pos_encoding¿   sr  € ð !Ô& qÔ)¨AÑ-ˆØÔ/Ô5°aÔ8¸1Ñ<ˆõ Œy×#Ò#Ñ%Ô%ð 	+¨+¸Ò*FÐ*FÈ6ÐUZÊ?È?ØÔ*Ð*àÔ1°!°!°!°R°a°R°%Ô8ˆØÔ1°!°!°!°Q°R°R°%Ô8ˆàÔ˜rÔ"ˆà˜tœÑ.ˆ
Ø˜Tœ_Ñ,ˆ	å& }°cÑ'9Ñ:Ô:ÐØ)×1Ò1°!Ð5GÐI[Ð]`ÑaÔaˆØ)×1Ò1°!°Q¸¸1Ñ=Ô=ˆåœ-×3Ò3ØØ˜iÐ(ØØð	 4ñ 
ô 
ˆð *×1Ò1°!°Q¸¸1Ñ=Ô=×BÒBÀ1ÀbÈ#ÑNÔNˆåŒy˜/¨?Ð;ÀÐCÑCÔCÐCr+   FÚpixel_valuesr‹   c                 ó(  — |j         \  }}}}| j        j        j        }|                      |                     |¬¦  «        ¦  «        }|                     d¦  «                             dd¦  «        }| j                             |dd¦  «                             |¦  «        }	t          j
        |	|gd¬¦  «        }
|r|                      |
||¦  «        }n| j        }|
|d d …d |
                     d¦  «        …d d …f                              |¦  «        z   }
|
S )N©Údtyperb   r   rw   r|   )r~   rm   Úweightr�   ÚtoÚflattenÚ	transposerk   Úexpandr&   r…   r‹   rp   ry   )rV   rŒ   r‹   Ú
batch_sizeÚ_rt   ru   Útarget_dtypeÚpatch_embedsÚclass_embedsrs   rp   s               r)   ÚforwardzBlipVisionEmbeddings.forwardç   s  € Ø'3Ô'9Ñ$ˆ
�A�v˜uØÔ+Ô2Ô8ˆØ×+Ò+¨L¯OªOÀ,¨OÑ,OÔ,OÑPÔPˆØ#×+Ò+¨AÑ.Ô.×8Ò8¸¸AÑ>Ô>ˆØÔ+×2Ò2°:¸qÀ"ÑEÔE×HÒHÈÑVÔVˆÝ”Y ¨lÐ;ÀÐCÑCÔCˆ
Ø#ð 	9Ø!%×!>Ò!>¸zÈ6ÐSXÑ!YÔ!YÐÐà!%Ô!8ÐØÐ"4°Q°Q°QÐ8L¸*¿/º/È!Ñ:LÔ:LÐ8LÈaÈaÈaÐ5OÔ"P×"SÒ"SÐT`Ñ"aÔ"aÑaˆ
ØÐr+   )F)r:   r;   r<   r   rd   r&   ÚTensorÚintr‹   r?   Úboolrš   Ú__classcell__©rr   s   @r)   r[   r[   ¬   sÂ   ø€ € € € € ðcÐ/ð cð cð cð cð cð cð$&D°5´<ð &DÈð &DÐUXð &DÐ]bÔ]ið &Dð &Dð &Dð &DðPð  EÔ$5ð ÐQUð ÐbgÔbnð ð ð ð ð ð ð ð r+   r[   c            	       ó~   ‡ — e Zd Zdefˆ fd„Z	 	 	 d	dej        dz  dej        dz  dej        dz  dej        fd„Z	ˆ xZ
S )
ÚBlipTextEmbeddingsr\   c                 óV  •— t          ¦   «                              ¦   «          |j        }t          j        |j        |¦  «        | _        t          j        |j        |¦  «        | _        |  	                    dt          j        |j        ¦  «                             d¦  «        d¬¦  «         d S )NÚposition_ids©r   rw   F)Ú
persistent)rc   rd   re   r   Ú	EmbeddingÚ
vocab_sizeÚtoken_embeddingÚmax_position_embeddingsrp   Úregister_bufferr&   r'   r”   ©rV   r\   rf   rr   s      €r)   rd   zBlipTextEmbeddings.__init__ø   sœ   ø€ Ý‰Œ×ÒÑÔÐØÔ&ˆ	å!œ|¨FÔ,=¸yÑIÔIˆÔÝ"$¤,¨vÔ/MÈyÑ"YÔ"YˆÔð 	×ÒØ�EœL¨Ô)GÑHÔH×OÒOÐPWÑXÔXÐejð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r+   NÚ	input_idsr£   Úinputs_embedsr    c                 ó.  — |�|j         d         n|j         d         }| j        j        j         d         }||k    rt          d|› d|› �¦  «        ‚|€| j        d d …d |…f         }|€|                      |¦  «        }|                      |¦  «        }||z   }|S )Nrw   éþÿÿÿr   zRSequence length must be less than max_position_embeddings (got `sequence length`: z and max_position_embeddings: )r~   rp   r�   Ú
ValueErrorr£   r¨   )rV   r¬   r£   r­   Ú
seq_lengthÚmax_position_embeddingÚposition_embeddingsrs   s           r)   rš   zBlipTextEmbeddings.forward  sØ   € ð -6Ð,A�Y”_ RÔ(Ð(À}ÔGZÐ[]ÔG^ˆ
Ø!%Ô!8Ô!?Ô!EÀaÔ!HÐàÐ.Ò.Ð.ÝðVØðVð VØ=SðVð Vñô ð ð
 ÐØÔ,¨Q¨Q¨Q°°°¨^Ô<ˆLàÐ Ø ×0Ò0°Ñ;Ô;ˆMà"×5Ò5°lÑCÔCÐØ"Ð%8Ñ8ˆ
àÐr+   ©NNN)r:   r;   r<   r   rd   r&   Ú
LongTensorr?   r›   rš   rž   rŸ   s   @r)   r¡   r¡   ÷   s¨   ø€ € € € € ð

˜~ð 

ð 

ð 

ð 

ð 

ð 

ð .2Ø04Ø26ð	ð àÔ# dÑ*ðð Ô&¨Ñ-ðð Ô(¨4Ñ/ð	ð
 
Œðð ð ð ð ð ð ð r+   r¡   c                   óŽ   ‡ — e Zd ZdZˆ fd„Zdej        dedefd„Zdej        de	e
         d	eej        ej        f         fd
„Zˆ xZS )ÚBlipAttentionz=Multi-headed attention from 'Attention Is All You Need' paperc                 ó  •— t          ¦   «                              ¦   «          || _        |j        | _        |j        | _        | j        | j        z  | _        | j        | j        z  | j        k    r t          d| j        › d| j        › d�¦  «        ‚| j        dz  | _	        t          j        |j        ¦  «        | _        t          j        | j        d| j        z  ¦  «        | _        t          j        | j        | j        ¦  «        | _        d S )Nz;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).g      à¿r   )rc   rd   r\   re   rf   Únum_attention_headsÚ	num_headsÚhead_dimr°   Úscaler   ÚDropoutÚattention_dropoutÚdropoutÚLinearÚqkvÚ
projectionrq   s     €r)   rd   zBlipAttention.__init__"  sî   ø€ Ý‰Œ×ÒÑÔÐØˆŒØÔ+ˆŒØÔ3ˆŒØœ¨$¬.Ñ8ˆŒØŒ=˜4œ>Ñ)¨T¬^Ò;Ð;Ýð'ÈdÌnð 'ð 'Ø”Nð'ð 'ð 'ñô ð ð ”] DÑ(ˆŒ
Ý”z &Ô":Ñ;Ô;ˆŒå”9˜Tœ^¨Q°´Ñ-?Ñ@Ô@ˆŒåœ) D¤N°D´NÑCÔCˆŒˆˆr+   ÚtensorÚseq_lenÚbszc                 ó’   — |                      ||| j        | j        ¦  «                             dd¦  «                             ¦   «         S )Nr   rb   )r„   rº   r»   r“   Ú
contiguous)rV   rÃ   rÄ   rÅ   s       r)   Ú_shapezBlipAttention._shape4  s<   € Ø�{Š{˜3 ¨¬¸¼ÑGÔG×QÒQÐRSÐUVÑWÔW×bÒbÑdÔdÐdr+   r8   Úkwargsr    c                 óÐ  — |                      ¦   «         \  }}}|                      |¦  «                             ||d| j        || j        z  ¦  «                             ddddd¦  «        }|d         |d         |d         }	}}t          j        ||                     dd¦  «        ¦  «        }
|
| j        z  }
t          j
                             |
d¬¦  «        }|                      |¦  «        }t          j        ||	¦  «                             dddd¦  «        }|                      ¦   «         d	d…         | j        fz   }|                     |¦  «        }|                      |¦  «        }||fS )
z#Input shape: Batch x Time x Channelr   rb   r   r   é   rw   r¯   r|   N)ry   rÁ   r�   rº   r‚   r&   Úmatmulr“   r¼   r   r$   Úsoftmaxr¿   rf   rÂ   )rV   r8   rÉ   rÅ   Útgt_lenrf   Ú	mixed_qkvÚquery_statesÚ
key_statesÚvalue_statesÚattention_scoresÚattention_probsÚcontext_layerÚnew_context_layer_shapeÚoutputs                  r)   rš   zBlipAttention.forward7  s^  € ð #0×"4Ò"4Ñ"6Ô"6ÑˆˆW�ið �HŠH�]Ñ#Ô#ßŠW�S˜' 1 d¤n°iÀ4Ä>Ñ6QÑRÔRßŠW�Q˜˜1˜a Ñ#Ô#ð 	ð
 2;¸1´¸yÈ¼|ÈYÐWXÌ\ ,�jˆõ !œ<¨°j×6JÒ6JÈ2ÈrÑ6RÔ6RÑSÔSÐà+¨d¬jÑ8Ðõ œ-×/Ò/Ð0@ÀbÐ/ÑIÔIˆð Ÿ,š, Ñ7Ô7ˆåœ _°lÑCÔC×KÒKÈAÈqÐRSÐUVÑWÔWˆà"/×"4Ò"4Ñ"6Ô"6°s¸°sÔ";¸t¼~Ð>OÑ"OÐØ%×-Ò-Ð.EÑFÔFˆà—’ Ñ/Ô/ˆà�Ð&Ð&r+   )r:   r;   r<   r=   rd   r&   r›   rœ   rÈ   r   r   r>   rš   rž   rŸ   s   @r)   r·   r·     s»   ø€ € € € € ØGÐGðDð Dð Dð Dð Dð$e˜Uœ\ð e°Cð e¸cð eð eð eð eð#'à”|ð#'ð Ð+Ô,ð#'ð 
ˆuŒ|˜Uœ\Ð)Ô	*ð	#'ð #'ð #'ð #'ð #'ð #'ð #'ð #'r+   r·   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚBlipMLPc                 ó  •— t          ¦   «                              ¦   «          || _        t          |j                 | _        t          j        |j        |j	        ¦  «        | _
        t          j        |j	        |j        ¦  «        | _        d S ©N)rc   rd   r\   r	   Ú
hidden_actÚactivation_fnr   rÀ   re   Úintermediate_sizeÚfc1Úfc2rq   s     €r)   rd   zBlipMLP.__init___  sf   ø€ Ý‰Œ×ÒÑÔÐØˆŒÝ# FÔ$5Ô6ˆÔÝ”9˜VÔ/°Ô1IÑJÔJˆŒÝ”9˜VÔ5°vÔ7IÑJÔJˆŒˆˆr+   r8   r    c                 ó„   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|S rÛ   )rß   rÝ   rà   )rV   r8   s     r)   rš   zBlipMLP.forwardf  s=   € ØŸš Ñ/Ô/ˆØ×*Ò*¨=Ñ9Ô9ˆØŸš Ñ/Ô/ˆØÐr+   )r:   r;   r<   rd   r&   r›   rš   rž   rŸ   s   @r)   rÙ   rÙ   ^  sc   ø€ € € € € ðKð Kð Kð Kð Kð U¤\ð °e´lð ð ð ð ð ð ð ð r+   rÙ   c                   óh   ‡ — e Zd Zdefˆ fd„Zedej        dee	         dej
        fd„¦   «         Zˆ xZS )ÚBlipEncoderLayerr\   c                 óD  •— t          ¦   «                              ¦   «          |j        | _        t	          |¦  «        | _        t          j        | j        |j        ¬¦  «        | _	        t          |¦  «        | _        t          j        | j        |j        ¬¦  «        | _        d S ©N)Úeps)rc   rd   re   rf   r·   Ú	self_attnr   Ú	LayerNormÚlayer_norm_epsÚlayer_norm1rÙ   ÚmlpÚlayer_norm2rq   s     €r)   rd   zBlipEncoderLayer.__init__n  s}   ø€ Ý‰Œ×ÒÑÔÐØÔ+ˆŒÝ& vÑ.Ô.ˆŒÝœ<¨¬¸FÔ<QÐRÑRÔRˆÔÝ˜6‘?”?ˆŒÝœ<¨¬¸FÔ<QÐRÑRÔRˆÔÐÐr+   r8   rÉ   r    c                 óÄ   — |}|                       |¦  «        } | j        dd|i|¤Ž\  }}||z   }|}|                      |¦  «        }|                      |¦  «        }||z   }|S )Nr8   rA   )rê   rç   rì   rë   )rV   r8   rÉ   Úresidualr–   s        r)   rš   zBlipEncoderLayer.forwardv  sŽ   € ð !ˆà×(Ò(¨Ñ7Ô7ˆØ)˜4œ>ð 
ð 
Ø'ð
àð
ð 
Ñˆ�qð &¨Ñ0ˆØ ˆØ×(Ò(¨Ñ7Ô7ˆØŸš Ñ/Ô/ˆà%¨Ñ0ˆàÐr+   )r:   r;   r<   r   rd   r   r&   r›   r   r   r?   rš   rž   rŸ   s   @r)   rã   rã   m  s’   ø€ € € € € ðS˜zð Sð Sð Sð Sð Sð Sð ðà”|ðð Ð+Ô,ðð 
Ô	ð	ð ð ñ „^ðð ð ð ð r+   rã   c                   ón   ‡ — e Zd ZU eed<   dZdZdZddgZdgZ	 e
j        ¦   «         ˆ fd„¦   «         Zˆ xZS )	ÚBlipPreTrainedModelr\   Úblip)ÚimageÚtextTrã   r¡   Úpast_key_valuesc                 ó  •— t          ¦   «                              |¦  «         | j        j        }t	          |t
          ¦  «        r`t          | j        d¦  «        r| j        j        j        }t          j	        |j
        d|¬¦  «         t          j	        |j        d|¬¦  «         dS t	          |t          ¦  «        rQt          j        |j        t          j        |j        j        d         ¦  «                             d¦  «        ¦  «         dS dS )zInitialize the weightsÚvision_configg        )ÚmeanÚstdrw   r¤   N)rc   Ú_init_weightsr\   Úinitializer_rangeÚ
isinstancer[   Úhasattrrö   ÚinitÚtrunc_normal_rp   rk   r¡   Úcopy_r£   r&   r'   r~   r”   )rV   Úmodulerø   rr   s      €r)   rù   z!BlipPreTrainedModel._init_weights–  sù   ø€ õ 	‰Œ×Ò˜fÑ%Ô%Ð%ØŒkÔ+ˆÝ�fÕ2Ñ3Ô3ð 	iÝ�t”{ OÑ4Ô4ð BØ”kÔ/ÔA�ÝÔ˜vÔ8¸sÈÐLÑLÔLÐLÝÔ˜vÔ5¸CÀSÐIÑIÔIÐIÐIÐIÝ˜Õ 2Ñ3Ô3ð 	iÝŒJ�vÔ*­E¬L¸Ô9LÔ9RÐSUÔ9VÑ,WÔ,W×,^Ò,^Ð_fÑ,gÔ,gÑhÔhÐhÐhÐhð	ið 	ir+   )r:   r;   r<   r   r@   Úbase_model_prefixÚinput_modalitiesÚsupports_gradient_checkpointingÚ_no_split_modulesÚ_skip_keys_device_placementr&   Úno_gradrù   rž   rŸ   s   @r)   rð   rð   �  sˆ   ø€ € € € € € àÐÐÑØÐØ(ÐØ&*Ð#Ø+Ð-AÐBÐØ#4Ð"5Ðà€U„]�_„_ð
ið 
ið 
ið 
iñ „_ð
ið 
ið 
ið 
ið 
ir+   rð   c                   óZ   ‡ — e Zd ZdZdefˆ fd„Zedee         de	e
z  fd„¦   «         Zˆ xZS )ÚBlipEncoderzû
    Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
    [`BlipEncoderLayer`].

    Args:
        config (`BlipConfig`):
            The corresponding vision configuration for the `BlipEncoder`.
    r\   c                 óÔ   •‡— t          ¦   «                              ¦   «          ‰| _        t          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _        d| _        d S )Nc                 ó.   •— g | ]}t          ‰¦  «        ‘ŒS rA   )rã   )rT   r–   r\   s     €r)   ú
<listcomp>z(BlipEncoder.__init__.<locals>.<listcomp>±  s"   ø€ Ð$gÐ$gÐ$gÀ!Õ%5°fÑ%=Ô%=Ð$gÐ$gÐ$gr+   F)	rc   rd   r\   r   Ú
ModuleListÚrangeÚnum_hidden_layersÚlayersÚgradient_checkpointingrq   s    `€r)   rd   zBlipEncoder.__init__®  s`   øø€ Ý‰Œ×ÒÑÔÐØˆŒÝ”mÐ$gÐ$gÐ$gÐ$gÅuÈVÔMeÑGfÔGfÐ$gÑ$gÔ$gÑhÔhˆŒØ&+ˆÔ#Ð#Ð#r+   rÉ   r    c                 óL   — |}| j         D ]} ||fi |¤Ž}Œt          |¬¦  «        S )N)r7   )r  r   )rV   r­   rÉ   r8   Úencoder_layers        r)   rš   zBlipEncoder.forward´  sP   € ð &ˆØ!œ[ð 	ð 	ˆMØ)˜MØðð àðð ˆMˆMõ
 °Ð?Ñ?Ô?Ð?r+   )r:   r;   r<   r=   r   rd   r   r   r   r>   r   rš   rž   rŸ   s   @r)   r  r  ¤  s—   ø€ € € € € ðð ð,˜zð ,ð ,ð ,ð ,ð ,ð ,ð ð@ð Ð+Ô,ð@ð 
�Ñ	 ð	@ð @ð @ñ „^ð@ð @ð @ð @ð @r+   r  c                   óÌ   ‡ — e Zd ZU dZdZeed<   eedœZ	defˆ fd„Z
e ed¬¦  «        e	 	 ddej        dz  d	ed
ee         deez  fd„¦   «         ¦   «         ¦   «         Zd„ Zˆ xZS )ÚBlipVisionModelrŒ   )rò   r\   )r8   r9   c                 ó  •— t          ¦   «                              |¦  «         || _        |j        }t	          |¦  «        | _        t          |¦  «        | _        t          j	        ||j
        ¬¦  «        | _        |                      ¦   «          d S rå   )rc   rd   r\   re   r[   rs   r  Úencoderr   rè   ré   Úpost_layernormÚ	post_initr«   s      €r)   rd   zBlipVisionModel.__init__Í  sx   ø€ Ý‰Œ×Ò˜Ñ Ô Ð ØˆŒØÔ&ˆ	å.¨vÑ6Ô6ˆŒÝ" 6Ñ*Ô*ˆŒÝ œl¨9¸&Ô:OÐPÑPÔPˆÔà�ŠÑÔÐÐÐr+   F)Útie_last_hidden_statesNr‹   rÉ   r    c                 ó  — |€t          d¦  «        ‚|                      ||¬¦  «        } | j        dd|i|¤Ž}|j        }|                      |¦  «        }|d d …dd d …f         }|                      |¦  «        }t          ||¬¦  «        S )Nz You have to specify pixel_values)r‹   r­   r   )r7   Úpooler_outputrA   )r°   rs   r  r7   r  r   )rV   rŒ   r‹   rÉ   r8   Úencoder_outputsr7   Úpooled_outputs           r)   rš   zBlipVisionModel.forwardØ  s¿   € ð ÐÝÐ?Ñ@Ô@Ð@àŸš¨ÐOg˜ÑhÔhˆà+7¨4¬<ð ,
ð ,
Ø'ð,
àð,
ð ,
ˆð
 ,Ô=ÐØ ×/Ò/Ð0AÑBÔBÐà)¨!¨!¨!¨Q°°°¨'Ô2ˆØ×+Ò+¨MÑ:Ô:ˆå)Ø/Ø'ð
ñ 
ô 
ð 	
r+   c                 ó   — | j         S rÛ   )rs   rY   s    r)   Úget_input_embeddingsz$BlipVisionModel.get_input_embeddingsö  s
   € ØŒÐr+   ©NF)r:   r;   r<   Úmain_input_namer  r   r@   rã   r·   Ú_can_record_outputsrd   r   r   r   r&   r?   r�   r   r   r>   r   rš   r  rž   rŸ   s   @r)   r  r  Ä  s
  ø€ € € € € € Ø$€OØ!ÐØÐÐÑà)Ø#ðð Ðð
	Ð/ð 	ð 	ð 	ð 	ð 	ð 	ð  Ø€_¨EÐ2Ñ2Ô2Øð 26Ø).ð
ð 
àÔ'¨$Ñ.ð
ð #'ð
ð Ð+Ô,ð	
ð
 
Ð+Ñ	+ð
ð 
ð 
ñ „^ñ 3Ô2ñ  Ôð
ð6ð ð ð ð ð ð r+   r  zÂ
    This model is going to be deprecated in future versions. Please use `BlipForConditionalGeneration`, `BlipForQuestionAnswering` or `BlipForImageTextRetrieval` depending on your usecase.
    c                   ó@  ‡ — e Zd ZU eed<   defˆ fd„Zd„ Zd„ Zee		 	 	 dde
j        dz  de
j        dz  de
j        dz  d	ee         d
eez  f
d„¦   «         ¦   «         Zee		 	 dde
j        dz  ded	ee         d
eez  fd„¦   «         ¦   «         Ze		 	 	 	 dde
j        dz  de
j        dz  de
j        dz  ded
e
j        f
d„¦   «         Zee		 	 	 	 	 	 dde
j        dz  de
j        dz  de
j        dz  de
j        dz  dedz  ded	ee         d
eez  fd„¦   «         ¦   «         Zˆ xZS )Ú	BlipModelr\   c                 óX  •— t          ¦   «                              |¦  «         t          |j        t          ¦  «        s%t          dt          |j        ¦  «        › d�¦  «        ‚t          |j        t          ¦  «        s%t          dt          |j        ¦  «        › d�¦  «        ‚|j        }|j        }|j	        | _	        |j
        | _        |j
        | _        t          |¦  «        | _        t          |¦  «        | _        t#          j        | j        | j	        d¬¦  «        | _        t#          j        | j        | j	        d¬¦  «        | _        t#          j        t-          j        | j        j        ¦  «        ¦  «        | _        t6                               d¦  «         |                      ¦   «          d S )NzKconfig.text_config is expected to be of type BlipTextConfig but is of type ú.zOconfig.vision_config is expected to be of type BlipVisionConfig but is of type F)Úbiasz¸`BlipModel` is going to be deprecated in future release, please use `BlipForConditionalGeneration`, `BlipForQuestionAnswering` or `BlipForImageTextRetrieval` depending on your usecase.)rc   rd   rû   Útext_configr   Ú	TypeErrorÚtyperö   r   Úprojection_dimre   Útext_embed_dimÚvision_embed_dimr   Ú
text_modelr  Úvision_modelr   rÀ   Úvisual_projectionÚtext_projectionri   r&   rÃ   r\   Úlogit_scale_init_valueÚlogit_scaleÚloggerÚwarningr  )rV   r\   r(  rö   rr   s       €r)   rd   zBlipModel.__init__  s—  ø€ Ý‰Œ×Ò˜Ñ Ô Ð å˜&Ô,­nÑ=Ô=ð 	Ýð0Ý˜Ô+Ñ,Ô,ð0ð 0ð 0ñô ð õ
 ˜&Ô.Õ0@ÑAÔAð 	Ýð2Ý˜Ô-Ñ.Ô.ð2ð 2ð 2ñô ð ð
 Ô(ˆØÔ,ˆà$Ô3ˆÔØ)Ô5ˆÔØ -Ô 9ˆÔå'¨Ñ4Ô4ˆŒÝ+¨MÑ:Ô:ˆÔå!#¤¨4Ô+@À$ÔBUÐ\aÐ!bÑ!bÔ!bˆÔÝ!œy¨Ô)<¸dÔ>QÐX]Ð^Ñ^Ô^ˆÔÝœ<­¬°T´[Ô5WÑ(XÔ(XÑYÔYˆÔå�Šð Gñ	
ô 	
ð 	
ð
 	�ŠÑÔÐÐÐr+   c                 ó4   — | j                              ¦   «         S rÛ   )r.  r  rY   s    r)   r  zBlipModel.get_input_embeddings&  s   € ØŒ×3Ò3Ñ5Ô5Ð5r+   c                 ó:   — | j                              |¦  «         d S rÛ   )r.  Úset_input_embeddings©rV   Úvalues     r)   r8  zBlipModel.set_input_embeddings)  s   € ØŒ×,Ò,¨UÑ3Ô3Ð3Ð3Ð3r+   Nr¬   Úattention_maskr£   rÉ   r    c                 ól   —  | j         d|||ddœ|¤Ž}|j        }|                      |¦  «        |_        |S )aÖ  
        Examples:

        ```python
        >>> from transformers import AutoProcessor, BlipModel

        >>> model = BlipModel.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> inputs = processor(text=["a photo of a cat", "a photo of a dog"], padding=True, return_tensors="pt")
        >>> text_features = model.get_text_features(**inputs)
        ```T)r¬   r;  r£   Úreturn_dictrA   )r.  r  r1  )rV   r¬   r;  r£   rÉ   Útext_outputsr  s          r)   Úget_text_featureszBlipModel.get_text_features,  sd   € ð* FUÀTÄ_ð F
ØØ)Ø%Øð	F
ð F
ð
 ðF
ð F
ˆð %Ô2ˆØ%)×%9Ò%9¸-Ñ%HÔ%HˆÔ"àÐr+   FrŒ   r‹   c                 ój   —  | j         d||ddœ|¤Ž}|j        }|                      |¦  «        |_        |S )aÈ  
        Examples:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipModel

        >>> model = BlipModel.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> inputs = processor(images=image, return_tensors="pt")

        >>> image_features = model.get_image_features(**inputs)
        ```T)rŒ   r‹   r=  rA   )r/  r  r0  )rV   rŒ   r‹   rÉ   Úvision_outputsr  s         r)   Úget_image_featureszBlipModel.get_image_featuresM  s\   € ð: 6G°TÔ5Fð 6
Ø%Ø%=Øð6
ð 6
ð ð	6
ð 6
ˆð 'Ô4ˆØ'+×'=Ò'=¸mÑ'LÔ'LˆÔ$àÐr+   c                 ó$  — |                       ||¬¦  «        }|d         }t          j        |                     ¦   «         dd…         t          j        ¬¦  «        }|                      ||||¬¦  «        }|d         }	|                      |	¦  «        }
|
S )a  
        Returns:
            multimodal_features (`torch.FloatTensor` of shape `(batch_size, output_dim`): The multimodal embeddings
            obtained by applying the image embeddings to the text encoder using the cross-attention mechanism.

        Examples:
        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipModel

        >>> model = BlipModel.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))
        >>> texts = ["a photo of a cat", "a photo of a dog"]
        >>> inputs = processor(images=image, text=texts, padding=True, return_tensors="pt")

        >>> multimodal_features = model.get_multimodal_features(**inputs)
        ```©rŒ   r‹   r   Nrw   rŽ   ©r¬   r;  Úencoder_hidden_statesÚencoder_attention_maskr   )r/  r&   Úonesry   Úlongr.  r1  )rV   r¬   rŒ   r;  r‹   rA  r6   Ú
image_attsr>  r  Úmultimodal_featuress              r)   Úget_multimodal_featuresz!BlipModel.get_multimodal_featuresu  s¤   € ð> ×*Ò*Ø%Ø%=ð +ñ 
ô 
ˆð
 & aÔ(ˆÝ”Z × 1Ò 1Ñ 3Ô 3°C°R°CÔ 8ÅÄ
ÐKÑKÔKˆ
à—’ØØ)Ø".Ø#-ð	 'ñ 
ô 
ˆð % QœˆØ"×2Ò2°=ÑAÔAÐà"Ð"r+   Úreturn_lossc           	      ó”  —  | j         d||dœ|¤Ž} | j        d|||dœ|¤Ž}	|j        }
|                      |
¦  «        }
|	j        }|                      |¦  «        }|
|
                     ddd¬¦  «        z  }
||                     ddd¬¦  «        z  }| j                             ¦   «                              |j	        ¬¦  «        }|
                     |j	        |j
        ¬¦  «        }
t          j        ||
                     ¦   «         ¦  «        |z  }|                     ¦   «         }d	}|rt          |¦  «        }t          |||||
|	|¬
¦  «        S )a@  
        return_loss (`bool`, *optional*):
            Whether or not to return the contrastive loss.

        Examples:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipModel

        >>> model = BlipModel.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> inputs = processor(
        ...     text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True
        ... )

        >>> outputs = model(**inputs)
        >>> logits_per_image = outputs.logits_per_image  # this is the image-text similarity score
        >>> probs = logits_per_image.softmax(dim=1)  # we can take the softmax to get the label probabilities
        ```rD  )r¬   r;  r£   rb   rw   T)Úpr}   Úkeepdimr"   )r#   r�   N)r5   rK   rL   rM   r6   rN   rO   rA   )r/  r.  r  r0  r1  Únormr3  Úexpr‘   r#   r�   r&   rÌ   Útr1   rJ   )rV   r¬   rŒ   r;  r£   rM  r‹   rÉ   rA  r>  r6   rM   r3  rL   rK   r5   s                   r)   rš   zBlipModel.forward¨  s›  € ðN +˜Ô*ð 
Ø%Ø%=ð
ð 
ð ð
ð 
ˆð '�t”ð 
ØØ)Ø%ð
ð 
ð ð	
ð 
ˆð &Ô3ˆØ×-Ò-¨lÑ;Ô;ˆà"Ô0ˆØ×*Ò*¨;Ñ7Ô7ˆð $ l×&7Ò&7¸!ÀÈTÐ&7Ñ&RÔ&RÑRˆØ! K×$4Ò$4°q¸bÈ$Ð$4Ñ$OÔ$OÑOˆð Ô&×*Ò*Ñ,Ô,×/Ò/°{Ô7IÐ/ÑJÔJˆØ#—’¨kÔ.@ÈÔHY�ÑZÔZˆÝœ, {°L·N²NÑ4DÔ4DÑEÔEÈÑSˆØ*×,Ò,Ñ.Ô.ÐàˆØð 	@Ý.¨Ñ?Ô?ˆDåØØ-Ø+Ø#Ø%Ø*Ø .ð
ñ 
ô 
ð 	
r+   r´   r   )NNNF)NNNNNF)r:   r;   r<   r   r@   rd   r  r8  r   r   r&   r›   r   r   r>   r   r?  r?   r�   rB  rµ   rL  rJ   rš   rž   rŸ   s   @r)   r$  r$  ú  sÁ  ø€ € € € € € ð ÐÐÑð"˜zð "ð "ð "ð "ð "ð "ðH6ð 6ð 6ð4ð 4ð 4ð Øð *.Ø.2Ø,0ð	ð à”< $Ñ&ðð œ tÑ+ðð ”l TÑ)ð	ð
 Ð+Ô,ðð 
Ð+Ñ	+ðð ð ñ „^ñ Ôðð> Øð 26Ø).ð$ð $àÔ'¨$Ñ.ð$ð #'ð$ð Ð+Ô,ð	$ð
 
Ð+Ñ	+ð$ð $ð $ñ „^ñ Ôð$ðL ð .2Ø15Ø.2Ø).ð0#ð 0#àÔ# dÑ*ð0#ð Ô'¨$Ñ.ð0#ð œ tÑ+ð	0#ð
 #'ð0#ð 
Ô	ð0#ð 0#ð 0#ñ „^ð0#ðd Øð .2Ø15Ø.2Ø04Ø#'Ø).ðN
ð N
àÔ# dÑ*ðN
ð Ô'¨$Ñ.ðN
ð œ tÑ+ð	N
ð
 Ô&¨Ñ-ðN
ð ˜D‘[ðN
ð #'ðN
ð Ð+Ô,ðN
ð 
�Ñ	ðN
ð N
ð N
ñ „^ñ ÔðN
ð N
ð N
ð N
ð N
r+   r$  aÒ  
    BLIP Model for image captioning. The model consists of a vision encoder and a text decoder. One can optionally pass
    `input_ids` to the model, which serve as a text prompt, to make the text decoder continue the prompt. Otherwise,
    the decoder starts generating text from the [BOS] (beginning-of-sequence) token. will start generating the caption
    from the text input. If no text input is provided, the decoder will start with the [BOS] token only.
    c                   ó|  ‡ — e Zd ZU eed<   dZdddœZdefˆ fd„Zd„ Zd„ Z	e
e	 	 	 	 	 ddej        dej        d	z  dej        d	z  dej        d	z  dedeej        z  dee         deez  fd„¦   «         ¦   «         Z ej        ¦   «         	 	 	 ddej        dej        d	z  dej        d	z  dedej        f
d„¦   «         Zˆ xZS )ÚBlipForConditionalGenerationr\   rŒ   ú!text_decoder.cls.predictions.biasú3text_decoder.bert.embeddings.word_embeddings.weight©z)text_decoder.cls.predictions.decoder.biasz+text_decoder.cls.predictions.decoder.weightc                 ó  •— t          ¦   «                              |¦  «         t          |j        ¦  «        | _        t          |j        ¦  «        | _        |j        j        | _	        |j        j
        | _        |                      ¦   «          d S rÛ   )rc   rd   r  rö   r/  r   r(  Útext_decoderÚbos_token_idÚdecoder_input_idsÚpad_token_idÚdecoder_pad_token_idr  rq   s     €r)   rd   z%BlipForConditionalGeneration.__init__  su   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å+¨FÔ,@ÑAÔAˆÔå/°Ô0BÑCÔCˆÔà!'Ô!3Ô!@ˆÔØ$*Ô$6Ô$CˆÔ!ð 	�ŠÑÔÐÐÐr+   c                 ó4   — | j                              ¦   «         S rÛ   )rZ  r  rY   s    r)   r  z1BlipForConditionalGeneration.get_input_embeddings  ó   € ØÔ ×5Ò5Ñ7Ô7Ð7r+   c                 ó:   — | j                              |¦  «         d S rÛ   )rZ  r8  r9  s     r)   r8  z1BlipForConditionalGeneration.set_input_embeddings  ó   € ØÔ×.Ò.¨uÑ5Ô5Ð5Ð5Ð5r+   NFr   r¬   r;  Úlabelsr‹   Úlogits_to_keeprÉ   r    c           
      ó´   —  | j         d||dœ|¤Ž}|j        }	 | j        d|||	|d|dœ|¤Ž}
t          |
j        |
j        |	|j        |j        |j        ¬¦  «        S )a  
        Examples:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipForConditionalGeneration

        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))
        >>> text = "A picture of"

        >>> inputs = processor(images=image, text=text, return_tensors="pt")

        >>> outputs = model(**inputs)
        ```rD  r÷   )r¬   r;  rF  rc  Ú	reductionrd  )r5   r   r6   r7   r8   r9   rA   )r/  r7   rZ  r4   r5   r   r8   r9   )rV   rŒ   r¬   r;  rc  r‹   rd  rÉ   rA  r6   Úoutputss              r)   rš   z$BlipForConditionalGeneration.forward  s¯   € ðD +˜Ô*ð 
Ø%Ø%=ð
ð 
ð ð
ð 
ˆð &Ô7ˆà#�$Ô#ð 
ØØ)Ø".ØØØ)ð
ð 
ð ð
ð 
ˆõ 7Ø”Ø”>Ø%Ø,Ô>Ø(Ô6Ø%Ô0ð
ñ 
ô 
ð 	
r+   c           
      ó¾  — |j         d         }|                      ||¬¦  «        }|d         }t          j        |                     ¦   «         dd…         t          j        |j        ¬¦  «        }	t          |t          ¦  «        rt          j	        |¦  «        }nY|€Wt          j	        | j
        | j        j        j        gg¦  «                             |d¦  «                             |j        ¦  «        }| j        j        j        |dd…df<   |�|dd…dd…f         nd} | j        j        d|dd…dd…f         | j        j        j        | j        j        j        |||	dœ|¤Ž}
|
S )	aÜ  
        Overrides *generate* function to be able to use the model as a conditional generator

        Parameters:
            pixel_values (*torch.FloatTensor* of shape *(batch_size, num_channels, image_height, image_width)*:
                Input image to be processed
            input_ids (*torch.LongTensor* of shape *(batch_size, sequence_length)*, *optional*):
                The sequence used as a prompt for the generation.
            attention_mask (*torch.LongTensor* of shape *(batch_size, sequence_length)*, *optional*):
                Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:


        Examples:
        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipForConditionalGeneration

        >>> model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> inputs = processor(images=image, return_tensors="pt")

        >>> outputs = model.generate(**inputs)
        >>> print(processor.decode(outputs[0], skip_special_tokens=True))
        two cats sleeping on a couch
        ```
        r   rD  Nrw   ©r�   r#   r   )r¬   Úeos_token_idr]  r;  rF  rG  rA   )r~   r/  r&   rH  ry   rI  r#   rû   Úlistrµ   r\  r\   r(  rj  Úrepeatr‘   r[  rZ  ÚgenerateÚsep_token_idr]  )rV   rŒ   r¬   r;  r‹   Úgenerate_kwargsr•   rA  r6   Úimage_attention_maskrg  s              r)   rm  z%BlipForConditionalGeneration.generate[  s€  € ðV "Ô'¨Ô*ˆ
Ø×*Ò*Ø%Ø%=ð +ñ 
ô 
ˆð
 & aÔ(ˆå$œz¨,×*;Ò*;Ñ*=Ô*=¸c¸r¸cÔ*BÍ%Ì*Ð]iÔ]pÐqÑqÔqÐå�i¥Ñ&Ô&ð 	ÝÔ(¨Ñ3Ô3ˆIˆIØÐåÔ  4Ô#9¸4¼;Ô;RÔ;_Ð"`Ð!aÑbÔbß’˜
 AÑ&Ô&ß’�LÔ'Ñ(Ô(ð ð œ+Ô1Ô>ˆ	�!�!�!�Q�$‰Ø3AÐ3M˜¨¨¨¨3¨B¨3¨Ô/Ð/ÐSWˆà,�$Ô#Ô,ð 
Ø    3 B 3 Ô'ØœÔ0Ô=ØœÔ0Ô=Ø)Ø".Ø#7ð
ð 
ð ð
ð 
ˆð ˆr+   )NNNFr   )NNF)r:   r;   r<   r   r@   r!  Ú_tied_weights_keysrd   r  r8  r   r   r&   r?   rµ   r�   rœ   r›   r   r   r>   r4   rš   r  rm  rž   rŸ   s   @r)   rU  rU  û  sÔ  ø€ € € € € € ð ÐÐÑØ$€Oà5XØ7lðð Ðð
˜zð ð ð ð ð ð ð8ð 8ð 8ð6ð 6ð 6ð Øð .2Ø26Ø*.Ø).Ø-.ð9
ð 9
àÔ'ð9
ð Ô# dÑ*ð9
ð Ô(¨4Ñ/ð	9
ð
 Ô  4Ñ'ð9
ð #'ð9
ð ˜eœlÑ*ð9
ð Ð+Ô,ð9
ð 
Ð8Ñ	8ð9
ð 9
ð 9
ñ „^ñ Ôð9
ðv €U„]�_„_ð .2Ø26Ø).ðJð JàÔ'ðJð Ô# dÑ*ðJð Ô(¨4Ñ/ð	Jð
 #'ðJð 
Ô	ðJð Jð Jñ „_ðJð Jð Jð Jð Jr+   rU  aS  
    BLIP Model for visual question answering. The model consists of a vision encoder, a text encoder as well as a text
    decoder. The vision encoder will encode the input image, the text encoder will encode the input question together
    with the encoding of the image, and the text decoder will output the answer to the question.
    c                   ó~  ‡ — e Zd ZU eed<   dddœZdefˆ fd„Zd„ Zd„ Ze	e
	 	 	 	 	 dd
ej        dej        dej        dz  dej        dz  dej        dz  dej        dz  dedee         deez  fd„¦   «         ¦   «         Z ej        ¦   «         	 	 dd
ej        dej        dej        dz  dedej        f
d„¦   «         Zˆ xZS )ÚBlipForQuestionAnsweringr\   rV  rW  rX  c                 óP  •— t          ¦   «                              |¦  «         t          |j        ¦  «        | _        t          |j        d¬¦  «        | _        t          |j        ¦  «        | _	        |j        j
        | _        |j        j        | _        |                      ¦   «          d S )NF©Úadd_pooling_layer)rc   rd   r  rö   r/  r   r(  Útext_encoderr   rZ  r]  r^  r[  Údecoder_start_token_idr  rq   s     €r)   rd   z!BlipForQuestionAnswering.__init__·  sŽ   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å+¨FÔ,@ÑAÔAˆÔå)¨&Ô*<ÐPUÐVÑVÔVˆÔÝ/°Ô0BÑCÔCˆÔà$*Ô$6Ô$CˆÔ!Ø&,Ô&8Ô&EˆÔ#ð 	�ŠÑÔÐÐÐr+   c                 ó:   — | j                              |¦  «         d S rÛ   ©rw  r8  r9  s     r)   r8  z-BlipForQuestionAnswering.set_input_embeddingsÅ  rb  r+   c                 ó4   — | j                              ¦   «         S rÛ   ©rw  r  rY   s    r)   r  z-BlipForQuestionAnswering.get_input_embeddingsÈ  s   € àÔ ×5Ò5Ñ7Ô7Ð7r+   NFr¬   rŒ   r\  Údecoder_attention_maskr;  rc  r‹   rÉ   r    c           
      ó´  — |€|€t          d¦  «        ‚ | j        d||dœ|¤Ž}	|	j        }
t          j        |
                     ¦   «         dd…         t          j        ¬¦  «        } | j        d|||
|dœ|¤Ž}|�|€|}|d         } | j        d|||||dd	œ|¤Ž}|�|j	         
                    ¦   «         }nd}t          ||
|	j        |	j        |	j        ¬
¦  «        S )aï  
        Examples:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipForQuestionAnswering

        >>> model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-vqa-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))

        >>> # training
        >>> text = "How many cats are in the picture?"
        >>> label = "2"
        >>> inputs = processor(images=image, text=text, return_tensors="pt")
        >>> labels = processor(text=label, return_tensors="pt").input_ids

        >>> inputs["labels"] = labels
        >>> outputs = model(**inputs)
        >>> loss = outputs.loss
        >>> loss.backward()

        >>> # inference
        >>> text = "How many cats are in the picture?"
        >>> inputs = processor(images=image, text=text, return_tensors="pt")
        >>> outputs = model.generate(**inputs)
        >>> print(processor.decode(outputs[0], skip_special_tokens=True))
        2
        ```Na  Either `decoder_input_ids` or `labels` should be passed when calling `forward` with `BlipForQuestionAnswering`. if you are training the model make sure that `labels` is passed, if you are using the model for inference make sure that `decoder_input_ids` is passed or call `generate`rD  rw   rŽ   rE  r   r÷   )r¬   r;  rF  rG  rc  rf  )r5   r6   r7   r8   r9   rA   )r°   r/  r7   r&   rH  ry   rI  rw  rZ  r5   r÷   rC   r8   r9   )rV   r¬   rŒ   r\  r}  r;  rc  r‹   rÉ   rA  r6   rp  rH   Úanswer_outputÚdecoder_losss                  r)   rš   z BlipForQuestionAnswering.forwardÌ  sl  € ð^ ˆ>Ð/Ð7Ýðuñô ð ð +˜Ô*ð 
Ø%Ø%=ð
ð 
ð ð
ð 
ˆð &Ô7ˆÝ$œz¨,×*;Ò*;Ñ*=Ô*=¸c¸r¸cÔ*BÍ%Ì*ÐUÑUÔUÐà+˜$Ô+ð 
ØØ)Ø".Ø#7ð	
ð 
ð
 ð
ð 
ˆð ÐÐ"3Ð";à &Ðà)¨!Ô,ˆà)˜Ô)ð 
Ø'Ø1Ø"1Ø#1ØØð
ð 
ð ð
ð 
ˆð ÐØ(Ô-×2Ò2Ñ4Ô4ˆLˆLàˆLå(ØØ%Ø,Ô>Ø(Ô6Ø%Ô0ð
ñ 
ô 
ð 	
r+   c           	      ó²  — |                       ||¬¦  «        }|d         }t          j        |                     ¦   «         dd…         t          j        |j        ¬¦  «        }t          |t          ¦  «        rt          j        |¦  «        }|  	                    ||||d¬¦  «        }	|	d         }
t          j        |
                     ¦   «         dd…         t          j        |
j        ¬¦  «        }t          j
        |
                     d¦  «        df| j        |
j        ¬	¦  «        } | j        j        d|| j        j        j        | j        j        j        |
|d
œ|¤Ž}|S )a•  
        Overrides *generate* function to be able to use the model as a conditional generator

        Parameters:
            input_ids (*torch.LongTensor* of shape *(batch_size, sequence_length)*):
                The sequence used as a prompt for the generation.
            pixel_values (*torch.FloatTensor* of shape *(batch_size, num_channels, image_height, image_width)*:
                Input image to be processed
            attention_mask (*torch.LongTensor* of shape *(batch_size, sequence_length)*, *optional*):
                Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`. `1` for
                tokens that are NOT MASKED, `0` for MASKED tokens.
            **generate_kwargs:
                Additional arguments passed to the *generate* function of the decoder


        Examples:
        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipForQuestionAnswering

        >>> model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-vqa-base")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))
        >>> text = "How many cats are in the picture?"

        >>> inputs = processor(images=image, text=text, return_tensors="pt")

        >>> outputs = model.generate(**inputs)
        >>> print(processor.decode(outputs[0], skip_special_tokens=True))
        2
        ```
        rD  r   Nrw   ri  F)r¬   r;  rF  rG  r=  r   )Ú
fill_valuer#   )r¬   rj  r]  rF  rG  rA   )r/  r&   rH  ry   rI  r#   rû   rk  rµ   rw  Úfullrx  rZ  rm  r\   r(  rn  r]  )rV   r¬   rŒ   r;  r‹   ro  rA  r6   rp  Úquestion_outputsrH   Úquestion_attention_maskÚbos_idsrg  s                 r)   rm  z!BlipForQuestionAnswering.generate0  s  € ð\ ×*Ò*Ø%Ø%=ð +ñ 
ô 
ˆð
 & aÔ(ˆå$œz¨,×*;Ò*;Ñ*=Ô*=¸c¸r¸cÔ*BÍ%Ì*Ð]iÔ]pÐqÑqÔqÐå�i¥Ñ&Ô&ð 	4ÝÔ(¨Ñ3Ô3ˆIà×,Ò,ØØ)Ø".Ø#7Øð -ñ 
ô 
Ðð +¨1Ô-ˆå"'¤*Ø× Ò Ñ"Ô" 3 B 3Ô'­u¬zÀ/ÔBXð#
ñ #
ô #
Ðõ ”*Ø×!Ò! !Ñ$Ô$ aÐ(°TÔ5PÐYhÔYoð
ñ 
ô 
ˆð -�$Ô#Ô,ð 
ØØœÔ0Ô=ØœÔ0Ô=Ø"1Ø#:ð
ð 
ð ð
ð 
ˆð ˆr+   )NNNNFr   )r:   r;   r<   r   r@   rq  rd   r8  r  r   r   r&   rµ   r?   r�   r   r   r>   rC   rš   r  rm  rž   rŸ   s   @r)   rs  rs  ©  sã  ø€ € € € € € ð ÐÐÑà5XØ7lðð Ðð
˜zð ð ð ð ð ð ð6ð 6ð 6ð8ð 8ð 8ð Øð
 6:Ø:>Ø26Ø*.Ø).ð`
ð `
àÔ#ð`
ð Ô'ð`
ð !Ô+¨dÑ2ð	`
ð
 !&Ô 0°4Ñ 7ð`
ð Ô(¨4Ñ/ð`
ð Ô  4Ñ'ð`
ð #'ð`
ð Ð+Ô,ð`
ð 
Ð*Ñ	*ð`
ð `
ð `
ñ „^ñ Ôð`
ðD €U„]�_„_ð
 37Ø).ðTð TàÔ#ðTð Ô'ðTð Ô(¨4Ñ/ð	Tð
 #'ðTð 
Ô	ðTð Tð Tñ „_ðTð Tð Tð Tð Tr+   rs  a   
    BLIP Model with a vision and text projector, and a classification head on top. The model is used in the context of
    image-text retrieval. Given an image and a text, the model returns the probability of the text being relevant to
    the image.
    c                   óÄ   ‡ — e Zd ZU eed<   defˆ fd„Zd„ Zd„ Zee		 	 	 dde
j        d	e
j        d
edz  de
j        dz  dedee         deez  fd„¦   «         ¦   «         Zˆ xZS )ÚBlipForImageTextRetrievalr\   c                 óf  •— t          ¦   «                              |¦  «         t          |j        ¦  «        | _        t          |j        d¬¦  «        | _        t          j	        |j        j
        |j        ¦  «        | _        t          j	        |j        j
        |j        ¦  «        | _        t          j	        |j        j
        d¦  «        | _        t          |d¦  «        s|j        j        n|j        | _        t          |d¦  «        s|j        j        n|j        | _        |                      ¦   «          d S )NFru  rb   r^  rx  )rc   rd   r  rö   r/  r   r(  rw  r   rÀ   re   Úimage_text_hidden_sizeÚvision_projÚ	text_projÚitm_headrü   r]  r^  r[  rx  r  rq   s     €r)   rd   z"BlipForImageTextRetrieval.__init__’  s  ø€ Ý‰Œ×Ò˜Ñ Ô Ð å+¨FÔ,@ÑAÔAˆÔå)¨&Ô*<ÐPUÐVÑVÔVˆÔõ œ9 VÔ%9Ô%EÀvÔGdÑeÔeˆÔõ œ 6Ô#5Ô#AÀ6ÔC`ÑaÔaˆŒõ œ	 &Ô"4Ô"@À!ÑDÔDˆŒõ ˜6Ð#9Ñ:Ô:ð-ˆFÔÔ+Ð+àÔ,ð 	Ô!õ ˜6Ð#;Ñ<Ô<ð/ˆFÔÔ+Ð+àÔ.ð 	Ô#ð 	�ŠÑÔÐÐÐr+   c                 ó4   — | j                              ¦   «         S rÛ   r|  rY   s    r)   r  z.BlipForImageTextRetrieval.get_input_embeddings°  r`  r+   c                 ó:   — | j                              |¦  «         d S rÛ   rz  r9  s     r)   r8  z.BlipForImageTextRetrieval.set_input_embeddings³  rb  r+   TNFr¬   rŒ   Úuse_itm_headr;  r‹   rÉ   r    c           	      ó†  —  | j         d
||dœ|¤Ž}|j        }t          j        |                     ¦   «         dd…         t          j        ¬¦  «        }	|r< | j        d
||||	dœ|¤Ž}
|
j        }
|                      |
dd…ddd…f         ¦  «        }n� | j        d
||dœ|¤Ž}
|
j        }
t          |  	                    |dd…ddd…f         ¦  «        d¬¦  «        }t          |  
                    |
dd…ddd…f         ¦  «        d¬¦  «        }||                     ¦   «         z  }t          ||j        |j        |j        |
¬	¦  «        S )ax  
        use_itm_head (`bool`, *optional*, defaults to `True`):
            Whether or not to use the image-text matching head.

        Examples:

        ```python
        >>> from PIL import Image
        >>> import httpx
        >>> from io import BytesIO
        >>> from transformers import AutoProcessor, BlipForImageTextRetrieval

        >>> model = BlipForImageTextRetrieval.from_pretrained("Salesforce/blip-itm-base-coco")
        >>> processor = AutoProcessor.from_pretrained("Salesforce/blip-itm-base-coco")

        >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
        >>> with httpx.stream("GET", url) as response:
        ...     image = Image.open(BytesIO(response.read()))
        >>> text = "an image of a cat"

        >>> inputs = processor(images=image, text=text, return_tensors="pt")
        >>> outputs = model(**inputs)
        ```
        rD  Nrw   rŽ   rE  r   )r¬   r;  r|   )rF   r7   r8   r9   rH   rA   )r/  r7   r&   rH  ry   rI  rw  r�  r   r‹  rŒ  rS  rE   r8   r9   )rV   r¬   rŒ   r�  r;  r‹   rÉ   rA  r6   rJ  rH   r×   Ú
image_featÚ	text_feats                 r)   rš   z!BlipForImageTextRetrieval.forward¶  s³  € ðF +˜Ô*ð 
Ø%Ø%=ð
ð 
ð ð
ð 
ˆð &Ô7ˆÝ”Z × 1Ò 1Ñ 3Ô 3°C°R°CÔ 8ÅÄ
ÐKÑKÔKˆ
àð 	0Ø/˜dÔ/ð Ø#Ø-Ø&2Ø'1ð	ð ð
 ðð ˆOð .Ô?ˆOà—]’] ?°1°1°1°a¸¸¸°7Ô#;Ñ<Ô<ˆFˆFà/˜dÔ/ð Ø#Ø-ðð ð ðð ˆOð
 .Ô?ˆOå" 4×#3Ò#3°LÀÀÀÀAÀqÀqÀqÀÔ4IÑ#JÔ#JÐPRÐSÑSÔSˆJÝ! $§.¢.°ÀÀÀÀAÀqÀqÀqÀÔ1IÑ"JÔ"JÐPRÐSÑSÔSˆIà )§+¢+¡-¤-Ñ/ˆFå/ØØ,Ô>Ø(Ô6Ø%Ô0Ø+ð
ñ 
ô 
ð 	
r+   )TNF)r:   r;   r<   r   r@   rd   r  r8  r   r   r&   rµ   r?   r�   r   r   r>   rC   rš   rž   rŸ   s   @r)   rˆ  rˆ  ˆ  s  ø€ € € € € € ð ÐÐÑð˜zð ð ð ð ð ð ð<8ð 8ð 8ð6ð 6ð 6ð Øð
 %)Ø26Ø).ðH
ð H
àÔ#ðH
ð Ô'ðH
ð ˜T‘kð	H
ð
 Ô(¨4Ñ/ðH
ð #'ðH
ð Ð+Ô,ðH
ð 
Ð*Ñ	*ðH
ð H
ð H
ñ „^ñ ÔðH
ð H
ð H
ð H
ð H
r+   rˆ  )r$  rð   rU  rs  r  r   rˆ  )Dr=   Údataclassesr   Útypingr   r&   r   Útorch.nn.functionalr   Ú r   rý   Úactivationsr	   Ú
generationr
   Úmodeling_layersr   Úmodeling_outputsr   r   r   Úmodeling_utilsr   Úprocessing_utilsr   Úutilsr   r   r   r   r   r   Úutils.genericr   Úutils.output_capturingr   Úconfiguration_blipr   r   r   Úmodeling_blip_textr   r   Ú
get_loggerr:   r4  r›   r*   r1   r4   rC   rE   rJ   ÚModuler[   r¡   r·   rÙ   rã   rð   r  r  r$  rU  rs  rˆ  Ú__all__rA   r+   r)   ú<module>r¦     sC  ðð Ð à !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )à &Ð &Ð &Ð &Ð &Ð &Ø !Ð !Ð !Ð !Ð !Ð !Ø )Ð )Ð )Ð )Ð )Ð )Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð
 .Ð -Ð -Ð -Ð -Ð -Ø &Ð &Ð &Ð &Ð &Ð &Ø jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jØ 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LØ BÐ BÐ BÐ BÐ BÐ BÐ BÐ Bð 
ˆÔ	˜HÑ	%Ô	%€ð`˜Uœ\ð `¨e¬lð `ð `ð `ð `ð
-¨E¬Lð -¸U¼\ð -ð -ð -ð -ð €ððñ ô ð ð<ð <ð <ð <ð <¨kñ <ô <ñ „ñô ð<ð$ €ððñ ô ð ð<ð <ð <ð <ð < ñ <ô <ñ „ñô ð<ð €ððñ ô ð ð<ð <ð <ð <ð < {ñ <ô <ñ „ñô ð<ð0 Ø
ð 
ð  
ð  
ð  
ð  
�ñ  
ô  
ñ „ñ „ð 
ðFGð Gð Gð Gð G˜2œ9ñ Gô Gð GðV%ð %ð %ð %ð %˜œñ %ô %ð %ðP;'ð ;'ð ;'ð ;'ð ;'�B”Iñ ;'ô ;'ð ;'ð~ð ð ð ð ˆbŒiñ ô ð ðð ð ð ð Ð1ñ ô ð ð@ ðið ið ið ið i˜/ñ iô iñ „ðið,@ð @ð @ð @ð @�"”)ñ @ô @ð @ð@3ð 3ð 3ð 3ð 3Ð)ñ 3ô 3ð 3ðl €ððñ ô ð
y
ð y
ð y
ð y
ð y
Ð#ñ y
ô y
ñô ð
y
ðx €ððñ ô ðcð cð cð cð cÐ#6¸ñ cô cñô ðcðL €ððñ ô ðUð Uð Uð Uð UÐ2°Oñ Uô Uñô ðUðp €ððñ ô ðq
ð q
ð q
ð q
ð q
Ð 3ñ q
ô q
ñô ðq
ðhð ð €€€r+   