+
    œ°³jØ/  ã                   óf  € ^ RI HtHt ^RIHt ^RIHtHt ^RIH	t	H
t
HtHt ^RIHtHtHt ^RIHtHt ]! 4       '       d   ^ RIt ! R R	]
R
R7      tRt]! R4       U u. uF
  p RV R R2NK  	  up ]! ^€4       U u. uF
  p RV R R2NK  	  up ,           t] ! R R]4      4       tR.tR# u up i u up i )é    )ÚOptionalÚUnion)ÚBatchFeature)Ú
ImageInputÚmake_flat_list_of_images)ÚMultiModalDataÚProcessingKwargsÚProcessorMixinÚUnpack)Ú
AddedTokenÚPreTokenizedInputÚ	TextInput)Úauto_docstringÚis_torch_availableNc                   ó>   € ] tR t^"tRRRRRRR/RRR	R
R/RRR//tRtR# )ÚColPaliProcessorKwargsÚtext_kwargsÚpaddingÚlongestÚreturn_mm_token_type_idsFÚreturn_text_replacement_offsetsÚimages_kwargsÚdata_formatÚchannels_firstÚdo_convert_rgbTÚcommon_kwargsÚreturn_tensorsÚpt© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú	_defaultsÚ__static_attributes__r   ó    Úo/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/colpali/processing_colpali.pyr   r   "   sB   † àØ�yØ&¨Ø-¨uð
ð
 	ØÐ+Ø˜dð
ð 	Ð*¨DÐ1ð„Ir&   r   F)Útotalz<image>i   z<locz0>4Ú>z<segz0>3c                   óT  a a€ ] tR t^5t o]tRV3R lV 3R lllt]RV3R lV 3R lll4       tRV 3R llt	RV3R lV 3R lllt
V3R lR	 ltRR
 lt]V 3R l4       t]V3R lR l4       t]! RR7      RV3R lR ll4       t]! RR7      V3R lR l4       tRV3R lR lltRtVtV ;t# )ÚColPaliProcessorc                ó&   <€ V ^8„  d   QhRS[ RS[ /# )é   Úvisual_prompt_prefixÚquery_prefix©Ústr)ÚformatÚ__classdict__s   "€r'   Ú__annotate__ÚColPaliProcessor.__annotate__9   s%   ø€ ÷ #Rñ #Rñ
 "ð#Rñ ñ#Rr&   c                óè  <€ W@n         WPn        \        VR4      '       g   \        R4      hVP                  V n        \        VR4      '       gO   \        \        RRR7      pRV./pVP                  V4       VP                  \        4      V n	        \        V n
        M"VP                  V n	        VP                  V n
        VP                  \        4       RVn        RVn        \        SV `A  WVR7       R	# )
zù
visual_prompt_prefix (`str`, *optional*, defaults to `"Describe the image."`):
    A string that gets tokenized and prepended to the image tokens.
query_prefix (`str`, *optional*, defaults to `"Question: "`):
    A prefix to be used for the query.
Úimage_seq_lengthz;Image processor is missing an `image_seq_length` attribute.Úimage_tokenFT)Ú
normalizedÚspecialÚadditional_special_tokens)Úchat_templateN)r.   r/   ÚhasattrÚ
ValueErrorr7   r   ÚIMAGE_TOKENÚadd_special_tokensÚconvert_tokens_to_idsÚimage_token_idr8   Ú
add_tokensÚEXTRA_TOKENSÚadd_bos_tokenÚadd_eos_tokenÚsuperÚ__init__)	ÚselfÚimage_processorÚ	tokenizerr<   r.   r/   r8   Útokens_to_addÚ	__class__s	   &&&&&&  €r'   rH   ÚColPaliProcessor.__init__9   sÕ   ø€ ð %9Ô!Ø(ÔÜ�Ð(:×;Ò;ÜÐZÓ[Ð[à /× @Ñ @ˆÔä�y -×0Ò0Ü$¤[¸UÈDÔQˆKØ8¸;¸-ÐHˆMØ×(Ñ(¨Ô7Ø"+×"AÑ"AÄ+Ó"NˆDÔÜ*ˆDÕà"+×":Ñ":ˆDÔØ(×4Ñ4ˆDÔà×Ñœ\Ô*Ø"'ˆ	ÔØ"'ˆ	Ôä‰Ñ˜À=ÐÖQr&   c                ó    <€ V ^8„  d   QhRS[ R,          RS[S[,          S[S[,          ,          S[S[,          ,          RS[S[,          RS[/# )r-   ÚimagesNÚtextÚkwargsÚreturn)r   r   r   Úlistr   r   r   )r2   r3   s   "€r'   r4   r5   _   sX   ø€ ÷ %ñ %á˜TÕ!ð%ñ Ñ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWð%ñ Ñ/Õ0ð	%ñ
 
ñ%r&   c                óp  <€ Ve   Ve   \        R4      hRVR&   V P                  ! V P                  3RV P                  P                  /VB pVR,          P                  RV P                  ^
,          4      pVey   V Uu. uF+  q`P                  P                   V P                   V V R2NK-  	  ppVR,          P                  R	R4      e'   VR,          R	;;,          V P                  ,          uu&   \        SV `0  ! RR
VRV/VB pVe'   VR,          P                  VR,          ^ 8H  R4      VR&   V# u upi )a¤  
Returns:
    [`BatchFeature`]: A [`BatchFeature`] with the following fields:

    - **input_ids** -- List of token ids to be fed to a model. Returned when `text` is not `None`. If `suffix`
      is provided, the `input_ids` will also contain the suffix input ids.
    - **attention_mask** -- List of indices specifying which tokens should be attended to by the model (when
      `return_attention_mask=True` or if *"attention_mask"* is in `self.model_input_names` and if `text` is not
      `None`).
    - **pixel_values** -- Pixel values to be fed to a model. Returned when `images` is not `None`.
    - **labels** -- Labels compatible with training if `suffix` is not None
Nz5Only one of text or images can be processed at a timeTÚreturn_token_type_idsÚtokenizer_init_kwargsr   ÚsuffixÚ
Ú
max_lengthrP   rQ   Ú	input_idsÚtoken_type_idsÚlabelsr   iœÿÿÿ)r>   Ú_merge_kwargsÚvalid_processor_kwargsrK   Úinit_kwargsÚpopÚquery_augmentation_tokenÚ	bos_tokenr/   Úgetr7   rG   Ú__call__Úmasked_fill)	rI   rP   rQ   rR   Úoutput_kwargsrX   ÚsampleÚmodel_inputsrM   s	   &&&,    €r'   re   ÚColPaliProcessor.__call__^   sL  ø€ ð& Ò Ò 2ÜÐTÓUÐUà*.ˆÐ&Ñ'Ø×*Ò*Ø×'Ñ'ñ
à"&§.¡.×"<Ñ"<ð
ð ñ
ˆð
 ˜}Õ-×1Ñ1°(¸D×<YÑ<YÐ\^Õ<^Ó_ˆàÒÙeiÓjÑeiÐ[a—~‘~×/Ñ/Ð0°×1BÑ1BÐ0CÀFÀ8ÈFÈ8ÐSUÓVÑeiˆDÐjØ˜]Õ+×/Ñ/°¸dÓCÒOØ˜mÕ,¨\×:¸d×>SÑ>SÕSÓ:ä‘wÒ'ÑR¨vÐR¸DÐRÀMÑRˆØÒØ%1°+Õ%>×%JÑ%JÈ<ÐXhÕKiÐmnÑKnÐptÓ%uˆL˜Ñ"ØÐùò ks   Á?1D3c                ó  <€ \         SV `  ! RR VRV/VB vrpVe^   \        V4      p\        \	        V4      4       Uu. uF4  pV P
                   V P                  P                   V P                   R2NK6  	  ppWRR3# u upi )rP   rQ   NrY   r   )	rG   Úprepare_inputs_layoutr   ÚrangeÚlenr8   rK   rc   r.   )rI   rP   rQ   rR   Ú_rM   s   &&&, €r'   rl   Ú&ColPaliProcessor.prepare_inputs_layout†   s�   ø€ Ü ™7Ò8Ñ\ÀÐ\ÈTÐ\ÐU[Ñ\Ðˆ�qØÒÜ-¨fÓ5ˆFô œs 6›{Ô+óá+�Að ×#Ñ#Ð$ T§^¡^×%=Ñ%=Ð$>¸t×?XÑ?XÐ>YÐY[Ó\Ù+ð ð ð ˜T 4Ð'Ð'ùò	s   ½:A>c                ó¨   <€ V ^8„  d   QhRS[ R,          RS[S[,          S[S[,          ,          S[S[,          ,          R,          RS[S[,          /# )r-   rP   NrQ   rR   )r   r   r   rT   r   r	   )r2   r3   s   "€r'   r4   r5   �   sY   ø€ ÷ Gñ Gá˜TÕ!ðGñ Ñ+Õ+©d±9­oÕ=ÁÑEVÕ@WÕWÐZ^Õ^ðGñ Ñ)Õ*ñ	Gr&   c                óR   <€ \         SV `  WR 7       Vf   Vf   \        R4      hR# R# ))rP   rQ   Nz&Either text or images must be provided)rG   Úvalidate_inputsr>   )rI   rP   rQ   rR   rM   s   &&&,€r'   rs   Ú ColPaliProcessor.validate_inputs�   s1   ø€ ô 	‰Ñ vÐÔ9ØŠ<˜FšNÜÐEÓFÐFñ +‰<r&   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r-   Úimage_inputsÚ	image_idxrS   )ÚdictÚintr1   )r2   r3   s   "€r'   r4   r5   š   s#   ø€ ÷ 8ñ 8±ð 8Áð 8ÑSVñ 8r&   c                ó<   € V P                   V P                  ,          # ©N)r8   r7   )rI   rv   rw   rR   s   &&&,r'   Úreplace_image_tokenÚ$ColPaliProcessor.replace_image_tokenš   s   € Ø×Ñ $×"7Ñ"7Õ7Ð7r&   c                ó®   € / pVeF   V P                   .\        V4      ,          p^.\        V4      ,          pVP                  RVRV/4       \        R/ VB # )ax  
Computes the number of placeholder tokens needed for multimodal inputs with the given sizes.

Args:
    image_sizes (list[list[str]], *optional*):
        The input sizes formatted as (height, width) per each image.
Returns:
    `MultiModalData`: A `MultiModalData` object holding number of tokens per each of the provided
    input modalities, along with other useful data.
Únum_image_tokensÚnum_image_patchesr   )r7   rn   Úupdater   )rI   Úimage_sizesrR   Úvision_datar   r€   s   &&,   r'   Ú_get_num_multimodal_tokensÚ+ColPaliProcessor._get_num_multimodal_tokens�   sc   € ð ˆØÒ"Ø $× 5Ñ 5Ð6¼¸[Ó9IÕIÐØ!" ¤c¨+Ó&6Õ 6ÐØ×ÑÐ 2Ð4DÐFYÐ[lÐmÔnÜÑ, Ñ,Ð,r&   c                ó*   <€ \         SV `  R R.,           # )r\   r]   )rG   Úmodel_input_names)rI   rM   s   &€r'   r‡   Ú"ColPaliProcessor.model_input_names¯   s   ø€ ä‰wÑ(Ð,<¸hÐ+GÕGÐGr&   c                ó    <€ V ^8„  d   QhRS[ /# )r-   rS   r0   )r2   r3   s   "€r'   r4   r5   ´   s   ø€ ÷ (ñ (©#ñ (r&   c                ó.   € V P                   P                  # )zr
Return the query augmentation token.

Query augmentation buffers are used as reasoning buffers during inference.
)rK   Ú	pad_token)rI   s   &r'   rb   Ú)ColPaliProcessor.query_augmentation_token³   s   € ð �~‰~×'Ñ'Ð'r&   znThis method forwards the `images` and `kwargs` arguments to ColPaliProcessor's [`~ColPaliProcessor.__call__`].)Úcustom_introc                ó4   <€ V ^8„  d   QhRS[ R,          RS[/# )r-   rP   NrS   )r   r   )r2   r3   s   "€r'   r4   r5   ¿   s$   ø€ ÷ 6ñ 6á˜TÕ!ð6ñ 
ñ	6r&   c                ó*   € V P                   ! RR V/VB # )rP   r   ©re   )rI   rP   rR   s   &&,r'   Úprocess_imagesÚColPaliProcessor.process_images¼   s   € ð �}Š}Ñ5 FÐ5¨fÑ5Ð5r&   zlThis method forwards the `text` and `kwargs` arguments to ColPaliProcessor's [`~ColPaliProcessor.__call__`].c                óF   <€ V ^8„  d   QhRS[ S[S[ ,          ,          RS[/# )r-   rQ   rS   )r   rT   r   )r2   r3   s   "€r'   r4   r5   É   s(   ø€ ÷ 2ñ 2á™$™y�/Õ)ð2ñ 
ñ	2r&   c                ó*   € V P                   ! RR V/VB # )rQ   r   r�   )rI   rQ   rR   s   &&,r'   Úprocess_queriesÚ ColPaliProcessor.process_queriesÆ   s   € ð �}Š}Ñ1 $Ð1¨&Ñ1Ð1r&   c                ó¢   <€ V ^8„  d   QhRS[ RS[R,          3,          RS[ RS[R,          3,          RS[RS[R,          RS[ RS[3,          R	R/# )
r-   Úquery_embeddingsztorch.TensorÚpassage_embeddingsÚ
batch_sizeÚoutput_dtypeztorch.dtypeÚoutput_deviceztorch.devicerS   )r   rT   ry   r   r1   )r2   r3   s   "€r'   r4   r5   Ð   st   ø€ ÷ >(ñ >(á ±°^Õ0DÐ DÕEð>(ñ " .±$°~Õ2FÐ"FÕGð>(ñ ð	>(ñ
 ˜}Õ-ð>(ñ ˜^©SÐ0Õ1ð>(ð 
ñ>(r&   c           	     ó8  € \        V4      ^ 8X  d   \        R4      h\        V4      ^ 8X  d   \        R4      hV^ ,          P                  V^ ,          P                  8w  d   \        R4      hV^ ,          P                  V^ ,          P                  8w  d   \        R4      hVf   V^ ,          P                  p. p\	        ^ \        V4      V4       EF1  p. p\
        P                  P                  P                  P                  WWs,            R^ R7      p	\	        ^ \        V4      V4       FŽ  p
\
        P                  P                  P                  P                  W*W£,            R^ R7      pVP                  \
        P                  ! RW›4      P                  ^R7      ^ ,          P                  ^R7      4       K�  	  VP                  \
        P                  ! V^R7      P                  V4      P                  V4      4       EK4  	  \
        P                  ! V^ R7      # )	aÂ  
Compute the late-interaction/MaxSim score (ColBERT-like) for the given multi-vector
query embeddings (`qs`) and passage embeddings (`ps`). For ColPali, a passage is the
image of a document page.

Because the embedding tensors are multi-vector and can thus have different shapes, they
should be fed as:
(1) a list of tensors, where the i-th tensor is of shape (sequence_length_i, embedding_dim)
(2) a single tensor of shape (n_passages, max_sequence_length, embedding_dim) -> usually
    obtained by padding the list of tensors.

Args:
    query_embeddings (`Union[torch.Tensor, list[torch.Tensor]`): Query embeddings.
    passage_embeddings (`Union[torch.Tensor, list[torch.Tensor]`): Passage embeddings.
    batch_size (`int`, *optional*, defaults to 128): Batch size for computing scores.
    output_dtype (`torch.dtype`, *optional*, defaults to `torch.float32`): The dtype of the output tensor.
        If `None`, the dtype of the input embeddings is used.
    output_device (`torch.device` or `str`, *optional*, defaults to "cpu"): The device of the output tensor.

Returns:
    `torch.Tensor`: A tensor of shape `(n_queries, n_passages)` containing the scores. The score
    tensor is saved on the "cpu" device.
zNo queries providedzNo passages providedz/Queries and passages must be on the same devicez-Queries and passages must have the same dtypeT)Úbatch_firstÚpadding_valuezbnd,csd->bcns)Údim)rn   r>   ÚdeviceÚdtyperm   ÚtorchÚnnÚutilsÚrnnÚpad_sequenceÚappendÚeinsumÚmaxÚsumÚcatÚto)rI   r˜   r™   rš   r›   rœ   ÚscoresÚiÚbatch_scoresÚbatch_queriesÚjÚbatch_passagess   &&&&&&      r'   Úscore_retrievalÚ ColPaliProcessor.score_retrievalÐ   sÍ  € ô@ ÐÓ  AÔ%ÜÐ2Ó3Ð3ÜÐ!Ó" aÔ'ÜÐ3Ó4Ð4à˜AÕ×%Ñ%Ð);¸AÕ)>×)EÑ)EÔEÜÐNÓOÐOà˜AÕ×$Ñ$Ð(:¸1Õ(=×(CÑ(CÔCÜÐLÓMÐMàÒØ+¨AÕ.×4Ñ4ˆLà%'ˆä�qœ#Ð.Ó/°×<ˆAØ/1ˆLÜ!ŸH™HŸN™N×.Ñ.×;Ñ;Ø  Q¥^Ð4À$ÐVWð <ó ˆMô ˜1œcÐ"4Ó5°zÖB�Ü!&§¡§¡×!3Ñ!3×!@Ñ!@Ø&¨1­>Ð:ÈÐ\]ð "Aó "�ð ×#Ñ#Ü—L’L °-ÓP×TÑTÐYZÐTÓ[Ð\]Õ^×bÑbÐghÐbÓiöñ	 Cð �M‰Mœ%Ÿ)š) L°aÔ8×;Ñ;¸LÓI×LÑLÈ]Ó[×\ñ =ô �yŠy˜ QÔ'Ð'r&   )r7   r8   rB   r/   r.   )NNNzDescribe the image.z
Question: )NNr{   )é€   NÚcpu)r    r!   r"   r#   r   r_   rH   r   re   rl   rs   r|   r„   Úpropertyr‡   rb   r‘   r•   r´   r%   Ú__classdictcell__Ú__classcell__)rM   r3   s   @@r'   r+   r+   5   sÎ   ù‡ € à3Ð÷#Rõ #RðJ ÷%ô %ó ð%÷N(÷Gõ G÷8ð 8ô-ð$ ôHó ðHð ÷(ó ð(ñ ð Fô÷6ñ 6óð6ñ ð Dô÷2óð2÷>(÷ >(ò >(r&   r+   )Útypingr   r   Úfeature_extraction_utilsr   Úimage_utilsr   r   Úprocessing_utilsr   r	   r
   r   Útokenization_utils_baser   r   r   r¥   r   r   r£   r   r?   rm   rD   r+   Ú__all__)r¯   s   0r'   Ú<module>rÁ      s¾   ð÷* #å 4ß ?ß XÓ Xß OÑ Oß 7ñ ×ÒÛôÐ-°Uõ ð €Ù).¨t¬Ó5© A�$�q˜�g˜Q“©Ñ5ÑRWÐX[ÔR\Ó8]ÑR\ÈQ¸4ÀÀ#¸wÀa»ÑR\Ñ8]Õ]€ð ôX(�~ó X(ó ðX(ðv Ð
‚ùò 6ùÒ8]s   ÁB)Á;B.