
    %	&h                        d dl mZ d dlmZmZmZmZ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 ddlmZmZ ddlmZmZmZmZ ddlm Z  ddl!m"Z"m#Z#  ejH                  e%      Z&dZ'dZ( ede(       G d de             Z) G d de	jT                        Z+	 d=de	jT                  dejX                  dejX                  dejX                  deejX                     de-de-fd Z. G d! d"e	jT                        Z/ G d# d$e	jT                        Z0 G d% d&e	jT                        Z1 G d' d(e	jT                        Z2d)Z3 ed*e3       G d+ d,e)             Z4e G d- d.e             Z5 G d/ d0e	jT                        Z6 G d1 d2e	jT                        Z7d3Z8 ed4e(       G d5 d6e)             Z9e G d7 d8e             Z: ed9e(       G d: d;e)e             Z;g d<Z<y)>    )	dataclass)CallableListOptionalTupleUnionN)nn)CrossEntropyLoss   )ACT2FN)DynamicCache)GenerationMixin)_prepare_4d_attention_mask)BaseModelOutputModelOutput)ALL_ATTENTION_FUNCTIONSPreTrainedModel)add_start_docstrings%add_start_docstrings_to_model_forwardloggingreplace_return_docstrings   )	AutoModel   )SmolVLMConfigSmolVLMVisionConfigr   ag  
    This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Parameters:
        config ([`SmolVLMConfig`] or [`SmolVLMVisionConfig`]):
            Model configuration class with all the parameters of the model. Initializing with a config file does not
            load the weights associated with the model, only the configuration. Check out the
            [`~PreTrainedModel.from_pretrained`] method to load the model weights.
zUThe bare SmolVLM Model outputting raw hidden-states without any specific head on top.c                   :    e Zd ZeZdZdZddgZdZdZ	dZ
dZdZd Zy)SmolVLMPreTrainedModelmodelTSmolVLMVisionAttentionSmolVLMDecoderLayerpast_key_valuesc                    t        | j                  d      r| j                  j                  n#| j                  j                         j                  }t        |d      r'|j                  j
                  j                  d|       t        |t        j                  t        j                  f      rY|j                  j
                  j                  d|       |j                  %|j                  j
                  j                          y y t        |t        j                        rf|j                  j
                  j                  d|       |j                  2|j                  j
                  |j                     j                          y y y )Ninitializer_rangeclass_embedding        )meanstd)hasattrconfigr$   get_text_configr%   datanormal_
isinstancer	   LinearConv2dweightbiaszero_	Embeddingpadding_idx)selfmoduler(   s      /var/www/pru.catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/transformers/models/smolvlm/modeling_smolvlm.py_init_weightsz$SmolVLMPreTrainedModel._init_weightsR   s$    t{{$78 KK)),,.@@ 	 6,-""''//Sc/Bfryy"))45MM&&CS&9{{&  &&( '-MM&&CS&9!!-""6#5#56<<> . .    N)__name__
__module____qualname__r   config_classbase_model_prefixsupports_gradient_checkpointing_no_split_modules_skip_keys_device_placement_supports_flash_attn_2_supports_sdpa_supports_flex_attn_supports_cache_classr9    r:   r8   r   r   C   sC    
 !L&*#13HI"3!N ?r:   r   c                   x     e Zd ZdZdef fdZdej                  dej                  dej                  fdZ
 xZS )SmolVLMVisionEmbeddingsaP  
    This is a modified version of `siglip.modelign_siglip.SiglipVisionEmbeddings` to enable images of variable
    resolution.

    The modifications are adapted from [Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolution](https://arxiv.org/abs/2307.06304)
    which allows treating images in their native aspect ratio and without the need to resize them to the same
    fixed size. In particular, we start from the original pre-trained SigLIP model
    (which uses images of fixed-size square images) and adapt it by training on images of variable resolutions.
    r*   c                    t         |           |j                  | _        |j                  | _        |j
                  | _        t        j                  |j                  | j                  | j
                  | j
                  d      | _	        | j                  | j
                  z  | _
        | j                  dz  | _        | j                  | _        t        j                  | j                  | j                        | _        y )Nvalid)in_channelsout_channelskernel_sizestridepaddingr   )super__init__hidden_size	embed_dim
image_size
patch_sizer	   r0   num_channelspatch_embeddingnum_patches_per_sidenum_patchesnum_positionsr4   position_embeddingr6   r*   	__class__s     r8   rR   z SmolVLMVisionEmbeddings.__init__q   s    ++ ++ ++!yy++?? 
 %)OOt$F!44a7!--"$,,t/A/A4>>"Rr:   pixel_valuespatch_attention_maskreturnc                    |j                   \  }}}}| j                  |      }|j                  d      j                  dd      }|| j                  z  || j                  z  }
}	t        j                  d| j                  z  dd| j                  z        }t        j                  ||	|
z  fd      }t        |      D ]  \  }}|d d df   j                         }|d   j                         }t        j                  ddd|z        }t        j                  ddd|z        }t        j                  ||d      }t        j                  ||d      }|d d d f   | j                  z  |z   j                         }|||   |j                  d	      j                         <    |j                  | j                  j                   j"                        }|| j                  |      z   }|S )
Nr   r   g      ?r   )size
fill_valueg!?T)right)shaperX   flatten	transposerV   torcharangerY   full	enumeratesum	bucketizeviewcputor\   r1   device)r6   r_   r`   
batch_size_max_im_hmax_im_wpatch_embeds
embeddingsmax_nb_patches_hmax_nb_patches_w
boundariesposition_ids	batch_idxp_attn_masknb_patches_hnb_patches_wfractional_coords_hfractional_coords_wbucket_coords_hbucket_coords_wpos_idss                         r8   forwardzSmolVLMVisionEmbeddings.forward   s   ,8,>,>)
Ax++L9!))!,66q!<
-5-H(VZVeVeJe*\\!d&?&?"?a$JcJcFcd
zz
4DGW4W'Xefg&/0D&E 	J"I{&q!t,002L&q>--/L"',,q(A<L"M"',,q(A<L"M#oo.A:UYZO#oo.A:UYZO&q$w/$2K2KKo]ffhGBIL#K$4$4R$8$<$<$>?	J $t'>'>'E'E'L'LM$"9"9,"GG
r:   )r;   r<   r=   __doc__r   rR   rj   FloatTensor
BoolTensorTensorr   __classcell__r^   s   @r8   rI   rI   f   sD    S2 S&E$5$5 UM]M] bgbnbn r:   rI   r7   querykeyvalueattention_maskscalingdropoutc                    t        j                  ||j                  dd            |z  }|||z   }t        j                  j                  |dt         j                        j                  |j                        }t        j                  j                  ||| j                        }t        j                  ||      }	|	j                  dd      j                         }	|	|fS )Nrf   )dimdtype)ptrainingr   r   )rj   matmulri   r	   
functionalsoftmaxfloat32rr   r   r   r   
contiguous)
r7   r   r   r   r   r   r   kwargsattn_weightsattn_outputs
             r8   eager_attention_forwardr      s     <<s}}R'<=GL!#n4==((2U]](SVVW\WbWbcL==((6??([L,,|U3K''1-88:K$$r:   c                        e Zd ZdZ fdZ	 	 ddej                  deej                     dee   de	ej                  eej                     f   fdZ
 xZS )	r    z=Multi-headed attention from 'Attention Is All You Need' paperc                    t         |           || _        |j                  | _        |j
                  | _        | j                  | j                  z  | _        | j                  | j                  z  | j                  k7  r&t        d| j                   d| j                   d      | j                  dz  | _	        |j                  | _        t        j                  | j                  | j                        | _        t        j                  | j                  | j                        | _        t        j                  | j                  | j                        | _        t        j                  | j                  | j                        | _        d| _        y )Nz;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).g      F)rQ   rR   r*   rS   rT   num_attention_heads	num_headshead_dim
ValueErrorscaleattention_dropoutr   r	   r/   k_projv_projq_projout_proj	is_causalr]   s     r8   rR   zSmolVLMVisionAttention.__init__   s   ++33$..8==4>>)T^^;MdnnM] ^NN#2'  ]]D(
//ii?ii?ii?		$..$..A r:   hidden_statesr   output_attentionsra   c           
         |j                   \  }}}| j                  |      }| j                  |      }| j                  |      }	|j	                  ||| j
                  | j                        j                  dd      }|j	                  ||| j
                  | j                        j                  dd      }|	j	                  ||| j
                  | j                        j                  dd      }	t        }
| j                  j                  dk7  rN| j                  j                  dk(  r|rt        j                  d       nt        | j                  j                     }
 |
| |||	|| j                  | j                  | j                   sdn| j"                        \  }}|j%                  |||      j'                         }| j)                  |      }|sd}||fS )	z#Input shape: Batch x Time x Channelr   r   eagersdpaz`torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to eager attention. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.r&   )r   r   r   N)rg   r   r   r   rp   r   r   ri   r   r*   _attn_implementationloggerwarning_oncer   r   r   r   r   reshaper   r   )r6   r   r   r   rt   
seq_lengthrT   querieskeysvaluesattention_interfacer   r   s                r8   r   zSmolVLMVisionAttention.forward   s    -:,?,?)
J	++m,{{=)]+,,z:t~~t}}U__`acdeyyZOYYZ[]^_ZT^^T]]S]]^_abc(?;;++w6{{//69>O##L
 '>dkk>^>^&_#$7nnJJ#}}C$,,	%
!\ "))*j)LWWYmmK0 LL((r:   NF)r;   r<   r=   r   rR   rj   r   r   boolr   r   r   r   s   @r8   r    r       sf    G2 26,1	-)||-) !.-) $D>	-)
 
u||Xell33	4-)r:   r    c                   V     e Zd Z fdZdej
                  dej
                  fdZ xZS )SmolVLMVisionMLPc                    t         |           || _        t        |j                     | _        t        j                  |j                  |j                        | _
        t        j                  |j                  |j                        | _        y N)rQ   rR   r*   r   
hidden_actactivation_fnr	   r/   rS   intermediate_sizefc1fc2r]   s     r8   rR   zSmolVLMVisionMLP.__init__  sd    #F$5$5699V//1I1IJ99V55v7I7IJr:   r   ra   c                 l    | j                  |      }| j                  |      }| j                  |      }|S r   )r   r   r   )r6   r   s     r8   r   zSmolVLMVisionMLP.forward  s4    /**=9/r:   )r;   r<   r=   rR   rj   r   r   r   r   s   @r8   r   r      s$    KU\\ ell r:   r   c            
            e Zd Zdef fdZ	 ddej                  dej                  dee   de	ej                     fdZ xZS )	SmolVLMEncoderLayerr*   c                 D   t         |           |j                  | _        t	        |      | _        t        j                  | j                  |j                        | _	        t        |      | _        t        j                  | j                  |j                        | _        y )Neps)rQ   rR   rS   rT   r    	self_attnr	   	LayerNormlayer_norm_epslayer_norm1r   mlplayer_norm2r]   s     r8   rR   zSmolVLMEncoderLayer.__init__  sm    ++/7<<F<Q<QR#F+<<F<Q<QRr:   r   r   r   ra   c                     |}| j                  |      }| j                  |||      \  }}||z   }|}| j                  |      }| j                  |      }||z   }|f}|r||fz  }|S )a=  
        Args:
            hidden_states (`torch.FloatTensor`):
                Input to the layer of shape `(batch, seq_len, embed_dim)`.
            attention_mask (`torch.FloatTensor`):
                Attention mask of shape `(batch, 1, q_len, k_v_seq_len)` where padding elements are indicated by very large negative values.
            output_attentions (`bool`, *optional*, defaults to `False`):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
        )r   r   r   )r   r   r   r   )r6   r   r   r   residualr   outputss          r8   r   zSmolVLMEncoderLayer.forward  s      !((7&*nn')/ '5 '
#|
 !=0 ((7/ =0 "&Gr:   )F)r;   r<   r=   r   rR   rj   r   r   r   r   r   r   r   r   s   @r8   r   r     sY    S2 S -2	$||$ $ $D>	$
 
u  	!$r:   r   c                        e Zd ZdZdef fdZ	 	 	 	 d
deej                     dee	   dee	   dee	   de
eef   f
d	Z xZS )SmolVLMEncoderz
    Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
    [`SmolVLMEncoderLayer`].

    Args:
        config: SmolVLMConfig
    r*   c                     t         |           || _        t        j                  t        |j                        D cg c]  }t        |       c}      | _        d| _	        y c c}w r   )
rQ   rR   r*   r	   
ModuleListrangenum_hidden_layersr   layersgradient_checkpointing)r6   r*   ru   r^   s      r8   rR   zSmolVLMEncoder.__init__H  sP    mm%PVPhPhJi$jQ%8%@$jk&+# %ks   A#r   r   output_hidden_statesreturn_dictra   c                    ||n| j                   j                  }||n| j                   j                  }||n| j                   j                  }|rdnd}|rdnd}|}| j                  D ]]  }	|r||fz   }| j
                  r+| j                  r| j                  |	j                  |||      }
n |	|||      }
|
d   }|sU||
d   fz   }_ |r||fz   }|st        d |||fD              S t        |||      S )ad  
        Args:
            inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
                Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation.
                This is useful if you want more control over how to convert `input_ids` indices into associated vectors
                than the model's internal embedding lookup matrix.
            attention_mask (`torch.Tensor` 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 tokens that are **masked**.

                [What are attention masks?](../glossary#attention-mask)
            output_attentions (`bool`, *optional*):
                Whether or not to return the attentions tensors of all attention layers. See `attentions` under
                returned tensors for more detail.
            output_hidden_states (`bool`, *optional*):
                Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors
                for more detail.
            return_dict (`bool`, *optional*):
                Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        NrG   )r   r   r   c              3   &   K   | ]	  }||  y wr   rG   .0vs     r8   	<genexpr>z)SmolVLMEncoder.forward.<locals>.<genexpr>  s     eqWXWde   last_hidden_stater   
attentions)r*   r   r   use_return_dictr   r   r   _gradient_checkpointing_func__call__tupler   )r6   inputs_embedsr   r   r   r   encoder_statesall_attentionsr   encoder_layerlayer_outputss              r8   r   zSmolVLMEncoder.forwardO  s7   < 2C1N-TXT_T_TqTq$8$D $++JjJj 	 &1%<k$++B]B]30d%![[ 	FM#!/=2B!B**t}} $ A A!**!"%	! !.!"&7! *!,M !/=3C2E!E)	F,  +}.>>Ne]NN$Seee+>Vd
 	
r:   NNNN)r;   r<   r=   r   r   rR   r   rj   r   r   r   r   r   r   r   r   s   @r8   r   r   ?  s~    ,} , 26,0/3&*E
 !.E
 $D>	E

 'tnE
 d^E
 
uo%	&E
r:   r   aR  
    This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Parameters:
        config ([`SmolVLMVisionConfig`]):
            Model configuration class with all the parameters of the model. Initializing with a config file does not
            load the weights associated with the model, only the configuration. Check out the
            [`~PreTrainedModel.from_pretrained`] method to load the model weights.
zDThe SmolVLM Vision Transformer Model outputting raw image embedding.c                        e Zd ZeZdZdZdZdef fdZd Z	d Z
	 	 	 	 ddeej                     dee   dee   d	ee   d
eeef   f
dZ xZS )SmolVLMVisionTransformerTr*   c                    t         |   |       |j                  }t        |      | _        t        |      | _        |j                  | _        t        j                  ||j                        | _        |j                  dk(  | _        y )Nr   flash_attention_2)rQ   rR   rS   rI   ry   r   encoderrV   r	   r   r   post_layernormr   _use_flash_attention_2)r6   r*   rT   r^   s      r8   rR   z!SmolVLMVisionTransformer.__init__  sm     &&	1&9%f- ++ ll9&:O:OP&,&A&AEX&X#r:   c                     | j                   S r   ry   r6   s    r8   get_input_embeddingsz-SmolVLMVisionTransformer.get_input_embeddings  s    r:   c                     || _         y r   r   r6   r   s     r8   set_input_embeddingsz-SmolVLMVisionTransformer.set_input_embeddings  s	    r:   r`   r   r   r   ra   c                    ||n| j                   j                  }||n| j                   j                  }||n| j                   j                  }|j	                  d      }|s| j
                  }t        j                  ||j	                  d      |z  |j	                  d      |z  f      }|j                  t        j                  |j                        }| j                  ||      }|j                  |d      }t        j                  |       sd }n"| j                  st        ||j                         }| j#                  |||||      }	|	d   }
| j%                  |
      }
|s	|
f|	dd  z   S t'        |
|	j(                  |	j*                  	      S )
Nr   r   r   r   rs   r_   r`   rf   )r   r   r   r   r   r   r   )r*   r   r   r   rc   rV   rj   onesrr   r   rs   ry   rp   anyr   r   r   r   r   r   r   r   )r6   r_   r`   r   r   r   rt   rV   r   encoder_outputsr   s              r8   r   z SmolVLMVisionTransformer.forward  s    2C1N-TXT_T_TqTq$8$D $++JjJj 	 &1%<k$++B]B]!&&q)
'J#(:: %%a(J6 %%a(J6$  $8#:#:T`TgTg#:#h \Xlm388RH yy../#' ,,#=>RTaTgTg#h ,,'//!5# ' 
 ,A. //0AB%'/!"*===/)77&11
 	
r:   r   )r;   r<   r=   r   r>   rD   _supports_flash_attention_2rE   rR   r   r  r   rj   r   r   r   r   r   r   r   r   s   @r8   r   r     s    
 'LN"&Y2 Y  <@,0/3&*7
 'u'7'787
 $D>	7

 'tn7
 d^7
 
uo%	&7
r:   r   c                       e Zd ZU dZdZeej                     ed<   dZ	ee
e
ej                           ed<   dZee
ej                        ed<   dZee
ej                        ed<   dZee
ej                        ed<   y)SmolVLMBaseModelOutputWithPasta	  
    Base class for SmolVLM model's outputs that may also contain a past key/values (to speed up sequential decoding).
    Args:
        last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
            Sequence of hidden-states at the output of the last layer of the model.
            If `past_key_values` is used only the last hidden-state of the sequences of shape `(batch_size, 1,
            hidden_size)` is output.
        past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
            Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
            `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and optionally if
            `config.is_encoder_decoder=True` 2 additional tensors of shape `(batch_size, num_heads,
            encoder_sequence_length, embed_size_per_head)`.
            Contains pre-computed hidden-states (key and values in the self-attention blocks and optionally if
            `config.is_encoder_decoder=True` in the cross-attention blocks) that can be used (see `past_key_values`
            input) to speed up sequential decoding.
        hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
            Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
            one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
            Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
        attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
            Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
            sequence_length)`.
            Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
            heads.
        image_hidden_states (`tuple(torch.FloatTensor)`, *optional*):
            Tuple of `torch.FloatTensor` (one for the output of the image embeddings, `(batch_size, num_images,
            sequence_length, hidden_size)`.
            image_hidden_states of the model produced by the vision encoder
    Nr   r"   r   r   image_hidden_states)r;   r<   r=   r   r   r   rj   r   __annotations__r"   r   r   r   r  rG   r:   r8   r  r    s    < 6:x 1 129AEOXeE%*;*;$<=>E8<M8E%"3"345<59Ju00129>B%(9(9":;Br:   r  c                   $     e Zd Z fdZd Z xZS )SmolVLMSimpleMLPc                     t         |           |j                  j                  |j                  dz  z  }|j
                  j                  }t        j                  ||d      | _        y )Nr   Fr2   )	rQ   rR   vision_configrS   scale_factortext_configr	   r/   proj)r6   r*   
input_sizeoutput_sizer^   s       r8   rR   zSmolVLMSimpleMLP.__init__$  sT    ))559L9La9OP
((44IIj+EB	r:   c                 $    | j                  |      S r   )r  )r6   xs     r8   r   zSmolVLMSimpleMLP.forward*  s    yy|r:   )r;   r<   r=   rR   r   r   r   s   @r8   r  r  #  s    Cr:   r  c                   ,     e Zd Z fdZddZd Z xZS )SmolVLMConnectorc                 d    t         |           |j                  | _        t        |      | _        y r   )rQ   rR   r  r  modality_projectionr]   s     r8   rR   zSmolVLMConnector.__init__/  s)    "//#3F#; r:   c                    |j                         \  }}}t        |dz        x}}|j                  ||||      }|j                  ||t        ||z        ||z        }|j                  dddd      }|j	                  |t        ||z        t        ||z        ||dz  z        }|j                  dddd      }|j	                  |t        ||dz  z        ||dz  z        }|S )Ng      ?r   r   r   r   )rc   intrp   permuter   )r6   r  r  bszseqrT   heightwidths           r8   pixel_shufflezSmolVLMConnector.pixel_shuffle4  s    ffhS)S#X&FF3y1FF3EL$8 99|;STIIaAq!IIc3u|34c&<:O6PR[_kmn_nRopIIaAq!IIc3slAo67lTUo9VWr:   c                 `    | j                  || j                        }| j                  |      }|S r   )r&  r  r  )r6   r  s     r8   r   zSmolVLMConnector.forward?  s4    "001DdFWFWX"667JK""r:   )r   )r;   r<   r=   rR   r&  r   r   r   s   @r8   r  r  .  s    <
	#r:   r  a  
    Args:
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
            it.

            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        attention_mask (`torch.Tensor` 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 tokens that are **masked**.

            [What are attention masks?](../glossary#attention-mask)

            Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            If `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
            `past_key_values`).

            If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
            and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
            information on the default strategy.

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.n_positions - 1]`. [What are position IDs?](../glossary#position-ids)
        past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
            Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
            `(batch_size, num_heads, sequence_length, embed_size_per_head)`) and 2 additional tensors of shape
            `(batch_size, num_heads, encoder_sequence_length, embed_size_per_head)`.

            Contains pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
            blocks) that can be used (see `past_key_values` input) to speed up sequential decoding.

            If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
            don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
            `decoder_input_ids` of shape `(batch_size, sequence_length)`.
        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
            is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
            model's internal embedding lookup matrix.
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)):
            The tensors corresponding to the input images. Pixel values can be obtained using
            [`AutoImageProcessor`]. See [`CLIPImageProcessor.__call__`] for details ([]`LlavaProcessor`] uses
            [`CLIPImageProcessor`] for processing images).
        pixel_attention_mask (`torch.Tensor` of shape `(batch_size, image_size, image_size)`, *optional*):
            Mask to avoid performing attention on padding pixel indices.
        image_hidden_states (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)`):
            The hidden states of the image encoder after modality projection.
        use_cache (`bool`, *optional*):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`).
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
            Indices depicting the position of the input sequence tokens in the sequence. Contrarily to `position_ids`,
            this tensor is not affected by padding. It is used to update the cache in the correct position and to infer
            the complete sequence length.
zOSmolVLM model consisting of a SIGLIP vision encoder and Llama3 language decoderc                        e Zd ZdZdef fdZd Zd Zd Zd Z	de
j                  d	e
j                  d
e
j                  fdZ ede      	 	 	 	 	 	 	 	 	 	 	 	 	 ddee
j                     dee
j                     dee
j                     deee
j$                        d	ee
j$                     dee
j$                     dee
j&                     d
ee
j$                     dee   dee   dee   dee   dee
j                     deeef   fd       Z xZS )SmolVLMModelz
    A subclass of Idefics3Model. We do *not* remove or block the call to inputs_merger
    in forward. Instead, we override inputs_merger here with custom logic.
    r*   c                    t         |   |       | j                  j                  j                  | _        | j                  j                  j                  | _        t        j                  |j                        | _
        t        |      | _        t        j                  |j                        | _        t!        |j                  j"                  |j                  j$                  z  dz  |j&                  dz  z        | _        | j                  j*                  | _        |j                  j,                  dk(  | _        | j1                          y )Nr   r   )rQ   rR   r*   r  pad_token_idr5   
vocab_sizer   _from_configr  vision_modelr  	connectorr   from_config
text_modelr   rU   rV   r  image_seq_lenimage_token_idr   r   	post_initr]   s     r8   rR   zSmolVLMModel.__init__  s     ;;22??++11<<4AA&BVBVW)&1#//0B0BC ""--1E1E1P1PPUVV[a[n[npq[qr
 #kk88&,&8&8&M&MQd&d#r:   c                     fdd }| j                         j                  |      | _         | j                        j                  |      | _        y)aE  
        Enables the gradients for the input embeddings.

        This is useful for lora when using gradient checkpointing.
        c.f. https://github.com/huggingface/peft/issues/1402#issuecomment-1913675032

        Override to set output.requires_grad = True for both the decoder's and vision model's embeddings.
        c                     t        t        | j                                     dk(  r| S  t        | j                               d         S )Nr   )lenlistchildren)r7   get_lowest_modules    r8   r:  zBSmolVLMModel.enable_input_require_grads.<locals>.get_lowest_module  s?    4)*+q0 )foo.?)@)CDDr:   c                 &    |j                  d       y NTrequires_grad_r7   inputoutputs      r8   make_inputs_require_gradszJSmolVLMModel.enable_input_require_grads.<locals>.make_inputs_require_grads      !!$'r:   N)r   register_forward_hook_text_require_grads_hookr.  _vision_require_grads_hook)r6   rB  r:  s     @r8   enable_input_require_gradsz'SmolVLMModel.enable_input_require_grads  sN    	E	( )-(A(A(C(Y(YZs(t%*;D<M<M*N*d*d%+
'r:   c                 l    | j                   j                          | j                  j                          y r   rE  removerF  r   s    r8   disable_input_require_gradsz(SmolVLMModel.disable_input_require_grads  &    %%,,.''..0r:   c                 6    | j                   j                         S r   )r1  r   r   s    r8   r   z!SmolVLMModel.get_input_embeddings  s    3355r:   c                 :    | j                   j                  |       y r   )r1  r  r  s     r8   r  z!SmolVLMModel.set_input_embeddings  s    ,,U3r:   	input_idsr   r  c                 H   |j                   \  }}}|| j                  k(  }|j                  d      }t        j                  ||z  dk(        st        d      ||z  }t        j                  j                  j                  |j                  d      dd      }	|	dd }
|j                  d      }|dz
  |z  }|dz
  |z  }|
j                  d      |z   }t        j                  |      }|||   ||   ddf   ||<   t        j                  |j                  d      ||      }|S )	ar  
        This method aims at merging the token embeddings with the image hidden states into one single sequence of vectors that are fed to the transformer LM.
        The merging happens as follows:
        - The text token sequence is: `tok_1 tok_2 tok_3 <fake_token_around_image> <image> <image> ... <image> <fake_token_around_image> tok_4`.
        - We get the image hidden states for the image through the vision encoder and that hidden state, after a pixel shuffle operation, is then projected into the text embedding space.
        We thus have a sequence of image hidden states of size (1, image_seq_len, hidden_dim), where 1 is for batch_size of 1 image and hidden_dim is the hidden_dim of the LM transformer.
        - The merging happens so that we obtain the following sequence: `vector_tok_1 vector_tok_2 vector_tok_3 vector_fake_tok_around_image {sequence of image_seq_len image hidden states} vector_fake_toke_around_image vector_tok_4`. That sequence is fed to the LM.
        - To fit the format of that sequence, `input_ids`, `input_embeds`, `attention_mask` are all 3 adapted to insert the image hidden states.
        r   r   r   zCAt least one sample has <image> tokens not divisible by patch_size.)r   r   )r   Nrf   )rg   r3  rn   rj   allr   r	   r   padcumsum	unsqueeze
zeros_likewhere)r6   rO  r   r  ru   rV   
image_masknum_image_tokensblocks_per_sampleoffsetsblock_offsetrow_cum	chunk_idx	local_idx	block_idximage_embedsmerged_embedss                    r8   inputs_mergerzSmolVLMModel.inputs_merger  s:    /44:q$"5"55
%>>a>0yy)J6!;<bcc,
:((%%))*;*B*Bq*B*I6YZ)[s|###+q[Z/	q[J.	 **1-	9	''6#6y7LiXbNcef7f#gZ J$8$8$<lMZr:   a  
        Inputs fed to the model can have an arbitrary number of images. To account for this, pixel_values fed to
        the model have image padding -> (batch_size, max_num_images, 3, max_heights, max_widths) where
        max_num_images is the maximum number of images among the batch_size samples in the batch.
        Padding images are not needed beyond padding the pixel_values at the entrance of the model.
        For efficiency, we only pass through the vision_model's forward the real images by
        discarding the padding images i.e. pixel_values of size (image_batch_size, 3, height, width) where
        image_batch_size would be 7 when num_images_per_sample=[1, 3, 1, 2] and max_num_images would be 3.
        r   r}   r"   r_   pixel_attention_mask	use_cacher   r   r   cache_positionra   c                 d   |
|
n| j                   j                  }
||n| j                   j                  }|	|	n| j                   j                  }	||n| j                   j                  }| j
                  r/| j                  j                  r|	rt        j                  d       d}	||j                  \  }}n||j                  \  }}}nt        d      d}|	r|
t               }|j                         }|||dk(  rt        d      |9 | j                  j                         |      j                  |j                         }||t        d      ||j                  \  }}}}}|} |j"                  ||z  g|j                  dd   }|j                  dd  j%                         }|d	k(  j'                  d
      |k7  }t)        |      sd|d<   ||   j+                         }|Lt-        j.                  dD cg c]  }|j                  |    c}t,        j0                  |j                         }n6 |j"                  ||z  g|j                  dd   }||   j+                         }| j                   j2                  j4                  }|j7                  d||      }|j7                  d||      }|j'                  d      dkD  j1                         }| j9                  ||      j:                  }| j=                  |      }n)|'|j                  | j>                  |j                         }||| jA                  |||      }| j                  |||||	|
|||	      }|stC        d g ||D              S tE        |j:                  |jF                  |jH                  |jJ                  |      S c c}w )NzZ`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...Fz5You have to specify either input_ids or inputs_embedsr   zWWhen first calling the model, if input_embeds are passed, input_ids should not be None.zMYou cannot specify both pixel_values and image_hidden_states at the same timer   r   r&   )rf   r   rQ  T)r   r   r   )rc   r   rs   )	dimensionrc   step)rf   r   r  r  )rO  r   r  )	r   r   r}   r"   re  r   r   r   rf  c              3   &   K   | ]	  }||  y wr   rG   r   s     r8   r   z'SmolVLMModel.forward.<locals>.<genexpr>u  s     Uqq}Ur   )r   r"   r   r   r  )&r*   r   r   re  r   r   r1  r   r   r   rg   r   r   get_seq_lengthr   rr   rs   rp   numelrn   r  r   rj   r  r   r  rV   unfoldr.  r   r/  r   rc  r   r  r"   r   r   )r6   rO  r   r}   r"   r   r_   rd  r  re  r   r   r   rf  rt   r   ru   past_seen_tokens
num_imagesrW   r$  r%  nb_values_per_imagereal_images_indsirV   patches_subgridr`   r   s                                r8   r   zSmolVLMModel.forward  s   8 2C1N-TXT_T_TqTq$8$D $++JjJj 	 "+!6IDKK<Q<Q	%0%<k$++B]B]==T__CC	l I  %.__"J
&(5(;(;%J
ATUU&"...==?$):?OST?Tvww BDOO@@B9MPPQZQaQabM #(;(Glmm%BNBTBT?J
L&%'L,<,,Z*-D^|GYGYZ[Z\G]^L #/"4"4QR"8">">"@ , 388\8JNaa'(&* #'(89DDFL $+',zz9BCA,,,Q/C**'..($ (A';'@'@+(.B.H.H.L($ (<<L'M'X'X'Z$22==J299AJ]g9hO-44qzXb4cO$3$7$7H$7$E$I#O#O#Q  #'"3"3)%9 #4 #     #'..1D"E ,"5"8"8tzzR[RbRb"8"c$)<)H !..#+$7 / M //')%+/!5#) " 

 U$Cg$C/B$CUUU-%77#33!//)) 3
 	
i Ds   9N-)NNNNNNNNNNNNN)r;   r<   r=   r   r   rR   rG  rK  r   r  rj   
LongTensorr   rc  r   SMOLVLM_INPUTS_DOCSTRINGr   r   r   r   r   r   r   r  r   r   r   s   @r8   r)  r)    s   

} $
4164 )) :?,, ]b]i]i D +	 	! 151537=A5948;?;?$(,0/3&*59@
E,,-@
 !.@
 u//0	@

 "$u'8'8"9:@
   1 12@
 u001@
 'u'7'78@
 &e&7&78@
 D>@
 $D>@
 'tn@
 d^@
 !!1!12@
 
u44	5@
@
r:   r)  c                      e Zd ZU dZdZeej                     ed<   dZ	eej                     ed<   dZ
eeej                        ed<   dZeeej                        ed<   dZeeej                        ed<   dZeeej                        ed<   y)	SmolVLMCausalLMOutputWithPasta  
    Base class for Idefics causal language model (or autoregressive) outputs.

    Args:
        loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
            Language modeling loss (for next-token prediction).
        logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
            Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
        past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
            Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
            `(batch_size, num_heads, sequence_length, embed_size_per_head)`)
            Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
            `past_key_values` input) to speed up sequential decoding.
        hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
            Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
            one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
            Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
        attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
            Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
            sequence_length)`.
            Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
            heads.
        image_hidden_states (`tuple(torch.FloatTensor)`, *optional*):
            Tuple of `torch.FloatTensor` (one for the output of the image embeddings, `(batch_size, num_images,
            sequence_length, hidden_size)`.
            image_hidden_states of the model produced by the vision encoder
    Nlosslogitsr"   r   r   r  )r;   r<   r=   r   ry  r   rj   r   r  rz  r"   r   r   r   r   r  rG   r:   r8   rx  rx    s    8 )-D(5$$
%,*.FHU&&'.9=OXd5#4#456=8<M8E%"3"345<59Ju00129>B%(9(9":;Br:   rx  z~The SmolVLM Model with a language modeling head. It is made up a SigLIP vision encoder, with a language modeling head on top. c            %       T    e Zd ZdZdgZ fdZd Zd Zd Zd Z	d Z
d	 Z ee       eee
      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddeej&                     deej(                     deej&                     deeej,                        deej,                     deej,                     deej.                     deej,                     deej&                     dee   dee   dee   deej&                     dee   deeej(                  f   deeef   f d              Z	 	 	 	 	 	 	 	 d fd	Z fdZ xZS ) SmolVLMForConditionalGenerationzy
    A subclass of Idefics3ForConditionalGeneration that uses SmolVLMModel
    instead of the default Idefics3Model.
    zlm_head.weightc                 Z   t         |   |       t        |      | _        | j                  j
                  | _        t        j                  |j                  j                  |j                  j                  d      | _        |j                  j                  | _
        | j                          y )NFr  )rQ   rR   r)  r   r*   r3  r	   r/   r  rS   r,  lm_headr4  r]   s     r8   rR   z(SmolVLMForConditionalGeneration.__init__  sz     !&)
"kk88yy!3!3!?!?ASASA^A^ejk ,,77 	r:   c                     d }| j                         j                  |      | _        | j                  j                  j                         j                  |      | _        y)z
        Enables the gradients for the input embeddings. This is useful for fine-tuning adapter weights while keeping
        the model weights fixed.
        c                 &    |j                  d       y r<  r=  r?  s      r8   rB  z]SmolVLMForConditionalGeneration.enable_input_require_grads.<locals>.make_inputs_require_grads  rC  r:   N)r   rD  rE  r   r.  rF  )r6   rB  s     r8   rG  z:SmolVLMForConditionalGeneration.enable_input_require_grads  sO    	( )-(A(A(C(Y(YZs(t%*.***A*A*V*V*X*n*n%+
'r:   c                 l    | j                   j                          | j                  j                          y r   rI  r   s    r8   rK  z;SmolVLMForConditionalGeneration.disable_input_require_grads  rL  r:   c                 J    | j                   j                  j                         S r   )r   r1  r   r   s    r8   r   z4SmolVLMForConditionalGeneration.get_input_embeddings  s    zz$$99;;r:   c                 N    | j                   j                  j                  |       y r   )r   r1  r  r  s     r8   r  z4SmolVLMForConditionalGeneration.set_input_embeddings  s    

2259r:   c                     | j                   S r   r~  r   s    r8   get_output_embeddingsz5SmolVLMForConditionalGeneration.get_output_embeddings  s    ||r:   c                     || _         y r   r  )r6   new_embeddingss     r8   set_output_embeddingsz5SmolVLMForConditionalGeneration.set_output_embeddings  s	    %r:   )output_typer>   rO  r   r}   r"   r   r_   rd  r  labelsre  r   r   rf  r   logits_to_keepra   c                 "   ||n| j                   j                  }||n| j                   j                  }||n| j                   j                  }| j	                  |||||||||
||||      }|d   }t        |t              rt        | d      n|}| j                  |dd|ddf         }d}|	|j                         }|	j                  |j                        }	|s|dd|j                  d   dz
   df   j                  |j                        }|dddddf   |dk7     j                         }|	dddf   |dk7     j                         }n1|dddddf   j                         }|	dddf   j                         }t               } ||j                  d|j!                  d            |j                  d            }|s|f|dd z   }||f|z   S |S t#        |||j$                  |j&                  |j(                  |j*                        S )a  
        Args:
            labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
                Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
                config.vocab_size]` or `model.image_token_id` (where `model` is your instance of `SmolVLMForConditionalGeneration`).
                Tokens with indices set to `model.image_token_id` are ignored (masked), the loss is only
                computed for the tokens with labels in `[0, ..., config.vocab_size]`.
        Returns:

        Example:

        ```python
        >>> import requests
        >>> import torch
        >>> from PIL import Image
        >>> from io import BytesIO

        >>> from transformers import AutoProcessor, AutoModelForImageTextToText
        >>> from transformers.image_utils import load_image

        >>> # Note that passing the image urls (instead of the actual pil images) to the processor is also possible
        >>> image1 = load_image("https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg")
        >>> image2 = load_image("https://cdn.britannica.com/59/94459-050-DBA42467/Skyline-Chicago.jpg")
        >>> image3 = load_image("https://cdn.britannica.com/68/170868-050-8DDE8263/Golden-Gate-Bridge-San-Francisco.jpg")

        >>> processor = AutoProcessor.from_pretrained("HuggingFaceTB/SmolVLM2-2.2B-Instruct")
        >>> model = AutoModelForImageTextToText.from_pretrained("HuggingFaceTB/SmolVLM2-2.2B-Instruct", torch_dtype=torch.bfloat16, device_map="auto")

        >>> # Create inputs
        >>> messages = [
        ...     {
        ...         "role": "user",
        ...         "content": [
        ...             {"type": "video", "path": path/to/video},
        ...             {"type": "text", "text": "What is happening in this video?"},
        ...         ]
        ...     }
        ... ]

        >>> inputs = processor.apply_chat_template([messages], add_generation_prompt=True)

        >>> # Generate
        >>> generated_ids = model.generate(**inputs, max_new_tokens=256)
        >>> generated_texts = processor.batch_decode(generated_ids, skip_special_tokens=True)

        >>> print(generated_texts)
        ```N)rO  r   r}   r"   r   r_   rd  r  re  r   r   rf  r   r   r   .rf   )ry  rz  r"   r   r   r  )r*   r   r   r   r   r.   r   slicer~  floatrr   rs   rg   r   r
   rp   rc   rx  r"   r   r   r  )r6   rO  r   r}   r"   r   r_   rd  r  r  re  r   r   rf  r   r  r   r   slice_indicesrz  ry  shift_attention_maskshift_logitsshift_labelsloss_fctrA  s                             r8   r   z'SmolVLMForConditionalGeneration.forward  sO   F 2C1N-TXT_T_TqTq$8$D $++JjJj 	 &1%<k$++B]B] **)%+'%!5 3/!5)#  
   
8B>SV8W~ot4]kmA}a,?@A\\^FYYv}}-F) (6a6<<?Q;N9O9Q6Q'R'U'UV\VcVc'd$%c3B3k23G13LMXXZ%c12g/Cq/HITTV%c3B3k2==?%c12g99;')HL--b,2C2CB2GH,J[J[\^J_`DY,F'+'7D7V#CVC,#33!//)) ' ; ;
 	
r:   c
                 p    t        |   |f||||||||	d|
}||d   dk(  r||d<   |
d |d<   d |d<   |S )N)r"   r   r   rf  r_   rd  r  r  r   rO  r_   rd  )rQ   prepare_inputs_for_generation)r6   rO  r"   r   r   rf  r_   rd  r  r  r   model_inputsr^   s               r8   r  z=SmolVLMForConditionalGeneration.prepare_inputs_for_generationY  s}      w<
+)')%!5 3)
 
 $):a)?(1L%*+/L(37L/0r:   c                 L    t        |   d|||d|}|j                  |d<   |S )N)r   model_kwargsis_encoder_decoderr  rG   )rQ   #_update_model_kwargs_for_generationr  )r6   r   r  r  r   r^   s        r8   r  zCSmolVLMForConditionalGeneration._update_model_kwargs_for_generation  sC    wB 
%1
 	
 /6.I.I*+r:   )NNNNNNNNNNNNNNr   )NNNNNNNN) r;   r<   r=   r   _tied_weights_keysrR   rG  rK  r   r  r  r  r   rv  r   rx  _CONFIG_FOR_DOCr   rj   ru  r   r   r   r   r   r   r   r   r   r  r  r   r   s   @r8   r|  r|    s   

 ++
1<:& ++CD+HWfg 151537=A5948;?;?-1$(,0/359&*34!{
E,,-{
 !.{
 u//0	{

 "$u'8'8"9:{
   1 12{
 u001{
 'u'7'78{
 &e&7&78{
 ))*{
 D>{
 $D>{
 'tn{
 !!1!12{
 d^{
  c5<</0!{
" 
u33	4#{
 h E{
@ ! &P	 	r:   r|  )r|  r   r)  r   )r&   )=dataclassesr   typingr   r   r   r   r   rj   r	   torch.nnr
   activationsr   cache_utilsr   
generationr   modeling_attn_mask_utilsr   modeling_outputsr   r   modeling_utilsr   r   utilsr   r   r   r   autor   configuration_smolvlmr   r   
get_loggerr;   r   r  SMOLVLM_START_DOCSTRINGr   ModulerI   r   r  r   r    r   r   r   SMOLVLM_VISION_START_DOCSTRINGr   r  r  r  rv  r)  rx  r|  __all__rG   r:   r8   <module>r     s?  , " 9 9   % ! ' ) B < F   E 
		H	%! " [?_ ?	?>7bii 7B %II%<<% 
% <<	%
 U\\*% % %.F)RYY F)Rryy -")) -`U
RYY U
p" " J"M
5 M
	M
` #C[ #C #CLryy #ryy #.G T Yj
) j
	j
Z "CK "C "CJ  I`&<o `	`F tr:   