+
    œ°³j×_  ã                   ó²  € ^ RI t ^ RIHt ^ RIHtHtHt ^ RIHtH	t	H
t
HtHtHtHtHt ^RIHt ^RIHt ^RIHtHt ]! RR	7      ] ! R
 R]4      4       4       t]! RR	7      ] ! R R]4      4       4       t]! RR	7      ] ! R R]4      4       4       t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]
4      t ! R R]4      t ! R R]	4      t. ROt R# )é    N)Ústrict)ÚInstructBlipConfigÚInstructBlipQFormerConfigÚInstructBlipVisionConfig)Ú'BaseModelOutputWithVisionQformerOutputsÚ$InstructBlipForConditionalGenerationÚ/InstructBlipForConditionalGenerationModelOutputÚInstructBlipModelÚInstructBlipPreTrainedModelÚInstructBlipQFormerModelÚInstructBlipVisionModelÚTransformersKwargs)ÚBaseModelOutputWithPooling)ÚUnpack)Úauto_docstringÚcan_return_tuplez"Salesforce/instructblip-flan-t5-xl)Ú
checkpointc                   ó   € ] tR t^(tRtRtR# )ÚInstructBlipVideoVisionConfiga   
Example:

```python
>>> from transformers import InstructBlipVideoVisionConfig, InstructBlipVideoVisionModel

>>> # Initializing a InstructBlipVideoVisionConfig with Salesforce/instructblip-flan-t5-xl style configuration
>>> configuration = InstructBlipVideoVisionConfig()

>>> # Initializing a InstructBlipVideoVisionModel (with random weights) from the Salesforce/instructblip-flan-t5-xl style configuration
>>> model = InstructBlipVideoVisionModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú€/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/instructblipvideo/modular_instructblipvideo.pyr   r   (   s   † õr   r   c                   ó   € ] tR t^<tRtRtR# )ÚInstructBlipVideoQFormerConfigaû  
cross_attention_frequency (`int`, *optional*, defaults to 2):
    The frequency of adding cross-attention to the Transformer layers.
encoder_hidden_size (`int`, *optional*, defaults to 1408):
    The hidden size of the hidden states for cross-attention.

Examples:

```python
>>> from transformers import InstructBlipVideoQFormerConfig, InstructBlipVideoQFormerModel

>>> # Initializing a InstructBlipVideo Salesforce/instructblip-flan-t5-xl style configuration
>>> configuration = InstructBlipVideoQFormerConfig()

>>> # Initializing a model (with random weights) from the Salesforce/instructblip-flan-t5-xl style configuration
>>> model = InstructBlipVideoQFormerModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
```r   Nr   r   r   r   r!   r!   <   s   † õr   r!   c                   óJ   a € ] tR t^Tt o RtRR/tRt]! 4       tV 3R lt	Rt
V tR# )ÚInstructBlipVideoConfiga®  
qformer_config (`dict`, *optional*):
    Dictionary of configuration options used to initialize [`InstructBlipVideoQFormerConfig`].
num_query_tokens (`int`, *optional*, defaults to 32):
    The number of query tokens passed through the Transformer.

Example:

```python
>>> from transformers import (
...     InstructBlipVideoVisionConfig,
...     InstructBlipVideoQFormerConfig,
...     OPTConfig,
...     InstructBlipVideoConfig,
...     InstructBlipVideoForConditionalGeneration,
... )

>>> # Initializing a InstructBlipVideoConfig with Salesforce/instructblip-flan-t5-xl style configuration
>>> configuration = InstructBlipVideoConfig()

>>> # Initializing a InstructBlipVideoForConditionalGeneration (with random weights) from the Salesforce/instructblip-flan-t5-xl style configuration
>>> model = InstructBlipVideoForConditionalGeneration(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config

>>> # We can also initialize a InstructBlipVideoConfig from a InstructBlipVideoVisionConfig, InstructBlipVideoQFormerConfig and any PreTrainedConfig

>>> # Initializing Instructblipvideo vision, Instructblipvideo Q-Former and language model configurations
>>> vision_config = InstructBlipVideoVisionConfig()
>>> qformer_config = InstructBlipVideoQFormerConfig()
>>> text_config = OPTConfig()

>>> config = InstructBlipVideoConfig(vision_config=vision_config, qformer_config=qformer_config, text_config=text_config)
```Úvideo_token_idÚvideo_token_indexNc                ó4   <€ V ^8„  d   Qh/ S[ R,          ;R&   # )é   Nr%   )Úint)ÚformatÚ__classdict__s   "€r   Ú__annotate__Ú$InstructBlipVideoConfig.__annotate__T   s   ø‡ ‚ ñP ˜T•zÑ(òQ r   r   )r   r   r   r   r   Úattribute_mapr%   ÚAttributeErrorÚimage_token_indexÚ__annotate_func__r   Ú__classdictcell__©r*   s   @r   r#   r#   T   s/   ø‡ € ñ"ðH &Ð':Ð;€MØ$(ÐÙ&Ó(Ð÷S ƒ r   r#   c                   ó   € ] tR t^€tRtRtR# )Ú InstructBlipVideoPreTrainedModelr   N)ÚvideoÚtext©r   r   r   r   Úinput_modalitiesr   r   r   r   r4   r4   €   s   † Ø(Ôr   r4   c                   ó   € ] tR t^„tRtRtR# )ÚInstructBlipVideoVisionModelr5   r   Nr7   r   r   r   r:   r:   „   s   † ØÔr   r:   c                   ó   € ] tR t^ˆtRtR# )ÚInstructBlipVideoQFormerModelr   N©r   r   r   r   r   r   r   r   r<   r<   ˆ   ó   † Ûr   r<   c                   ó   € ] tR t^ŒtRtR# )Ú4InstructBlipVideoForConditionalGenerationModelOutputr   Nr=   r   r   r   r@   r@   Œ   r>   r   r@   c                   óJ   a € ] tR t^�t o ]]RV 3R lR ll4       4       tRtV tR# )ÚInstructBlipVideoModelNc                ó„  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[RS[R,          RS[S[,          RS[S[,          /# )r'   Úpixel_valuesÚqformer_input_idsÚqformer_attention_maskNÚ	input_idsÚattention_maskÚdecoder_input_idsÚdecoder_attention_maskÚinputs_embedsÚinterpolate_pos_encodingÚ	use_cacheÚkwargsÚreturn)	ÚtorchÚFloatTensorÚ
LongTensorÚTensorÚboolr   r   Útupler@   )r)   r*   s   "€r   r+   Ú#InstructBlipVideoModel.__annotate__“   sí   ø€ ÷ [
ñ [
á×'Ñ'ð[
ñ !×,Ñ,ð[
ñ !&× 0Ñ 0°4Õ 7ð	[
ñ
 ×$Ñ$ tÕ+ð[
ñ ×(Ñ(¨4Õ/ð[
ñ !×+Ñ+¨dÕ2ð[
ñ !&× 0Ñ 0°4Õ 7ð[
ñ —|‘| dÕ*ð[
ñ #'ð[
ñ ˜$•;ð[
ñ Ñ+Õ,ð[
ñ 
ÑEÕ	Eñ[
r   c                óæ  € VP                   w  rÍrïpVP                  WÍ,          WïV4      pV P                  ! RR VRV	/VB pV^ ,          p\        P                  ! VP                  4       RR \        P                  VP                  R7      pV P                  P                  VP                   ^ ,          RR4      p\        P                  ! VP                  4       RR \        P                  VP                  R7      pVf   \        P                  ! V4      pVP                  V^ R7      pVP                  V^ R7      pVP                  VP                  4      p\        P                  ! VV.^R7      pV P                  ! RRVRVRVRVR	V/VB pV^ ,          R
RVP                  ^4      1R
3,          pV P                  V4      pVP                  WÀP                   P"                  V,          R4      pVfT   V P$                  P'                  4       ! V4      pW@P                   P(                  8H  pVf   \        P                  ! V4      pMmW€P'                  4       ! \        P*                  ! RV P                   P(                  \        P                  VP                  R7      4      8H  pVP-                  R4      pVP/                  R4      P                  VP                  4      pVP                  VP                  VP0                  4      pVP3                  VV4      pV P                   P4                  '       d   V P$                  ! RRVRVRV
/VB pMV P$                  ! RRVRVRVRVRV
/VB p\7        VVVR7      # )rD   rL   N©ÚdtypeÚdevice©ÚdimrG   rH   Úquery_embedsÚencoder_hidden_statesÚencoder_attention_maskºNNNrK   rM   rI   rJ   )Úvision_outputsÚqformer_outputsÚlanguage_model_outputsr   éÿÿÿÿ)ÚshapeÚreshapeÚvision_modelrP   ÚonesÚsizeÚlongrZ   Úquery_tokensÚexpandÚ	ones_likeÚrepeat_interleaveÚtoÚcatÚqformerÚlanguage_projectionÚconfigÚnum_query_tokensÚlanguage_modelÚget_input_embeddingsr$   ÚfullÚallÚ	unsqueezerY   Úmasked_scatterÚuse_decoder_only_language_modelr@   )ÚselfrD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   Ú
batch_sizeÚframesÚchannelÚheightÚwidthra   Úimage_embedsÚimage_attention_maskrk   Úquery_attention_maskÚquery_outputsÚquery_outputÚlanguage_model_inputsÚspecial_image_maskÚoutputss   &&&&&&&&&&&,               r   ÚforwardÚInstructBlipVideoModel.forward‘   sœ  € ð$ 6B×5GÑ5GÑ2ˆ
˜G¨UØ#×+Ñ+¨JÕ,?ÀÐRWÓXˆà×*Ò*ñ 
Ø%ð
à%=ð
ð ñ
ˆð
 & aÕ(ˆô  %Ÿzšz¨,×*;Ñ*;Ó*=¸c¸rÐ*BÌ%Ï*É*Ð]i×]pÑ]pÔqÐð ×(Ñ(×/Ñ/°×0BÑ0BÀ1Õ0EÀrÈ2ÓNˆÜ$Ÿzšz¨,×*;Ñ*;Ó*=¸c¸rÐ*BÌ%Ï*É*Ð]i×]pÑ]pÔqÐà!Ò)Ü%*§_¢_Ð5FÓ%GÐ"à-×?Ñ?ÀÈAÐ?ÓNÐØ!7×!IÑ!IÈ&ÐVWÐ!IÓ!XÐØ!7×!:Ñ!:Ð;O×;VÑ;VÓ!WÐÜ!&§¢Ð,@ÐBXÐ+YÐ_`Ô!aÐØŸšñ 
Ø'ð
à1ð
ð &ð
ð #/ð	
ð
 $8ð
ð ñ
ˆð % QÕ'¨Ð+A¨\×->Ñ->¸qÓ-AÐ+AÀ1Ð(DÕEˆð !%× 8Ñ 8¸Ó FÐð !6× =Ñ =¸jÏ+É+×JfÑJfÐioÕJoÐqsÓ tÐØÒ Ø ×/Ñ/×DÑDÔFÀyÓQˆMØ!*¯k©k×.HÑ.HÑ!HÐØÒ%Ü!&§¢°Ó!;�øà!.×2KÑ2KÔ2MÜ—
’
˜2˜tŸ{™{×9Ñ9ÄÇÁÐTa×ThÑThÔió3ñ "Ðð "4×!7Ñ!7¸Ó!;Ðà/×9Ñ9¸"Ó=×@Ñ@À×AUÑAUÓVÐØ 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ%×4Ñ4Ð5GÐI^Ó_ˆà�;‰;×6×6Ð6Ø×)Ò)ñ Ø+ðà-ðð $ðð ñ	‰Gð ×)Ò)ñ Ø+ðà-ðð #4ðð (>ð	ð
 $ðð ñˆGô DØ)Ø)Ø#*ô
ð 	
r   r   )NNNNNNFN)	r   r   r   r   r   r   rŠ   r   r1   r2   s   @r   rB   rB   �   s'   ø‡ € ØØ÷[
ñ [
ó ó ö[
r   rB   c                   óÊ   a € ] tR t^ñt o ]]RV 3R lR ll4       4       tR tV 3R lR lt]]RV 3R lR ll4       4       t	]
P                  ! 4       RV 3R	 lR
 ll4       tRtV tR# )Ú)InstructBlipVideoForConditionalGenerationNc                ó¶   <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[R,          RS[S[,          RS[S[,          /# )r'   rD   rE   rF   NrL   rN   rO   )rP   rQ   rR   rT   r   r   rU   r   )r)   r*   s   "€r   r+   Ú6InstructBlipVideoForConditionalGeneration.__annotate__ô   sv   ø€ ÷ Dñ Dá×'Ñ'ðDñ !×+Ñ+ðDñ !&× 0Ñ 0°4Õ 7ð	Dñ
 #'¨¥+ðDñ Ñ+Õ,ðDñ 
Ñ8Õ	8ñDr   c                ól  € VP                   w  rgr‰p
VP                  Wg,          W‰V
4      pV P                  ! RRVRV/VB p\        VP                  VP
                  VP                  VP                  VRR7      pV^ ,          p\        P                  ! VP                  4       RR \        P                  VP                  R7      pV P                  P                  VP                   ^ ,          RR4      p\        P                  ! VP                  4       RR \        P                  VP                  R7      pVf   \        P                  ! V4      pVP!                  V^ R7      pVP!                  V^ R7      pVP#                  VP                  4      p\        P$                  ! Wó.^R7      pV P&                  ! RRVRVR	VR
VRV/VB pVVn        V^ ,          RRVP                  ^4      1R3,          pV P+                  V4      pVP                  W`P,                  P.                  V,          R4      pVVn        V# )aÊ  
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)`):
    The tensors corresponding to the input images.
qformer_input_ids (`torch.LongTensor` of shape (batch_size, sequence_length)):
    The sequence used as a prompt to be fed to the Q-Former module.
qformer_attention_mask (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
    Mask to avoid performing attention on padding token indices.
rD   rL   N)Úlast_hidden_stateÚpooler_outputÚhidden_statesÚ
attentionsra   rb   rX   r[   rG   rH   r]   r^   r_   r`   r   rd   )re   rf   rg   r   r‘   r’   r“   r”   rP   rh   ri   rj   rZ   rk   rl   rm   rn   ro   rp   rq   rb   rr   rs   rt   )r|   rD   rE   rF   rL   rN   r}   r~   r   r€   r�   ra   r‚   rƒ   rk   r„   rb   r†   Úvideo_featuress   &&&&&,             r   Úget_video_featuresÚ<InstructBlipVideoForConditionalGeneration.get_video_featuresò   sN  € ð( 6B×5GÑ5GÑ2ˆ
˜G¨UØ#×+Ñ+¨JÕ,?ÀÐRWÓXˆà59×5FÒ5Fñ 6
Ø%ð6
à%=ð6
ð ñ6
ˆô
 AØ,×>Ñ>Ø(×6Ñ6Ø(×6Ñ6Ø%×0Ñ0Ø)Ø ô
ˆð & aÕ(ˆô  %Ÿzšz¨,×*;Ñ*;Ó*=¸c¸rÐ*BÌ%Ï*É*Ð]i×]pÑ]pÔqÐð ×(Ñ(×/Ñ/°×0BÑ0BÀ1Õ0EÀrÈ2ÓNˆÜ$Ÿzšz¨,×*;Ñ*;Ó*=¸c¸rÐ*BÌ%Ï*É*Ð]i×]pÑ]pÔqÐà!Ò)Ü%*§_¢_Ð5FÓ%GÐ"à-×?Ñ?ÀÈAÐ?ÓNÐØ!7×!IÑ!IÈ&ÐVWÐ!IÓ!XÐØ!7×!:Ñ!:Ð;O×;VÑ;VÓ!WÐÜ!&§¢Ð,@Ð+YÐ_`Ô!aÐØŸ,š,ñ 
Ø'ð
à1ð
ð &ð
ð #/ð	
ð
 $8ð
ð ñ
ˆð *9ˆÔ&Ø& qÕ)¨!Ð-C¨|×/@Ñ/@ÀÓ/CÐ-CÀQÐ*FÕGˆð ×1Ñ1°,Ó?ˆð (×/Ñ/°
¿K¹K×<XÑ<XÐ[aÕ<aÐceÓfˆØ'5ˆÔ$àÐr   c                 ó   € \        R 4      h)z=No need to inherit as this architecture only supports videos.)r.   )Úsuper_kwargss   ,r   Úget_image_featuresÚ<InstructBlipVideoForConditionalGeneration.get_image_features:  s   € ÜÐ\Ó]Ð]r   c                óN   <€ V ^8„  d   QhRS[ P                  RS[ P                  /# )r'   rG   rK   )rP   rR   rQ   )r)   r*   s   "€r   r+   r�   =  s'   ø€ ÷ "ñ "©e×.>Ñ.>ð "Éu×O`ÑO`ñ "r   c           
     ón  € Vfo   W P                  4       ! \        P                  ! RV P                  P                  \        P
                  VP                  R7      4      8H  pVP                  R4      pMWP                  P                  8H  pVP                  R4      P                  VP                  4      pV# )zJ
Obtains multimodal placeholder mask from `input_ids` or `inputs_embeds`.
rX   r   rd   )
rv   rP   rw   rs   r$   rj   rZ   rx   ry   ro   )r|   rG   rK   rˆ   s   &&& r   Úget_placeholder_maskÚ>InstructBlipVideoForConditionalGeneration.get_placeholder_mask=  s˜   € ð ÒØ!.×2KÑ2KÔ2MÜ—
’
˜2˜tŸ{™{×9Ñ9ÄÇÁÐTa×ThÑThÔió3ñ "Ðð "4×!7Ñ!7¸Ó!;Ñà!*¯k©k×.HÑ.HÑ!HÐà/×9Ñ9¸"Ó=×@Ñ@À×AUÑAUÓVÐØ!Ð!r   c                ó¬  <€ V ^8„  d   QhRS[ P                  RS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          R	S[ P                  R,          R
S[ P                  R,          RS[RS[R,          RS[S[,          RS[S[,          /# )r'   rD   rE   rF   NrG   rH   rI   rJ   rK   ÚlabelsrL   rM   rN   rO   )rP   rQ   rR   rT   r   r   rU   r@   )r)   r*   s   "€r   r+   r�   N  s  ø€ ÷ D
ñ D
á×'Ñ'ðD
ñ !×,Ñ,ðD
ñ !&× 0Ñ 0°4Õ 7ð	D
ñ
 ×$Ñ$ tÕ+ðD
ñ ×(Ñ(¨4Õ/ðD
ñ !×+Ñ+¨dÕ2ðD
ñ !&× 0Ñ 0°4Õ 7ðD
ñ ×(Ñ(¨4Õ/ðD
ñ × Ñ  4Õ'ðD
ñ #'ðD
ñ ˜$•;ðD
ñ Ñ+Õ,ðD
ñ 
ÑEÕ	EñD
r   c                óø  € V P                   ! V3RVRVRV
/VB pVP                  pVP                  pVP                  pVf   V P	                  4       ! V4      pVf   \
        P                  ! V4      pVP                  VP                  VP                  4      pV P                  WHR7      pVP                  VV4      pV P                  P                  '       d_   V P                  ! RRVRVRV/VB pV^ ,          pRpV	e7   V P                  ! RR	VR
V	RV P                  P                   P"                  /VB pM6V P                  ! RRVRVRVRVR
V	RV/VB pVP$                  pVP&                  p\)        VVVVVR7      # )aÐ	  
qformer_input_ids (`torch.LongTensor` of shape (batch_size, sequence_length)):
    The sequence used as a prompt to be fed to the Q-Former module.
qformer_attention_mask (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
    Mask to avoid performing attention on padding token indices.

Examples:

```python
>>> from transformers import InstructBlipVideoProcessor, InstructBlipVideoForConditionalGeneration
>>> import torch
>>> from huggingface_hub import hf_hub_download
>>> import av
>>> import numpy as np

>>> def read_video_pyav(container, indices):
...     '''
...     Decode the video with PyAV decoder.
...     Args:
...         container (`av.container.input.InputContainer`): PyAV container.
...         indices (`list[int]`): List of frame indices to decode.
...     Returns:
...         result (np.ndarray): np array of decoded frames of shape (num_frames, height, width, 3).
...     '''
...     frames = []
...     container.seek(0)
...     start_index = indices[0]
...     end_index = indices[-1]
...     for i, frame in enumerate(container.decode(video=0)):
...         if i > end_index:
...             break
...         if i >= start_index and i in indices:
...             frames.append(frame)
...     return np.stack([x.to_ndarray(format="rgb24") for x in frames])

>>> model = InstructBlipVideoForConditionalGeneration.from_pretrained("Salesforce/instructblip-vicuna-7b", device_map="auto")
>>> processor = InstructBlipVideoProcessor.from_pretrained("Salesforce/instructblip-vicuna-7b")

>>> file_path = hf_hub_download(
...       repo_id="nielsr/video-demo", filename="eating_spaghetti.mp4", repo_type="dataset"
... )
>>> container = av.open(file_path)

>>> # sample uniformly 4 frames from the video
>>> total_frames = container.streams.video[0].frames
>>> indices = np.arange(0, total_frames, total_frames / 4).astype(int)
>>> clip = read_video_pyav(container, indices)

>>> prompt = "What is happening in the video?"
>>> inputs = processor(text=prompt, images=clip, return_tensors="pt").to(model.device)

>>> outputs = model.generate(
...     **inputs,
...     do_sample=False,
...     num_beams=5,
...     max_length=256,
...     repetition_penalty=1.5,
...     length_penalty=1.0,
... )
>>> generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0].strip()
>>> print(generated_text)
"A person is eating a bowl of pasta, and they are using a fork to eat it. The person is sitting at a table, and the plate of pasta is on the table in front"
```rE   rF   rL   N©rK   rK   rH   rM   Úlogitsr¡   Ú
vocab_sizerI   rJ   )Úlossr¤   ra   rb   rc   r   )r–   r’   rb   ra   rv   rP   rm   ro   rZ   rY   rž   rz   rs   r{   ru   Úloss_functionÚtext_configr¥   r¦   r¤   r@   )r|   rD   rE   rF   rG   rH   rI   rJ   rK   r¡   rL   rM   rN   r•   r‡   rb   ra   rˆ   r‰   r¤   r¦   s   &&&&&&&&&&&&,        r   rŠ   Ú1InstructBlipVideoForConditionalGeneration.forwardL  sü  € ð` CG×BYÒBYØñC
à/ðC
ð $:ðC
ð &>ð	C
ð
 ñC
ˆð !/× <Ñ <ÐØ(×8Ñ8ˆØ'×6Ñ6ˆàÒ Ø ×5Ñ5Ô7¸	ÓBˆMàÒ!Ü"Ÿ_š_¨YÓ7ˆNà 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ!×6Ñ6°yÐ6Ó^ÐØ%×4Ñ4Ð5GÐI^Ó_ˆà�;‰;×6×6Ð6Ø×)Ò)ñ Ø+ðà-ðð $ðð ñ	ˆGð ˜Q•ZˆFØˆDØÒ!Ø×)Ò)ñ Ø!ðØ*0ðØ=A¿[¹[×=TÑ=T×=_Ñ=_ðØciñ�øð
 ×)Ò)ñ Ø+ðà-ðð #4ðð (>ð	ð
 ðð $ðð ñˆGð —<‘<ˆDØ—^‘^ˆFäCØØØ)Ø+Ø#*ô
ð 	
r   c                ó  <€ V ^8„  d   QhRS[ P                  RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R	S[ P                  /# )
r'   rD   rE   NrF   rG   rH   rK   rL   rO   )rP   rQ   rR   rT   )r)   r*   s   "€r   r+   r�   Õ  s¨   ø€ ÷ Cñ Cá×'Ñ'ðCñ !×+Ñ+¨dÕ2ðCñ !&× 0Ñ 0°4Õ 7ð	Cñ
 ×#Ñ# dÕ*ðCñ ×(Ñ(¨4Õ/ðCñ ×(Ñ(¨4Õ/ðCñ #'ðCñ 
×	Ñ	ñCr   c                ó˜  € \        V R4      '       d   V P                  4        VP                  ^ ,          p	V P                  VVVVR7      p
V
P                  pVf¿   Vf¥   V P
                  P                  .V P
                  P                  ,          ^,          pWÀP
                  P                  P                  .,           p\        P                  ! V.\        P                  VP                  R7      pVP                  V	^4      pV P                  4       ! V4      pVf   \        P                   ! V4      pVP#                  VP                  VP$                  4      pV P'                  WFR7      pVP)                  Wë4      pRVRV/pV P*                  P
                  P,                  '       g   WOR&   V P*                  P.                  ! R/ VBVB pV# )	aA  
Overrides `generate` function to be able to use the model as a conditional generator.

Args:
    pixel_values (`torch.FloatTensor` of shape (batch_size, num_channels, height, width) or
        (batch_size, num_frames, num_channels, height, width)): Input images or videos to be processed.
    qformer_input_ids (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
        The sequence used as a prompt to be fed to the Q-Former module.
    qformer_attention_mask (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
        Mask to avoid performing attention on padding token indices.
    input_ids (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
        The sequence used as a prompt for the generation.
    attention_mask (`torch.LongTensor` of shape (batch_size, sequence_length), *optional*):
        Mask to avoid performing attention on padding token indices.
    inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
        Embedded representation of the inputs. Should be float, not int tokens.
    interpolate_pos_encoding (`bool`, *optional*, defaults to `False`):
        Whether to interpolate the positional encoding of the image embeddings.

Returns:
    captions (list): A list of strings of length batch_size * num_captions.
Úhf_device_map)rE   rF   rL   rX   r£   rK   rH   rG   r   )ÚhasattrÚ_preprocess_acceleratere   r–   r’   rs   r%   rt   r¨   Úbos_token_idrP   Útensorrj   rZ   Úrepeatrv   rm   ro   rY   rž   rz   ru   Úis_encoder_decoderÚgenerate)r|   rD   rE   rF   rG   rH   rK   rL   Úgenerate_kwargsr}   r•   r‡   Úvideo_tokensÚstart_tokensrˆ   Úinputsr‰   s   &&&&&&&&,        r   r³   Ú2InstructBlipVideoForConditionalGeneration.generateÔ  sœ  € ôD �4˜×)Ò)à×'Ñ'Ô)à!×'Ñ'¨Õ*ˆ
ØBF×BYÑBYØØ/Ø#9Ø%=ð	 CZó C
ˆð !/× <Ñ <ÐàÒ ØÒ Ø $§¡× =Ñ =Ð>ÀÇÁ×A]ÑA]Õ]Ð`aÕa�Ø+¯{©{×/FÑ/F×/SÑ/SÐ.TÕT�Ü!ŸLšL¨,¨¼u¿z¹zÐR^×ReÑReÔf�	Ø%×,Ñ,¨Z¸Ó;�	Ø ×5Ñ5Ô7¸	ÓBˆMàÒ!Ü"Ÿ_š_¨YÓ7ˆNà 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ!×6Ñ6°yÐ6Ó^ÐØ%×4Ñ4Ð5GÓ_ˆà! =Ð2BÀNÐSˆØ×"Ñ"×)Ñ)×<×<Ð<Ø"+�;Ñà×%Ñ%×.Ò.ÑK°ÐK¸?ÑKˆàˆr   r   )NF)	NNNNNNNFN)NNNNNF)r   r   r   r   r   r   r–   rš   rž   rŠ   rP   Úno_gradr³   r   r1   r2   s   @r   r�   r�   ñ   s   ø‡ € ØØ÷Dñ Dó ó ðDòL^÷"ð "ð Ø÷D
ñ D
ó ó ðD
ðL ‡]‚]ƒ_÷Cñ Có öCr   r�   )r#   r!   r   r:   r4   r<   rB   r�   )!rP   Úhuggingface_hub.dataclassesr   Ú;transformers.models.instructblip.configuration_instructblipr   r   r   Ú6transformers.models.instructblip.modeling_instructblipr   r   r	   r
   r   r   r   r   Úmodeling_outputsr   Úprocessing_utilsr   Úutilsr   r   r   r!   r#   r4   r:   r<   r@   rB   r�   Ú__all__r   r   r   Ú<module>rÁ      s  ðó  Ý .÷ñ ÷
	÷ 	ó 	õ ;Ý &ß 5ñ Ð?Ô@ØôÐ$<ó ó ó Aðñ$ Ð?Ô@ØôÐ%>ó ó ó Aðñ, Ð?Ô@Øô')Ð0ó ')ó ó Að')ôT)Ð'Bô )ôÐ#:ô ô	Ð$<ô 	ô	Ð;jô 	ô^
Ð.ô ^
ôBgÐ0Tô gòT		‚r   