+
    œ°³j«  ã                   óÔ   € ^ RI Ht ^ RIt^RIHt ^RIHt ^RIHt ^RI	H
t
HtHt ^RIHt ^RIHt ]P"                  ! ]4      t] ! R	 R
]4      4       t]
 ! R R]4      4       tR.tR# )é    )Ú	dataclassN)ÚCache)Ú$ImageClassifierOutputWithNoAttention)ÚPreTrainedModel)Úauto_docstringÚcan_return_tupleÚlogging)ÚAutoModelForImageTextToText©ÚShieldGemma2Configc                   ó4   a € ] tR t^"t o RtRtV 3R ltRtV tR# )Ú0ShieldGemma2ImageClassifierOutputWithNoAttentionzWShieldGemma2 classifies images as violative or not relative to a specific policy
Args:
Nc                óH   <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   # )é   NÚprobabilities)ÚtorchÚTensor)ÚformatÚ__classdict__s   "€Úw/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/shieldgemma2/modeling_shieldgemma2.pyÚ__annotate__Ú=ShieldGemma2ImageClassifierOutputWithNoAttention.__annotate__"   s   ø‡ ‚ ñ —<‘< $Õ&Ñ-ò ó    © )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r   "   s   ø‡ € ñð *.€M÷ ƒ r   r   c                   ó¤   a a€ ] tR t^+t oRtRtRtRtRtRt	V3R lV 3R llt
R tR tR tR t]]RV3R	 lR
 ll4       4       tV3R ltRtVtV ;t# )Ú"ShieldGemma2ForImageClassificationÚmodelTc                ó    <€ V ^8„  d   QhRS[ /# ©r   Úconfigr   )r   r   s   "€r   r   Ú/ShieldGemma2ForImageClassification.__annotate__5   s   ø€ ÷ ñ Ñ1ñ r   c                óÈ   <€ \         SV `  VR 7       \        VRR4      V n        \        VRR4      V n        \
        P                  ! VR 7      V n        V P                  4        R# ))r(   Úyes_token_indexi *  Úno_token_indexi»  N)	ÚsuperÚ__init__Úgetattrr+   r,   r
   Úfrom_configr%   Ú	post_init)Úselfr(   Ú	__class__s   &&€r   r.   Ú+ShieldGemma2ForImageClassification.__init__5   sS   ø€ Ü‰Ñ ÐÔ'Ü& vÐ/@À&ÓIˆÔÜ% fÐ.>ÀÓEˆÔÜ0×<Ò<ÀFÔKˆŒ
Ø�‰Ör   c                óR   € V P                   P                  4       P                  4       # ©N)r%   Úget_decoderÚget_input_embeddings©r2   s   &r   r8   Ú7ShieldGemma2ForImageClassification.get_input_embeddings<   s   € Ø�z‰z×%Ñ%Ó'×<Ñ<Ó>Ð>r   c                óX   € V P                   P                  4       P                  V4       R # r6   )r%   r7   Úset_input_embeddings)r2   Úvalues   &&r   r<   Ú7ShieldGemma2ForImageClassification.set_input_embeddings?   s   € Ø�
‰
×ÑÓ ×5Ñ5°eÖ<r   c                óR   € V P                   P                  4       P                  4       # r6   )r%   r7   Úget_output_embeddingsr9   s   &r   r@   Ú8ShieldGemma2ForImageClassification.get_output_embeddingsB   s   € Ø�z‰z×%Ñ%Ó'×=Ñ=Ó?Ð?r   c                óX   € V P                   P                  4       P                  V4       R # r6   )r%   r7   Úset_output_embeddings)r2   Únew_embeddingss   &&r   rC   Ú8ShieldGemma2ForImageClassification.set_output_embeddingsE   s   € Ø�
‰
×ÑÓ ×6Ñ6°~ÖFr   c                óÆ  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[R,          RS[S[ P                  ,          RS[/# )r   Ú	input_idsNÚpixel_valuesÚattention_maskÚposition_idsÚpast_key_valuesÚtoken_type_idsÚinputs_embedsÚlabelsÚ	use_cacheÚoutput_attentionsÚoutput_hidden_statesÚreturn_dictÚlogits_to_keepÚreturn)r   Ú
LongTensorÚFloatTensorr   r   ÚboolÚintr   )r   r   s   "€r   r   r)   J   sÿ   ø€ ÷ ;
ñ ;
á×#Ñ# dÕ*ð;
ñ ×'Ñ'¨$Õ.ð;
ñ Ÿ™ tÕ+ð	;
ñ
 ×&Ñ&¨Õ-ð;
ñ  �ð;
ñ ×(Ñ(¨4Õ/ð;
ñ ×(Ñ(¨4Õ/ð;
ñ × Ñ  4Õ'ð;
ñ ˜$•;ð;
ñ   $�;ð;
ñ # T�kð;
ñ ˜D•[ð;
ñ ™eŸl™lÕ*ð;
ñ  
:ñ!;
r   c                ó   € V P                   ! RRVRVRVRVRVRVRVRVR	V	R
V
RVRVRV/VB pVP                  pVRRV P                  V P                  .3,          p\        P
                  ! VRR7      p\        VVR7      # )aÙ  
Returns:
    A `ShieldGemma2ImageClassifierOutputWithNoAttention` instance containing the logits and probabilities
    associated with the model predicting the `Yes` or `No` token as the response to that prompt, captured in the
    following properties.

        *   `logits` (`torch.Tensor` of shape `(batch_size, 2)`):
            The first position along dim=1 is the logits for the `Yes` token and the second position along dim=1 is
            the logits for the `No` token.
        *   `probabilities` (`torch.Tensor` of shape `(batch_size, 2)`):
            The first position along dim=1 is the probability of predicting the `Yes` token and the second position
            along dim=1 is the probability of predicting the `No` token.

    ShieldGemma prompts are constructed such that predicting the `Yes` token means the content *does violate* the
    policy as described. If you are only interested in the violative condition, use
    `violated = outputs.probabilities[:, 1]` to extract that slice from the output tensors.

    When used with the `ShieldGemma2Processor`, the `batch_size` will be equal to `len(images) * len(policies)`,
    and the order within the batch will be img1_policy1, ... img1_policyN, ... imgM_policyN.
rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   :NNN)Údim)Úlogitsr   r   éÿÿÿÿ)r%   r[   r+   r,   r   Úsoftmaxr   )r2   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   Ú	lm_kwargsÚoutputsr[   Úselected_logitsr   s   &&&&&&&&&&&&&&,    r   ÚforwardÚ*ShieldGemma2ForImageClassification.forwardH   së   € ðN —*’*ñ 
Øð
à%ð
ð *ð
ð &ð	
ð
 ,ð
ð *ð
ð (ð
ð ð
ð  ð
ð 0ð
ð "6ð
ð $ð
ð *ð
ð ñ
ˆð  —‘ˆØ   B¨×)=Ñ)=¸t×?RÑ?RÐ(SÐ!SÕTˆÜŸš o¸2Ô>ˆÜ?Ø"Ø'ô
ð 	
r   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # r'   r   )r   r   s   "€r   r   r)   +   s   ø‡ ‚ áÑò r   )r%   r,   r+   )ÚimageÚtext)NNNNNNNNNNNNr   )r   r   r   r   Úinput_modalitiesÚbase_model_prefixÚ_supports_flash_attnÚ_supports_sdpaÚ_supports_flex_attnÚ_supports_attention_backendr.   r8   r<   r@   rC   r   r   ra   r    r!   r"   Ú__classcell__)r3   r   s   @@r   r$   r$   +   sr   ù‡ € ð )ÐØÐØÐØ€NØÐØ"&Ð÷ó ò?ò=ò@òGð Ø÷;
ñ ;
ó ó ð;
÷? … r   r$   )Údataclassesr   r   Úcache_utilsr   Úmodeling_outputsr   Úmodeling_utilsr   Úutilsr   r   r	   Úautor
   Úconfiguration_shieldgemma2r   Ú
get_loggerr   Úloggerr   r$   Ú__all__r   r   r   Ú<module>rw      s�   ðõ "ã å  Ý DÝ -÷ñ õ
 /Ý :ð 
×	Ò	˜HÓ	%€ð ô.Ð7[ó .ó ð.ð ôY
¨ó Y
ó ðY
ðz )ð‚r   