+
    œ°³je)  ã                  óº   € R t ^ RIHt ^ RIHt ^RIHt ^RIHtH	t	 ^RI
HtHtHt ^RIHt ^RIHtHtHt ]! 4       '       d   ^ RIt] ! R	 R
]4      4       tR
.tR# )zProcessor class for NeoMME.)Úannotations)ÚLiteral)ÚBatchFeature)Ú
ImageInputÚmake_flat_list_of_images)ÚProcessingKwargsÚProcessorMixinÚUnpack)Ú	TextInput)Úauto_docstringÚis_numpy_arrayÚis_torch_availableNc                  óÈ   a € ] tR t^tRt]tRV 3R llt]RR V 3R lll4       t	RR V 3R lllt
R R ltRR	 V 3R
 lllt]R V 3R ll4       tR t]RR R ll4       tRtV ;t# )ÚNeoMMEProcessorzú
Constructs a processor that prepares text and images for NeoMME models.

Plain text is tokenized without retrieval markers. Use [`~NeoMMEProcessor.apply_chat_template`] to format retrieval
inputs. Images receive a patch grid and two-axis positions.
c                	ór   <€ VP                   V n         VP                  V n        \        SV `  ! W3R V/VB  R# )Úchat_templateN)Úimage_tokenÚimage_token_idÚsuperÚ__init__)ÚselfÚimage_processorÚ	tokenizerr   ÚkwargsÚ	__class__s   &&&&,€Úm/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/neomme/processing_neomme.pyr   ÚNeoMMEProcessor.__init__*   s9   ø€ ð %×0Ñ0ˆÔØ'×6Ñ6ˆÔÜ‰Ò˜Ñ[À=Ð[ÐTZÔ[ó    c               ó(   € V ^8„  d   QhRRRRRRRR/# )	é   ÚimagesúImageInput | NoneÚtextú"TextInput | list[TextInput] | Noner   zUnpack[ProcessingKwargs]Úreturnr   © )Úformats   "r   Ú__annotate__ÚNeoMMEProcessor.__annotate__6   s2   € ÷ ;ñ ;à!ð;ð 1ð;ð +ð	;ð
 
ñ;r   c                óú  <€ VP                  RR4      p\        V\        4      '       d   V.MTp\        V P                  V R2R4      pVR8X  d9   Ve5   V Uu. uF'  qwP                  V P                  P                  4      NK)  	  upM. p\        SV `   ! RRVRV/VB p	V	R,          p
\        V
R4      '       d   V
P                  4       MT
pV	P                  R	4      p\        VR4      '       d   VP                  4       MTp\        V4       F¦  w  rïVe2   \        WýV,          4       UUu. uF  w  ppV'       g   K  VNK  	  uppMTpVe"   V'       d   V^ ,          V8w  d   \        R
4      hV'       g   Kk  VP                  V P                  P                  4      WŽ,          8w  g   K�  \        R4      h	  V	P                  RR4      pVe&   Vf   \        R4      hV P!                  V
VV4      V	R&   V	# u upi u uppi )aÒ  
Tokenize text or process images. Depending on the downstream task, inputs must first be formatted with
[`~NeoMMEProcessor.apply_chat_template`].

- Text inputs are tokenized as provided. For masked language modeling, prepend the document token
  (`tokenizer.document_token`) manually. For retrieval, use [`~NeoMMEProcessor.apply_chat_template`]
  instead.
- Image inputs always receive the complete document-page token formatting (the `<doc>` prefix followed
  by the `<img>` patch grid with `<row>` markers). For retrieval, use
  `apply_chat_template(..., task="document")` instead.

Returns:
    A [`BatchFeature`] with `input_ids` and `attention_mask`. Image inputs also return `position_ids`,
    and `pixel_values`.
Ú_retrieval_taskNÚ	_token_idÚqueryr    r"   Ú	input_idsÚtolistÚattention_maskzDThe NeoMME retrieval template must preserve its leading task marker.zHTruncation removed NeoMME query expansion tokens; increase `max_length`.Úimage_grid_hwz9NeoMME image inputs require `return_attention_mask=True`.Úposition_idsr%   )ÚpopÚ
isinstanceÚstrÚgetattrr   ÚcountÚ
mask_tokenr   Ú__call__Úhasattrr.   ÚgetÚ	enumerateÚzipÚ
ValueErrorÚmask_token_idÚ_build_position_ids)r   r    r"   r   Úretrieval_taskÚ
text_batchÚexpected_prefix_idÚvalueÚquery_mask_countsÚbatchr-   Úinput_ids_listr/   Úattention_mask_listÚindexÚinput_ids_rowÚtoken_idÚis_non_paddingÚnon_padded_idsr0   r   s   &&&,                €r   r8   ÚNeoMMEProcessor.__call__5   sÿ  ø€ ð,  Ÿ™Ð$5°tÓ<ˆÜ)¨$´×4Ò4�d‘V¸$ˆ
Ü$ T§^¡^¸Ð7GÀyÐ5QÐSWÓXÐð  Ô(¨ZÒ-Cñ BLÓLÁ¸�[‰[˜Ÿ™×2Ñ2Ö3ÁÒLàð 	ô
 ‘Ò ÑD¨ÐD°TÐD¸VÑDˆà˜+Õ&ˆ	Ü/6°yÀ(×/KÒ/K˜×)Ñ)Ô+ÐQZˆØŸ™Ð#3Ó4ˆÜ9@ÀÐQY×9ZÒ9Z˜n×3Ñ3Ô5Ð`nÐÜ$-¨nÖ$=Ñ ˆEð 'Ò2ô 58¸Ð[`ÕGaÔ4bôá4bÑ0˜ .Ü%÷ �HÙ4bóð #ð ð "Ò-·~ÈÐXYÕIZÐ^pÔIpÜ Ð!gÓhÐhß Ñ  ]×%8Ñ%8¸¿¹×9UÑ9UÓ%VÐZkÕZrÖ%rÜ Ð!kÓlÐlñ %>ð Ÿ	™	 /°4Ó8ˆØÒ$ØÒ%Ü Ð!\Ó]Ð]Ø$(×$<Ñ$<ØØØó%ˆE�.Ñ!ð
 ˆùòE Mùós   Á-G2Ä)G7Ä;G7c               ó    € V ^8„  d   QhRRRR/# )r   r    r!   r"   r#   r%   )r&   s   "r   r'   r(   s   s   € ÷ (ñ (à!ð(ð 1ñ(r   c                	óÒ   <€ \         SV `  ! RR VRV/VB w  rrEVeH   VfD   \        V4      pV P                  P                  V P
                  ,           .\        V4      ,          pWRR3# )r    r"   Nr%   )r   Úprepare_inputs_layoutr   r   Údocument_tokenr   Úlen)r   r    r"   r   ÚvideosÚaudior   s   &&&,  €r   rP   Ú%NeoMMEProcessor.prepare_inputs_layouts   s|   ø€ ô ',¡gÒ&Cñ '
Øð'
àð'
ð ñ'
Ñ#ˆ�fð
 Ò $¢,Ü-¨fÓ5ˆFØ—N‘N×1Ñ1°D×4DÑ4DÕDÐEÌÈFËÕSˆDØ˜T 4Ð'Ð'r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úimage_inputsÚdictÚ	image_idxÚintr$   r4   r%   )r&   s   "r   r'   r(   ƒ   s'   € ÷ Cñ C°ð CÀð CÐSVñ Cr   c                	ó  € VR ,          V,          w  rEV P                   P                  \        V4      ,          V P                   P                  ,           pV P                   P                  V\        V4      ,          ,           # )r0   )r   r   rZ   Ú	row_token)r   rW   rY   r   Úgrid_heightÚ
grid_widthÚrows   &&&,   r   Úreplace_image_tokenÚ#NeoMMEProcessor.replace_image_tokenƒ   sZ   € Ø".¨Õ"?À	Õ"JÑˆØ�n‰n×(Ñ(¬3¨z«?Õ:¸T¿^¹^×=UÑ=UÕUˆØ�~‰~×)Ñ)¨C´#°kÓ2BÕ,BÕBÐBr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úconversationz1list[dict[str, str]] | list[list[dict[str, str]]]r   z
str | NoneÚtaskz#Literal['query', 'document'] | NoneÚprocessor_kwargszdict | Noner%   )r&   s   "r   r'   r(   ˆ   s2   € ÷ 
ñ 
àGð
ð "ð
ð 2ð	
ð
 &ñ
r   c                ó®   <€ VP                  R4      '       d   \        R4      h/ T;'       g    / CRV/CpVe   RV/M/ p\        SV `  ! V3RVRV/VBVB # )zûApply the configured retrieval template and optionally tokenize its output.

When `tokenize=True`, image content must include an image, URL, path, or base64 value. Pass processing
options such as `max_length` or `max_side` through `processor_kwargs`.
Úreturn_assistant_tokens_maskzINeoMME retrieval templates do not support `return_assistant_tokens_mask`.r*   rd   r   re   )r:   r=   r   Úapply_chat_template)r   rc   r   rd   re   r   Útemplate_kwargsr   s   &&&&&, €r   rh   Ú#NeoMMEProcessor.apply_chat_templateˆ   sˆ   ø€ ð �:‰:Ð4×5Ò5ÜÐhÓiÐiàPÐ/×5Ð5°2ÐPÐ8IÈ4ÑPÐØ,0Ò,<˜6 4™.À"ˆÜ‰wÒ*Øñ
à'ð
ð .ð
ð ð	
ð
 ñ
ð 	
r   c               ó   € V ^8„  d   QhRR/# )r   r$   z	list[str]r%   )r&   s   "r   r'   r(   £   s   € ÷ jñ j 9ñ jr   c                	ób   <€ \         SV `   Uu. uF  qR 8w  g   K  VNK  	  upR.,           # u upi )r0   r1   )r   Úmodel_input_names)r   Únamer   s   & €r   rm   Ú!NeoMMEProcessor.model_input_names¢   s2   ø€ ä!&¡Ò!:ÓVÑ!:˜ÀoÑ>U—�Ñ!:ÑVÐZhÐYiÕiÐiùÒVs   Ž,›,c                ó2  € \        VR4      '       d   VP                  4       MTp\        V Uu0 uF  p\        V4      kK  	  up4      ^8w  d   \        R4      h\	        V\
        P                  4      p\        V4      p\
        P                  ! V4      p\
        P                  ! W!P                  R7      p\
        P                  ! W1P                  R7      p\
        P                  ! ^.VP                  O5\
        P                  VP                  R7      p^ p	\        \        W4      4       EF‡  w  p
w  r[\
        P                  ! VRR7      ^ ,          pW\,          pV P                   V9   dñ   V	\        V4      8  dá   W9,          P                  4       w  rïV	^,          p	\
        P"                  ! V P$                  P&                  V P                   .V P                   .V,          V P$                  P(                  .,           V,          OVP                  R7      p\
        P*                  ! VV4      '       g   \        R4      hV P-                  WïVP                  R7      pME\
        P.                  ! \        V4      VP                  R7      p\
        P0                  ! VV3RR7      pVP2                  VR	W¬3&   EKŠ  	  V	\        V4      8w  d   \        R
V	 R\        V4       R24      hV'       d   V# V'       d   VP5                  4       # VP                  4       # u upi )z›
Build two-axis positions for batches containing document images. This method
is stored in `processor` since it requires knowledge about special MM tokens
r.   zANeoMME image batches require padding to a common sequence length.©Údevice©Údtyperr   T)Úas_tuplezANeoMME image inputs contain an invalid or truncated token layout.)Údim:NNNzGot z image prompts for z images.éÿÿÿÿ)r9   r.   rR   r=   r3   ÚtorchÚTensorr   Ú	as_tensorrr   ÚzerosÚshapeÚlongr;   r<   Únonzeror   Útensorr   Údocument_token_idÚrow_token_idÚequalÚ_image_positionsÚarangeÚstackÚmTÚnumpy)r   r-   r/   r0   rF   rI   Úinput_ids_is_tensorÚinput_ids_is_numpyr1   Úimage_indexÚbatch_indexÚattention_mask_rowÚnon_padded_indicesrL   r]   r^   Úexpected_input_idsÚsample_position_idsÚtext_position_idss   &&&&               r   r?   Ú#NeoMMEProcessor._build_position_ids¦   s’  € ô
 07°yÀ(×/KÒ/K˜×)Ñ)Ô+ÐQZˆÜ¹ÓG¹ }”�MÖ"¹ÑGÓHÈAÔMÜÐ`ÓaÐaä(¨´E·L±LÓAÐÜ+¨IÓ6ÐÜ—O’O IÓ.ˆ	ÜŸš¨×@PÑ@PÔQˆÜŸš¨×>NÑ>NÔOˆä—{’{ AÐ#8¨	¯©Ñ#8ÄÇ
Á
ÐS\×ScÑScÔdˆØˆä@IÌ#ÈiÓJh×@iÑ<ˆKÑ<˜-Ü!&§¢Ð/AÈDÔ!QÐRSÕ!TÐØ*Õ>ˆNØ×"Ñ" nÔ4¸ÄsÈ=ÓGYÔ9YØ*7Õ*D×*KÑ*KÓ*MÑ'�Ø˜qÕ �Ü%*§\¢\àŸ™×8Ñ8Ø×+Ñ+ðð  ×.Ñ.Ð/°*Õ<ÀÇÁ×@[Ñ@[Ð?\Õ\Ð`kÕkðð
 %×+Ñ+ô&Ð"ô —{’{ >Ð3E×FÒFÜ$Ð%hÓiÐiØ&*×&;Ñ&;¸KÐ\e×\lÑ\lÐ&;Ó&mÑ#ä$)§L¢L´Ð5GÓ1HÐQZ×QaÑQaÔ$bÐ!Ü&+§k¢kÐ3DÐFWÐ2XÐ^`Ô&aÐ#à?R×?UÑ?UˆL˜˜KÐ;Ô<ñ+ Ajð. œ#˜mÓ,Ô,Ü˜t K =Ð0CÄCÈÓDVÐCWÐW_Ð`ÓaÐaçØÐß'9ˆ|×!Ñ!Ó#ÐT¸|×?RÑ?RÓ?TÐTùòQ Hs   ®Lc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r]   rZ   r^   rr   ztorch.device | Noner$   ztorch.Tensorr%   )r&   s   "r   r'   r(   ×   s*   € ÷ ñ  cð °sð ÐDWð Ðcoñ r   c                ó2  € \         P                  ! ^W^,           ,          ,           ^3\         P                  VR7      p\         P                  ! ^VR7      P	                  R4      VR&   \         P                  ! WR7      P	                  R4      P                  RV^,           4      p\         P                  ! V^,           VR7      P	                  ^ 4      P                  V R4      p^VP                  4       ,           VR&   ^VP                  4       ,           VR&   V# )zNReturn positions for `<doc> <img>` followed by the patch grid and row markers.rs   rq   :Nr   Nrw   )ºr   NNé    )r”   é   )rx   Úemptyr}   r„   Ú	unsqueezeÚexpandÚravel)r]   r^   rr   r1   ÚrowsÚcolumnss   &&&   r   rƒ   Ú NeoMMEProcessor._image_positionsÖ   sÚ   € ô —{’{ A¨ÀAµ~Õ(FÕ$FÈÐ#JÔRW×R\ÑR\ÐekÔlˆÜ Ÿ<š<¨°&Ô9×CÑCÀBÓGˆ�RÑÜ�|Š|˜KÔ7×AÑAÀ"ÓE×LÑLÈRÐQ[Ð^_ÕQ_Ó`ˆÜ—,’,˜z¨A�~°fÔ=×GÑGÈÓJ×QÑQÐR]Ð_aÓbˆØ $§*¡*£,Õ.ˆ�UÑØ '§-¡-£/Õ1ˆ�UÑØÐr   )r   r   )NNN)NN)N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úvalid_processor_kwargsr   r   r8   rP   r`   rh   Úpropertyrm   r?   Ústaticmethodrƒ   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s{   ø† ñð .Ð÷	\ð ÷;ñ ;ó ð;÷z(ò (õ C÷

ò 
ð4 ÷jó ðjò.Uð` öó ör   r   )r¢   Ú
__future__r   Útypingr   Úfeature_extraction_utilsr   Úimage_utilsr   r   Úprocessing_utilsr   r   r	   Útokenization_utils_baser
   Úutilsr   r   r   rx   r   Ú__all__r%   r   r   Ú<module>r°      s\   ðñ "å "å å 4ß ?ß HÑ HÝ 0ß GÑ Gñ ×ÒÛð ô�nó ó ððD Ð
‚r   