Ë
    ÛÓ^jë_  ã                   ó°  — d dl Z d dlmZ d dlmZmZmZ d dlmZm	Z	m
Z
mZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ  ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z ed	¬
«      e G d„ de«      «       «       Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de
«      Z G d„ de«      Z G d„ de	«      Zg d¢Z y)é    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                   ó   — e Zd ZdZy)ÚInstructBlipVideoVisionConfigaH  
    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__Ú__doc__© ó    úŠ/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/instructblipvideo/modular_instructblipvideo.pyr   r   (   s   „ òr   r   c                   ó   — e Zd ZdZy)ÚInstructBlipVideoQFormerConfiga3  
    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
    ```Nr   r   r   r   r    r    <   s   „ òr   r    c                   ó<   — e Zd ZU dZddiZdZedz  ed<    e«       Z	y)Ú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_indexN)
r   r   r   r   Úattribute_mapr$   ÚintÚ__annotations__ÚAttributeErrorÚimage_token_indexr   r   r   r"   r"   T   s-   … ñ"ðH &Ð':Ð;€MØ$(Ð�s˜T‘zÓ(Ù&Ó(Ñr   r"   c                   ó   — e Zd ZdZy)Ú InstructBlipVideoPreTrainedModel)ÚvideoÚtextN©r   r   r   Úinput_modalitiesr   r   r   r+   r+   €   s   „ Ø(Ñr   r+   c                   ó   — e Zd ZdZy)ÚInstructBlipVideoVisionModelr,   Nr.   r   r   r   r1   r1   „   s   „ ØÑr   r1   c                   ó   — e Zd Zy)ÚInstructBlipVideoQFormerModelN©r   r   r   r   r   r   r3   r3   ˆ   ó   „ Ør   r3   c                   ó   — e Zd Zy)Ú4InstructBlipVideoForConditionalGenerationModelOutputNr4   r   r   r   r7   r7   Œ   r5   r   r7   c                   ó@  — e Zd Zee	 	 	 	 	 	 	 	 ddej                  dej                  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  d	ej                  dz  d
e	de	dz  de
e   deez  fd„«       «       Zy)ÚInstructBlipVideoModelNÚpixel_valuesÚqformer_input_idsÚqformer_attention_maskÚ	input_idsÚattention_maskÚdecoder_input_idsÚdecoder_attention_maskÚinputs_embedsÚinterpolate_pos_encodingÚ	use_cacheÚkwargsÚreturnc           	      ó�  — |j                   \  }}}}}|j                  ||z  |||«      } | j                  d||	dœ|¤Ž}|d   }t        j                  |j                  «       d d t        j                  |j                  ¬«      }| j                  j                  |j                   d   dd«      }t        j                  |j                  «       d d t        j                  |j                  ¬«      }|€t        j                  |«      }|j                  |d¬«      }|j                  |d¬«      }|j                  |j                  «      }t        j                  ||gd¬«      } | j                  d|||||dœ|¤Ž}|d   d d …d |j                  d«      …d d …f   }| j                  |«      }|j                  || j                   j"                  |z  d«      }|€Q | j$                  j'                  «       |«      }|| j                   j(                  k(  }|€‚t        j                  |«      }nl| | j'                  «       t        j*                  | j                   j(                  t        j                  |j                  ¬«      «      k(  }|j-                  d«      }|j/                  d«      j                  |j                  «      }|j                  |j                  |j0                  «      }|j3                  ||«      }| j                   j4                  r | j$                  d|||
dœ|¤Ž}n | j$                  d|||||
d	œ|¤Ž}t7        |||¬
«      S )N©r:   rB   r   éÿÿÿÿ©ÚdtypeÚdevice©Údimé   ©r=   r>   Úquery_embedsÚencoder_hidden_statesÚencoder_attention_mask©rA   r>   rC   )rA   r>   r?   r@   rC   )Úvision_outputsÚqformer_outputsÚlanguage_model_outputsr   )ÚshapeÚreshapeÚvision_modelÚtorchÚonesÚsizeÚlongrK   Úquery_tokensÚexpandÚ	ones_likeÚrepeat_interleaveÚtoÚcatÚqformerÚlanguage_projectionÚconfigÚnum_query_tokensÚlanguage_modelÚget_input_embeddingsr#   ÚtensorÚallÚ	unsqueezerJ   Úmasked_scatterÚuse_decoder_only_language_modelr7   )Úselfr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   Ú
batch_sizeÚframesÚchannelÚheightÚwidthrT   Úimage_embedsÚimage_attention_maskr^   Úquery_attention_maskÚquery_outputsÚquery_outputÚlanguage_model_inputsÚspecial_image_maskÚoutputss                              r   ÚforwardzInstructBlipVideoModel.forward‘   sl  € ð$ 6B×5GÑ5GÑ2ˆ
�F˜G V¨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Ø%Ø".Ø#7ñ
ð ñ
ˆð % QÑ'ªÐ+A¨\×->Ñ->¸qÓ-AÐ+AÂ1Ð(DÑEˆð !%× 8Ñ 8¸Ó FÐð !6× =Ñ =¸jÈ$Ï+É+×JfÑJfÐioÑJoÐqsÓ tÐØÐ ØF˜D×/Ñ/×DÑDÓFÀyÓQˆMØ!*¨d¯k©k×.HÑ.HÑ!HÐØÐ%Ü!&§¡°Ó!;‘à!.Ð2M°$×2KÑ2KÓ2MÜ—‘˜TŸ[™[×7Ñ7¼u¿z¹zÐR_×RfÑRfÔgó3ñ "Ðð "4×!7Ñ!7¸Ó!;Ðà/×9Ñ9¸"Ó=×@Ñ@À×AUÑAUÓVÐØ 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ%×4Ñ4Ð5GÐI^Ó_ˆà�;‰;×6Ò6Ø)�d×)Ñ)ð Ø+Ø-Ø#ñð ñ	‰Gð *�d×)Ñ)ð Ø+Ø-Ø"3Ø'=Ø#ñð ñˆGô DØ)Ø)Ø#*ô
ð 	
r   )NNNNNNFN)r   r   r   r   r   rZ   ÚFloatTensorÚ
LongTensorÚTensorÚboolr   r   Útupler7   r}   r   r   r   r9   r9   �   s  „ ØØð
 ;?Ø.2Ø26Ø59Ø:>Ø-1Ø).Ø!%ñ[
à×'Ñ'ð[
ð !×,Ñ,ð[
ð !&× 0Ñ 0°4Ñ 7ð	[
ð
 ×$Ñ$ tÑ+ð[
ð ×(Ñ(¨4Ñ/ð[
ð !×+Ñ+¨dÑ2ð[
ð !&× 0Ñ 0°4Ñ 7ð[
ð —|‘| dÑ*ð[
ð #'ð[
ð ˜$‘;ð[
ð Ð+Ñ,ð[
ð 
ÐEÑ	Eò[
ó ó ñ[
r   r9   c                   ó4  — e Zd Zee	 	 ddej                  dej                  dej                  dz  dedz  de	e
   deez  fd„«       «       Zd	„ Zd
ej                  dej                  fd„Zee	 	 	 	 	 	 	 	 	 ddej                  dej                  dej                  dz  d
ej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dededz  de	e
   deez  fd„«       «       Z ej$                  «       	 	 	 	 	 	 ddej                  dej                  dz  dej                  dz  d
ej                  dz  dej                  dz  dej                  dz  dedej                  fd„«       Zy)Ú)InstructBlipVideoForConditionalGenerationNr:   r;   r<   rB   rD   rE   c           	      ó:  — |j                   \  }}}}	}
|j                  ||z  ||	|
«      } | j                  d
||dœ|¤Ž}t        |j                  |j
                  |j                  |j                  |d¬«      }|d   }t        j                  |j                  «       dd t        j                  |j                  ¬«      }| j                  j                  |j                   d   dd«      }t        j                  |j                  «       dd t        j                  |j                  ¬«      }|€t        j                  |«      }|j!                  |d¬«      }|j!                  |d¬«      }|j#                  |j                  «      }t        j$                  ||gd¬«      } | j&                  d
|||||d	œ|¤Ž}||_        |d   dd…d|j                  d«      …dd…f   }| j+                  |«      }|j                  || j,                  j.                  |z  d«      }||_        |S )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.
        rG   N)Úlast_hidden_stateÚpooler_outputÚhidden_statesÚ
attentionsrT   rU   r   rH   rI   rL   rN   rO   r   )rW   rX   rY   r   r†   r‡   rˆ   r‰   rZ   r[   r\   r]   rK   r^   r_   r`   ra   rb   rc   rd   rU   re   rf   rg   )ro   r:   r;   r<   rB   rD   rp   rq   rr   rs   rt   rT   ru   rv   r^   rw   rU   ry   Úvideo_featuress                      r   Úget_video_featuresz<InstructBlipVideoForConditionalGeneration.get_video_featuresò   s@  € ð( 6B×5GÑ5GÑ2ˆ
�F˜G V¨UØ#×+Ñ+¨J¸Ñ,?ÀÈ&ÐRWÓXˆà5F°T×5FÑ5Fð 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ÐÜ!&§¡Ð,@ÐBXÐ+YÐ_`Ô!aÐØ&˜$Ÿ,™,ð 
Ø'Ø1Ø%Ø".Ø#7ñ
ð ñ
ˆð *9ˆÔ&Ø& qÑ)ª!Ð-C¨|×/@Ñ/@ÀÓ/CÐ-CÂQÐ*FÑGˆð ×1Ñ1°,Ó?ˆð (×/Ñ/°
¸D¿K¹K×<XÑ<XÐ[aÑ<aÐceÓfˆØ'5ˆÔ$àÐr   c                  ó   — t        d«      ‚)Nz=No need to inherit as this architecture only supports videos.)r(   )Úsuper_kwargss    r   Úget_image_featuresz<InstructBlipVideoForConditionalGeneration.get_image_features:  s   € ÜÐ\Ó]Ð]r   r=   rA   c                 ój  — |€m| | j                  «       t        j                  | j                  j                  t        j
                  |j                  ¬«      «      k(  }|j                  d«      }n|| j                  j                  k(  }|j                  d«      j                  |j                  «      }|S )zZ
        Obtains multimodal placeholder mask from `input_ids` or `inputs_embeds`.
        rI   rH   )
ri   rZ   rj   rf   r#   r]   rK   rk   rl   rb   )ro   r=   rA   r{   s       r   Úget_placeholder_maskz>InstructBlipVideoForConditionalGeneration.get_placeholder_mask=  s�   € ð ÐØ!.Ð2M°$×2KÑ2KÓ2MÜ—‘˜TŸ[™[×7Ñ7¼u¿z¹zÐR_×RfÑRfÔgó3ñ "Ðð "4×!7Ñ!7¸Ó!;Ñà!*¨d¯k©k×.HÑ.HÑ!HÐà/×9Ñ9¸"Ó=×@Ñ@À×AUÑAUÓVÐØ!Ð!r   r>   r?   r@   ÚlabelsrC   c           
      óÂ  —  | j                   |f|||
dœ|¤Ž}|j                  }|j                  }|j                  }|€ | j	                  «       |«      }|€t        j                  |«      }|j                  |j                  |j                  «      }| j                  ||¬«      }|j                  ||«      }| j                  j                  rT | j                  d	|||dœ|¤Ž}|d   }d}|	�f | j                  d	||	| j                  j                   j"                  dœ|¤Ž}n1 | j                  d	|||||	|dœ|¤Ž}|j$                  }|j&                  }t)        |||||¬«      S )
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 videWhy is this video funny?o
        >>> 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"
        ```©r;   r<   rB   N©rA   rS   r   )Úlogitsr‘   Ú
vocab_size)rA   r>   r?   r@   r‘   rC   )Úlossr•   rT   rU   rV   r   )r‹   r‡   rU   rT   ri   rZ   r`   rb   rK   rJ   r�   rm   rf   rn   rh   Úloss_functionÚtext_configr–   r—   r•   r7   )ro   r:   r;   r<   r=   r>   r?   r@   rA   r‘   rB   rC   rD   rŠ   rz   rU   rT   r{   r|   r•   r—   s                        r   r}   z1InstructBlipVideoForConditionalGeneration.forwardL  s¼  € ð` CZÀ$×BYÑBYØðC
à/Ø#9Ø%=ñ	C
ð
 ñC
ˆð !/× <Ñ <ÐØ(×8Ñ8ˆØ'×6Ñ6ˆàÐ Ø7˜D×5Ñ5Ó7¸	ÓBˆMàÐ!Ü"Ÿ_™_¨YÓ7ˆNà 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ!×6Ñ6°yÐP]Ð6Ó^ÐØ%×4Ñ4Ð5GÐI^Ó_ˆà�;‰;×6Ò6Ø)�d×)Ñ)ð Ø+Ø-Ø#ñð ñ	ˆGð ˜Q‘ZˆFØˆDØÐ!Ø)�t×)Ñ)ð Ø!¨&¸T¿[¹[×=TÑ=T×=_Ñ=_ñØciñ‘ð
 *�d×)Ñ)ð Ø+Ø-Ø"3Ø'=ØØ#ñð ñˆGð —<‘<ˆDØ—^‘^ˆFäCØØØ)Ø+Ø#*ô
ð 	
r   c                 óV  — t        | d«      r| j                  «        |j                  d   }	| j                  ||||¬«      }
|
j                  }|€°|€˜| j
                  j                  g| j
                  j                  z  dz  }|| j
                  j                  j                  gz   }t        j                  |gt        j                  |j                  ¬«      }|j                  |	d«      } | j                  «       |«      }|€t        j                   |«      }|j#                  |j                  |j$                  «      }| j'                  ||¬«      }|j)                  ||«      }||dœ}| j*                  j
                  j,                  s||d	<    | j*                  j.                  d
i |¤|¤Ž}|S )aÙ  
        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_mapr   r“   é   rI   rN   r”   )rA   r>   r=   r   )ÚhasattrÚ_preprocess_acceleraterW   r‹   r‡   rf   r$   rg   r™   Úbos_token_idrZ   rj   r]   rK   Úrepeatri   r`   rb   rJ   r�   rm   rh   Úis_encoder_decoderÚgenerate)ro   r:   r;   r<   r=   r>   rA   rB   Úgenerate_kwargsrp   rŠ   rz   Úvideo_tokensÚstart_tokensr{   Úinputsr|   s                    r   r¢   z2InstructBlipVideoForConditionalGeneration.generateÔ  sŸ  € ôD �4˜Ô)à×'Ñ'Ô)à!×'Ñ'¨Ñ*ˆ
ØBF×BYÑBYØØ/Ø#9Ø%=ð	 CZó C
ˆð !/× <Ñ <ÐàÐ ØÐ Ø $§¡× =Ñ =Ð>ÀÇÁ×A]ÑA]Ñ]Ð`aÑa�Ø+¨t¯{©{×/FÑ/F×/SÑ/SÐ.TÑT�Ü!ŸL™L¨,¨¼u¿z¹zÐR^×ReÑReÔf�	Ø%×,Ñ,¨Z¸Ó;�	Ø7˜D×5Ñ5Ó7¸	ÓBˆMàÐ!Ü"Ÿ_™_¨YÓ7ˆNà 5× 8Ñ 8¸×9MÑ9MÈ}×ObÑObÓ cÐØ!×6Ñ6°yÐP]Ð6Ó^ÐØ%×4Ñ4Ð5GÐI^Ó_ˆà#0ÀNÑSˆØ×"Ñ"×)Ñ)×<Ò<Ø"+ˆF�;Ñà.�$×%Ñ%×.Ñ.ÑK°ÐK¸?ÑKˆàˆr   )NF)	NNNNNNNFN)NNNNNF)r   r   r   r   r   rZ   r~   r   r�   r   r   r‚   r   r‹   rŽ   r�   r7   r}   Úno_gradr¢   r   r   r   r„   r„   ñ   s°  „ ØØð
 ;?Ø05ñDà×'Ñ'ðDð !×+Ñ+ðDð !&× 0Ñ 0°4Ñ 7ð	Dð
 #'¨¡+ðDð Ð+Ñ,ðDð 
Ð8Ñ	8òDó ó ðDòL^ð"¨e×.>Ñ.>ð "Èu×O`ÑO`ó "ð Øð
 ;?Ø.2Ø26Ø59Ø:>Ø26Ø*.Ø).Ø!%ñ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
ó ó ðD
ðL €U‡]�]ƒ_ð 6:Ø:>Ø-1Ø26Ø26Ø).ñCà×'Ñ'ðCð !×+Ñ+¨dÑ2ðCð !&× 0Ñ 0°4Ñ 7ð	Cð
 ×#Ñ# dÑ*ðCð ×(Ñ(¨4Ñ/ðCð ×(Ñ(¨4Ñ/ðCð #'ðCð 
×	Ñ	òCó ñCr   r„   )r"   r    r   r1   r+   r3   r9   r„   )!rZ   Ú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"   r+   r1   r3   r7   r9   r„   Ú__all__r   r   r   ú<module>r¯      s  ðó  Ý .÷ñ ÷
	÷ 	ó 	õ ;Ý &ß 5ñ Ð?Ô@ØôÐ$<ó ó ó Aðñ$ Ð?Ô@ØôÐ%>ó ó ó Aðñ, Ð?Ô@Øô')Ð0ó ')ó ó Að')ôT)Ð'Bô )ôÐ#:ô ô	Ð$<ô 	ô	Ð;jô 	ô^
Ð.ô ^
ôBgÐ0Tô gòT		�r   