
    gw                     >   d Z ddlmZ ddlmZmZmZmZ ddlZddl	Zddlm
Z
 ddlmZmZ ddlmZ dd	lmZ dd
lmZmZmZmZmZmZ ddlmZ  e            r
ddlmZmZmZ ddlm Z m!Z!  ej"        e#          Z$dZ%	 	 d)dej&        de'de'dej(        dej)        de*dej&        de'de+dej&        fdZ,e G d de                      Z- G d d e
j.                  Z/d!Z0 ed"e0           G d# d$e                      Z1d%Z2 ed&e0           G d' d(e1e                      Z3dS )*zPyTorch PaliGemmamodel.    )	dataclass)ListOptionalTupleUnionN)nn   )CacheStaticCache)GenerationMixin)PreTrainedModel)ModelOutputadd_start_docstrings%add_start_docstrings_to_model_forwardis_flash_attn_2_availableloggingreplace_return_docstrings   )PaliGemmaConfig)index_first_axis	pad_inputunpad_input   )	AutoModelAutoModelForCausalLMr   Fattention_masksequence_lengthtarget_lengthdtypedevice	min_dtypecache_position
batch_sizeis_trainingtoken_type_idsc
                    | |                                  dk    r| }nt          j        ||f|||          }|dk    r$|rt          j        |d          }nd|ddd|f<   |t          j        ||j                  |                    dd          k    z  }|ddddddf                             |ddd          }| |                                }| j	        d         }|ddddddd|f         | ddddddf         
                    |j                  z   }|d	k    }|ddddddd|f                             ||          |ddddddd|f<   |ra|ddddddd|f                             |	ddddddf         
                    |j                  d	k    d	          |ddddddd|f<   |S )
aR  
    Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
    `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.

    Args:
        attention_mask (`torch.Tensor`):
            A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape `(batch_size, 1, query_length, key_value_length)`.
        sequence_length (`int`):
            The sequence length being processed.
        target_length (`int`):
            The target length: when generating with static cache, the mask should be as long as the static cache, to account for the 0 padding, the part of the cache that is not filled yet.
        dtype (`torch.dtype`):
            The dtype to use for the 4D attention mask.
        device (`torch.device`):
            The device to plcae the 4D attention mask on.
        min_dtype (`float`):
            The minimum value representable with the dtype `dtype`.
        cache_position (`torch.Tensor`):
            Indices depicting the position of the input sequence tokens in the sequence.
        batch_size (`torch.Tensor`):
            Batch size.
        is_training (`bool`):
            Whether the model is in training mode or in inference. The condition is checked by presence/absence of `token_type_ids/labels`
    N   
fill_valuer   r    r   diagonal        r    r   )dimtorchfulltriuaranger    reshapeexpandcloneshapetomasked_fill)r   r   r   r   r    r!   r"   r#   r$   r%   kwargscausal_maskmask_lengthpadding_masks                 l/var/www/html/ai-engine/env/lib/python3.11/site-packages/transformers/models/paligemma/modeling_paligemma.py5_prepare_4d_causal_attention_mask_with_cache_positionr?   3   sZ   J !n&8&8&:&:a&?&?$j/=!Ai_dmsttta 7#jqAAA36AAA///0u|M.:OPPPSaSiSijlnoSpSppp!$aaa"23:::q"bQQ%%++--K(.r2K&qqq!!!QQQ'<=qqqRVX\^_^_^_O_@`@c@cdodv@w@wwL'1,L1<QQQ111l{l=R1S1_1_i2 2K111aaa+-.  5@AAAqqq,;,AV5W5c5c"111dD!!!#34778JKKqPRS6 6AAAqqq!!!\k\12     c                      e Zd ZU dZdZeej                 ed<   dZ	ej        ed<   dZ
eeeej                 ef                  ed<   dZeeej                          ed<   dZeeej                          ed<   dZeej                 ed<   dS )	PaliGemmaCausalLMOutputWithPasta  
    Base class for PaliGemmacausal 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.text_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 (`torch.FloatTensor`, *optional*):
            A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
            image_hidden_states of the model produced by the vision encoder after projecting last hidden state.
    Nlosslogitspast_key_valueshidden_states
attentionsimage_hidden_states)__name__
__module____qualname____doc__rC   r   r0   FloatTensor__annotations__rD   rE   r   r   r
   rF   r   rG   rH    r@   r>   rB   rB   v   s          < )-D(5$
%,,, $FE$$$GKOXeD):$;U$BCDKKK8<M8E%"345<<<59Ju0129997;%"34;;;;;r@   rB   c                   *     e Zd Zdef fdZd Z xZS )PaliGemmaMultiModalProjectorconfigc                     t                                                       t          j        |j        j        |j        j        d          | _        d S )NT)bias)super__init__r   Linearvision_confighidden_sizeprojection_dimlinear)selfrR   	__class__s     r>   rV   z%PaliGemmaMultiModalProjector.__init__   sB    i 4 @&BVBelpqqqr@   c                 0    |                      |          }|S N)r[   )r\   image_featuresrF   s      r>   forwardz$PaliGemmaMultiModalProjector.forward   s    N33r@   )rI   rJ   rK   r   rV   ra   __classcell__r]   s   @r>   rQ   rQ      sZ        r r r r r r r      r@   rQ   ak  
    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 ([`PaliGemmaConfig`] or [`PaliGemmaVisionConfig`]):
            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.
zSThe bare LLaMA Model outputting raw hidden-states without any specific head on top.c                   B    e Zd ZeZdZdZdgZdZdZ	dZ
dZdZ	dZdZd ZdS )PaliGemmaPreTrainedModelmodelTrQ   rE   c                    t          | j        d          r| j        j        n| j        j        j        }t          |d          r!|j        j                            d|           t          |t          j	        t          j
        f          rJ|j        j                            d|           |j         |j        j                                         d S d S t          |t          j                  rS|j        j                            d|           |j        -|j        j        |j                                                  d S d S d S )Ninitializer_rangeclass_embeddingr,   )meanstd)hasattrrR   rh   text_configri   datanormal_
isinstancer   rW   Conv2dweightrT   zero_	Embeddingpadding_idx)r\   modulerk   s      r>   _init_weightsz&PaliGemmaPreTrainedModel._init_weights   s>   
 t{$788;DK))(: 	 6,-- 	C"'//Sc/BBBfry")455 	?M&&CS&999{& &&((((( '&-- 	?M&&CS&999!-"6#56<<>>>>>	? 	?--r@   N)rI   rJ   rK   r   config_classbase_model_prefixsupports_gradient_checkpointing_no_split_modules_skip_keys_device_placement_supports_cache_class_supports_quantized_cache_supports_static_cache_supports_flash_attn_2_supports_sdparw   rO   r@   r>   re   re      sh        
 #L&*#78"3  $! !N? ? ? ? ?r@   re   a0  
    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)
        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 [`SiglipImageProcessor.__call__`] for details ([]`PaliGemmaProcessor`] uses
            [`SiglipImageProcessor`] for processing images).
        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.
        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.
zMThe PALIGEMMA model which consists of a vision backbone and a language model.c            #       B    e Zd Zdef fdZd Zd Zd Zd Zd Z	d Z
d	 Z	 d#defdZdej        fdZ ee           eee          	 	 	 	 	 	 	 	 	 	 	 	 	 	 d$dej        dej        deej                 deej                 deeeej                 ef                  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deeef         fd                         Z	 	 	 	 	 	 	 	 	 d%d"Z xZ S )&!PaliGemmaForConditionalGenerationrR   c                    t                                          |           t          j        |j                  | _        t          |          | _        |j        j	        | _	        t          j        |j                  }|j        d |j        D             | _        || _        | j        j        | j        j        nd| _        |                                  d S )N)rR   c                     g | ]}d | S )zlanguage_model.rO   ).0ks     r>   
<listcomp>z>PaliGemmaForConditionalGeneration.__init__.<locals>.<listcomp>5  s!    &h&h&h'<'<'<&h&h&hr@   r.   )rU   rV   r   from_configrX   vision_towerrQ   multi_modal_projectorrm   
vocab_sizer   _tied_weights_keyslanguage_modelrR   pad_token_id	post_init)r\   rR   r   r]   s      r>   rV   z*PaliGemmaForConditionalGeneration.__init__,  s       %19MNNN%A&%I%I" ,7-9ASTTT,8&h&hnFg&h&h&hD#,8<8P8\DK44bdr@   c                 4    | j                                         S r_   )r   get_input_embeddingsr\   s    r>   r   z6PaliGemmaForConditionalGeneration.get_input_embeddings<  s    "77999r@   c                 :    | j                             |           d S r_   )r   set_input_embeddings)r\   values     r>   r   z6PaliGemmaForConditionalGeneration.set_input_embeddings@  s    0077777r@   c                 4    | j                                         S r_   )r   get_output_embeddingsr   s    r>   r   z7PaliGemmaForConditionalGeneration.get_output_embeddingsD  s    "88:::r@   c                 :    | j                             |           d S r_   )r   set_output_embeddings)r\   new_embeddingss     r>   r   z7PaliGemmaForConditionalGeneration.set_output_embeddingsH  s    11.AAAAAr@   c                 :    | j                             |           d S r_   )r   set_decoder)r\   decoders     r>   r   z-PaliGemmaForConditionalGeneration.set_decoderL  s    ''00000r@   c                 4    | j                                         S r_   )r   get_decoderr   s    r>   r   z-PaliGemmaForConditionalGeneration.get_decoderP      "..000r@   c                 4    | j                                         S r_   )r   tie_weightsr   s    r>   r   z-PaliGemmaForConditionalGeneration.tie_weightsT  r   r@   Fr$   c                    | j         j        j        dk    r
|d|v r|S d S t          |t                    }|j        }t          j        |          j        }	|j	        d         }
|r|
                                }n5t          |t          j                  r|j	        d         n|d         |
z   dz   }||                                dk    r|S t          j        |
|f|	||j                  }|
dk    r$|rt          j        |d          }nd|d d d |
f<   |t          j        ||j        	          |                    dd          k    z  }|d d d d d d f                             |j	        d         ddd          }||                                }|j	        d         }|d d d d d d d |f         |d d d d d d f                             |j                  z   }|dk    }|d d d d d d d |f                             ||	          |d d d d d d d |f<   |ra|d d d d d d d |f                             |d d d d d d f                             |j                  dk    d          |d d d d d d d |f<   |S )
Nflash_attention_2r,   r   r.   r   r'   r(   r*   r-   )rR   rm   _attn_implementationrp   r   r   r0   finfominr7   get_max_lengthTensorr/   r1   r    r2   r3   r4   r5   r6   r8   r9   )r\   r   r%   inputs_embedsrE   r"   r$   using_static_cacher   r!   r   r   r;   r<   r=   s                  r>   _update_causal_maskz5PaliGemmaForConditionalGeneration._update_causal_maskW  s+    ;"7;NNN)c^.C.C%%4'EE#K&&*	'-a0 	+::<<MM nel;;=$R((#A&81<  %.*<*<*>*>!*C*C!!jm,%XfXm
 
 
 a 7#jqAAA36AAA///0u|M.:OPPPSaSiSijlnoSpSppp!$aaa"23::=;Nq;QSTVXZ\]]%%++--K(.r2K&qqq!!!QQQ'<=qqqRVX\^_^_^_O_@`@c@cdodv@w@wwL'1,L1<QQQ111l{l=R1S1_1_i2 2K111aaa+-.  5@AAAqqq,;,AV5W5c5c"111dD!!!#34778JKKqPRS6 6AAAqqq!!!\k\12 r@   pixel_valuesc                     |                      |          }|j        }|                     |          }|| j        j        dz  z  }|S )a  
        Obtains image last hidden states from the vision tower and apply multimodal projection.

        Args:
            pixel_values (`torch.FloatTensor]` of shape `(batch_size, channels, height, width)`)
               The tensors corresponding to the input images.
        Returns:
            image_features (`torch.Tensor`): Image feature tensor of shape `(num_images, image_length, embed_dim)`).
        g      ?)r   last_hidden_stater   rR   rY   )r\   r   image_outputsselected_image_featurer`   s        r>   get_image_featuresz4PaliGemmaForConditionalGeneration.get_image_features  sN     )),77!.!@334JKK'4;+BC+GHr@   )output_typerx   Nr   	input_idsr   position_idsrE   r%   r"   r   labels	use_cacheoutput_attentionsoutput_hidden_statesreturn_dictnum_logits_to_keepreturnc                 ~   |du |duz  rt          d          ||t          d          ||n| j        j        }||n| j        j        }||n| j        j        }|duo|	du}| |                                 |          }|B||                                nd}t          j        |||j	        d         z   |j
                  }||                    d          dz   }||                     |          }|| j        j        k                        d          }|                    |                              |j
                  }||                                         |                                k    rQt          j        || j        j        k              }t          d| d	|j	        d         |j	        d         z   d
          |                    |j
        |j                  }|                    ||          }|	M| j        |	v rDt*                              dd           t          j        || j        k    | j        j        |	          }	|                     ||||||          }|                     |||||
|||||
  
        }|j        }d}|	i|                                }|dddddf         }|	dddf         }||dd|j	        d          df                             |j
                  }||                    |j
                  dk                                             }||                    |j
                  dk                                             }n(|                                }|                                }t=          j                    }|                     d| j        j!        j"                  }|                     d                              |j
                  } |||          }|s|f|dd         z   }||f|z   n|S tG          |||j$        |j%        |j&        ||nd          S )aC  
        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.text_config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
                (masked), the loss is only computed for the tokens with labels in `[0, ..., config.text_config.vocab_size]`.

            num_logits_to_keep (`int`, *optional*):
                Calculate logits for the last `num_logits_to_keep` tokens. If `0`, calculate logits for all
                `input_ids` (special case). Only last token logits are needed for generation, and calculating them only for that
                token can save memory, which becomes pretty significant for long sequences or large vocabulary size.

        Returns:

        Example:

        ```python
        >>> from PIL import Image
        >>> import requests
        >>> from transformers import AutoProcessor, PaliGemmaForConditionalGeneration

        >>> model = PaliGemmaForConditionalGeneration.from_pretrained("google/PaliGemma-test-224px-hf")
        >>> processor = AutoProcessor.from_pretrained("google/PaliGemma-test-224px-hf")

        >>> prompt = "answer en Where is the cow standing?"
        >>> url = "https://huggingface.co/gv-hf/PaliGemma-test-224px-hf/resolve/main/cow_beach_1.png"
        >>> image = Image.open(requests.get(url, stream=True).raw)

        >>> inputs = processor(images=image, text=prompt,  return_tensors="pt")

        >>> # Generate
        >>> generate_ids = model.generate(**inputs, max_length=30)
        >>> processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
        "answer en Where is the cow standing?\nbeach"
        ```Nz:You must specify exactly one of input_ids or inputs_embedszdYou cannot specify both pixel_values and inputs_embeds at the same time, and must specify either oner   r   r-   r.   zVNumber of images does not match number of special image tokens in the input text. Got z image tokens in the text but z tokens from image embeddings.zR`labels` contains `pad_token_id` which will be masked with `config.ignore_index`. zeYou have to mask out `pad_token_id` when preparing `labels`, this behavior will be removed in v.4.46.)
r   r   rE   r   r   r   r   r   r"   r   .)rC   rD   rE   rF   rG   rH   )'
ValueErrorrR   r   r   use_return_dictr   get_seq_lengthr0   r3   r7   r    	unsqueezer   image_token_index	expand_asr8   numelsumr   masked_scatterr   loggerwarning_oncewhereignore_indexr   r   rD   float
contiguousr   CrossEntropyLossviewrm   r   rB   rE   rF   rG   )r\   r   r   r   r   rE   r%   r"   r   r   r   r   r   r   r   r$   past_seen_tokensr`   special_image_maskimage_tokens_in_textr;   outputsrD   rC   shift_logitsshift_labelsshift_attention_maskloss_fctflat_logitsflat_labelsoutputs                                  r>   ra   z)PaliGemmaForConditionalGeneration.forward  s   n -t";< 	[YZZZ#(Av   2C1N--TXT_Tq$8$D  $+Jj 	 &1%<kk$+B]$D0GV45G 7D5577	BBM!CRC^==???de"\ "2]5H5K"KTaTh  N )33A66:L #!44\BBN"+t{/L"L!W!WXZ![![!3!=!=m!L!L!O!OP]Pd!e!e/06688N<P<P<R<RRR',ydk>[1['\'\$ 4/4 4O]OcdeOfiwi}~  jA  PA4 4 4  
 ,..}/C]EXYYN)889K^\\M $"3v"="=dw   [d.?!?AY[abbF..NM?N\g
 
 %%&%+'/!5#)1 & 
 
 \\^^F!#ssAAA+.L!#qrr'?L) (6aaa,:LQ:O9O9Q9Q6Q'R'U'UV\Vc'd'd$+,@,C,CFM,R,RVW,WXccee+,@,C,CLDW,X,X\],]^iikk+6688+6688*,,H&++B0G0RSSK&++B//22<3FGGK8K55D 	DY,F'+'7D7V##VC.#3!/)2>2JPT
 
 
 	
r@   Tc                      | j         j        |f||||||	|
|d|}|                    d          |dxx         dz  cc<   |d         dk    r||d<   |S )N)rE   r   r   r   r"   r   r   r%   r   r   r   r   )r   prepare_inputs_for_generationget)r\   r   rE   r   r"   r   r   r   r%   r   r   r:   model_inputss                r>   r   z?PaliGemmaForConditionalGeneration.prepare_inputs_for_generation:  s     It*H
+')%)1)
 
 
 
 N++7(((A-((( !!!+7L(r@   )F)NNNNNNNNNNNNNr   )	NNNNNNNTN)!rI   rJ   rK   r   rV   r   r   r   r   r   r   r   boolr   r0   rM   r   r   PALIGEMMA_INPUTS_DOCSTRINGr   rB   _CONFIG_FOR_DOC
LongTensorr   r   r   r   r
   intr   ra   r   rb   rc   s   @r>   r   r   '  s       
       : : :8 8 8; ; ;B B B1 1 11 1 11 1 1 sx2 2ko2 2 2 2hu/@      +*+EFF+JYhiii '+*.1537KO595959-1$(,0/3&*"#[
 [
#[
 '[
 !.	[

 u/0[
 "%U->(?(F"GH[
 !!12[
 !!12[
   12[
 )*[
 D>[
 $D>[
 'tn[
 d^[
  [
  
u55	6![
 [
 [
 ji GF[
@ % % % % % % % %r@   r   )FN)4rL   dataclassesr   typingr   r   r   r   r0   torch.utils.checkpointr   cache_utilsr
   r   
generationr   modeling_utilsr   utilsr   r   r   r   r   r   configuration_paligemmar   flash_attn.bert_paddingr   r   r   autor   r   
get_loggerrI   r   r   r   r   r   r    r   r   r?   rB   ModulerQ   PALIGEMMA_START_DOCSTRINGre   r   r   rO   r@   r>   <module>r      s-     ! ! ! ! ! ! / / / / / / / / / / / /            - - - - - - - - ) ) ) ) ) ) - - - - - -                5 4 4 4 4 4  QPPPPPPPPPP 2 2 2 2 2 2 2 2 
	H	%	%# #'@ @L@@ @ ;	@
 L@ @ L@ @ @ L@ @ @ @F $< $< $< $< $<k $< $< $<N    29    " Y  ?  ?  ?  ?  ?  ?  ?	  ?FC L W t t t t t(@/ t t	 t t tr@   