
    sg~                        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 ddlmZ dd	lmZ dd
lmZ ddlmZmZmZmZ ddlmZmZ ddlmZ  ej:                  e      ZdZ dZ!e G d de             Z" G d de
jF                        Z$dZ% ede%       G d de             Z&dZ' ede%       G d de&e             Z(y)zPyTorch Llava model.    )	dataclass)ListOptionalTupleUnionN)nn   )ACT2FN)GenerationMixin)ModelOutput)PreTrainedModel)add_start_docstrings%add_start_docstrings_to_model_forwardloggingreplace_return_docstrings   )	AutoModelAutoModelForCausalLM   )LlavaConfigr   zllava-hf/llava-1.5-7b-hfc                      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j                        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<   y)	LlavaCausalLMOutputWithPasta  
    Base class for Llava 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 (`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 and after projecting the last hidden state.
    Nlosslogitspast_key_valueshidden_states
attentionsimage_hidden_states)__name__
__module____qualname____doc__r   r   torchFloatTensor__annotations__r   r   r   r   r   r   r        [/var/www/html/venv/lib/python3.12/site-packages/transformers/models/llava/modeling_llava.pyr   r   .   s    < )-D(5$$
%, $FE$9=OXd5#4#456=8<M8E%"3"345<59Ju001297;%"3"34;r'   r   c                   *     e Zd Zdef fdZd Z xZS )LlavaMultiModalProjectorconfigc                 f   t         |           t        j                  |j                  j
                  |j                  j
                  d      | _        t        |j                     | _
        t        j                  |j                  j
                  |j                  j
                  d      | _        y )NT)bias)super__init__r   Linearvision_confighidden_sizetext_configlinear_1r
   projector_hidden_actactlinear_2selfr+   	__class__s     r(   r/   z!LlavaMultiModalProjector.__init__W   sz    		&"6"6"B"BFDVDVDbDbimn&556		&"4"4"@"@&BTBTB`B`gklr'   c                 l    | j                  |      }| j                  |      }| j                  |      }|S N)r4   r6   r7   )r9   image_featuresr   s      r(   forwardz LlavaMultiModalProjector.forward^   s2    n5/m4r'   )r   r    r!   r   r/   r>   __classcell__r:   s   @r(   r*   r*   V   s    m{ mr'   r*   ac  
    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 ([`LlavaConfig`] or [`LlavaVisionConfig`]):
            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                   4    e Zd ZeZdZdZdgZdZdZ	dZ
dZd Zy)LlavaPreTrainedModelmodelTLlavaVisionAttentionr   c                    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_embeddingg        )meanstd)hasattrr+   rF   r3   rG   datanormal_
isinstancer   r0   Conv2dweightr-   zero_	Embeddingpadding_idx)r9   modulerI   s      r(   _init_weightsz"LlavaPreTrainedModel._init_weights   s!    t{{$78 KK))((:: 	 6,-""''//Sc/Bfryy"))45MM&&CS&9{{&  &&( '-MM&&CS&9!!-""6#5#56<<> . .r'   N)r   r    r!   r   config_classbase_model_prefixsupports_gradient_checkpointing_no_split_modules_skip_keys_device_placement_supports_cache_class_supports_flash_attn_2_supports_sdparT   r&   r'   r(   rB   rB   v   s:    
 L&*#/0"3 !N?r'   rB   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)
        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).
        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.
        vision_feature_layer (`int`, *optional*, defaults to -2):
            The index of the layer to select the vision feature.
        vision_feature_select_strategy (`str`, *optional*, defaults to `"default"`):
            The feature selection strategy used to select the vision feature from the vision backbone.
            Can be one of `"default"` or `"full"`.
        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.
zIThe LLAVA model which consists of a vision backbone and a language model.c            %       L    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e   dej                  fdZdej$                  dedefdZd Z ee       eee      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dej6                  dej$                  deej8                     deej6                     deeej$                        deej$                     dee   dee   deej6                     dee   dee   dee   dee   deej6                     dedee ef   f d              Z!	 	 	 	 	 	 d#d Z" xZ#S )$LlavaForConditionalGenerationr+   c                    t         |   |       t        j                  |j                        | _        t        |      | _        |j                  j                  | _	        t        j                  |j                        | _        | j                  j                  | j                  j                  nd| _        | j                          y )N)r.   r/   r   from_configr1   vision_towerr*   multi_modal_projectorr3   
vocab_sizer   language_modelr+   pad_token_id	post_initr8   s     r(   r/   z&LlavaForConditionalGeneration.__init__   s     %11&2F2FG%=f%E" ,,772>>v?Q?QR8<8P8P8\DKK44bdr'   c                 6    | j                   j                         S r<   )re   get_input_embeddingsr9   s    r(   ri   z2LlavaForConditionalGeneration.get_input_embeddings   s    ""7799r'   c                 :    | j                   j                  |       y r<   )re   set_input_embeddings)r9   values     r(   rl   z2LlavaForConditionalGeneration.set_input_embeddings   s    007r'   c                 6    | j                   j                         S r<   )re   get_output_embeddingsrj   s    r(   ro   z3LlavaForConditionalGeneration.get_output_embeddings   s    ""88::r'   c                 :    | j                   j                  |       y r<   )re   set_output_embeddings)r9   new_embeddingss     r(   rq   z3LlavaForConditionalGeneration.set_output_embeddings   s    11.Ar'   c                 :    | j                   j                  |       y r<   )re   set_decoder)r9   decoders     r(   rt   z)LlavaForConditionalGeneration.set_decoder  s    ''0r'   c                 6    | j                   j                         S r<   )re   get_decoderrj   s    r(   rw   z)LlavaForConditionalGeneration.get_decoder      ""..00r'   c                 6    | j                   j                         S r<   )re   tie_weightsrj   s    r(   rz   z)LlavaForConditionalGeneration.tie_weights  rx   r'   new_num_tokensreturnc                     | j                   j                  ||      }|j                  | j                  j                  _        |j                  | _        |S r<   )re   resize_token_embeddingsnum_embeddingsr+   r3   rd   )r9   r{   pad_to_multiple_ofmodel_embedss       r(   r~   z5LlavaForConditionalGeneration.resize_token_embeddings
  sF    **BB>Sef-9-H-H*&55r'   pixel_valuesvision_feature_layervision_feature_select_strategyc                     | j                  |d      }|j                  |   }|dk(  r|ddddf   }n*|dk(  r|}n"t        d| j                  j                         | j                  |      }|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.
            vision_feature_layer (`int`):
                The index of the layer to select the vision feature.
            vision_feature_select_strategy (`str`):
                The feature selection strategy used to select the vision feature from the vision backbone.
                Can be one of `"default"` or `"full"`
        Returns:
            image_features (`torch.Tensor`): Image feature tensor of shape `(num_images, image_length, embed_dim)`).
        T)output_hidden_statesdefaultNr   fullz$Unexpected select feature strategy: )rb   r   
ValueErrorr+   r   rc   )r9   r   r   r   image_outputsselected_image_featurer=   s          r(   get_image_featuresz0LlavaForConditionalGeneration.get_image_features  s    " )),T)R!.!<!<=Q!R)Y6%;AqrE%B"+v5%;"CDKKDnDnCopqq334JKr'   c                    |j                   \  }}}|j                   \  }	}
t        j                  |d d df   t        j                  | j                        k(         }|| j
                  j                  k(  }t        j                  |d      }|j                         |dz
  z  |
z   }t        j                  || j
                  j                  k7        \  }}t        j                  ||dz
  z  dz   d      dz
  }|dz
  |d d df   z
  }|r||d d d f   z  }|||f   }t        j                  |	|||j                  |j                        }t        j                  |	||j                  |j                        }|Ct        j                  |	|f| j
                  j                  |j                  |j                        }|j                  }|j                  |      |j                  |      |j                  |      }}}|j                  |      }|||f   |||f<   |||f   |||f<   ||||f   ||f<   t        j                  |	|fdt        j                   |j                        }d|||f<   |r1||j                  d      dz
  |d d d f   j                  |      k\  z  }nYt        j"                  |t        j                         j                  d      dz
  }||d d dd f   j                  |      k  }||z  }|j                         |j                   d d j%                         k7  r%t'        dt        j                  |       d	| d
      |j)                         j+                  d|      j                  |      ||<   ||z  }|j                  d      dz
  j-                  |dk(  d      }t        j                  || j                  k(        \  }}|||f   }d|||f<   |d }|||fS )Nr`   dimr   dtypedeviceTF)r   zIThe input provided to the model are wrong. The number of image tokens is z1 while the number of image given to the model is z=. This prevents correct indexing and breaks batch generation.r   )shaper#   sumtensorrf   r+   image_token_indexmaxwherecumsumzerosr   r   r   ignore_indextobool	ones_likenumelr   
contiguousreshapemasked_fill_)r9   r=   inputs_embeds	input_idsattention_masklabels
num_imagesnum_image_patches	embed_dim
batch_sizesequence_lengthleft_paddingspecial_image_token_masknum_special_image_tokensmax_embed_dimbatch_indicesnon_image_indicesnew_token_positionsnb_image_padtext_to_overwritefinal_embeddingfinal_attention_maskfinal_labelstarget_deviceimage_to_overwritemaskpadding_maskposition_idspad_indicesindices_to_masks                                 r(   $_merge_input_ids_with_image_featureszBLlavaForConditionalGeneration._merge_input_ids_with_image_features.  sO   3A3G3G0
%y&/oo#
O 99Yq"u%5dFWFW9X%XYY#,0M0M#M #(99-E2#N 1557;Lq;PQUdd+0;;yDKKDaDa7a+b(( $ll,DHY\]H],^ab,beghkll$q(+>q"u+EE<4#88/?P0PQ  ++y8K8KTaThTh
  %{{^-A-A-J^J^ 
  ::]+T[[-E-EY__eneueuL
 &,,]+  /  / +<(
 (**=9 =J-YjJj<k'889AOP]_pPpAq],==>=CMSdDd=eL(99: #ZZ'UZZH\H\
 @E=*;;<"4";";B"?!"C|TUW[T[G\G_G_`mGn"nn??#5UZZHOOPRSVWWD#6q"#v#>#A#A-#PPL,.!!#~';';CR'@'F'F'HH[\a\e\ef~\  \A A>>H\  JGH 
 /=.G.G.I.Q.QRTV_.`.c.cdq.r*+ 22,33B7!;IIK_cdKdghi &+[[d>O>O1O%P"{-m[.HI:;67>L 4lLPPr'   )output_typerU   r   r   r   r   r   r   	use_cacheoutput_attentionsr   return_dictcache_positionnum_logits_to_keepc                 >   ||n| j                   j                  }||n| j                   j                  }||n| j                   j                  }||n| j                   j                  }||n| j                   j
                  }|du |duz  rt        d      ||t        d      d}|} | j                         |      }|| j                   j                  k(  j                  d      j                         | j                   j                  k  xs |j                  d   dk(  xr |du}d}|| j                  |||      }|rt        j                  d       |j                  d   dk7  rJ| j!                  |||||	      \  }}}	}t#        j$                  |j                  d   |j&                  	      }n>|d
   d
   ddddddd
f   }t#        j(                  |j+                         j                  d      d
k(        \  }}|j                  d   }|j                  d   }t#        j,                  |j                  d
   |f|j.                  |j&                        }||j1                  d      k  }||   }||   }d
|||f<   t#        j2                  ||dd| df   fd      }t#        j                  |d      j5                  d      dz
  }t#        j$                  |j                  d   |j&                  	      | d }n||| j                   j                  k(  j                         j7                         }|j                  d
   |j                  d   z  }||k7  rt        d| d|       || j                   j                  k(  j5                  d      j9                  |      j;                  |j&                        }|j;                  |j&                  |j.                        }|j=                  ||      }| j?                  |||||
|||||
      }|d
   }d} |	<||dd|j                  d   dz
   df   j;                  |j&                        }!|dddddf   |!j;                  |j&                        d
k7     jA                         }"|	dddf   |!j;                  |	j&                        d
k7     jA                         }#n1|dddddf   jA                         }"|	dddf   jA                         }#tC        jD                         }$ |$|"jG                  d|"j1                  d            |#jG                  d      j;                  |"j&                              } |s|f|dd z   }%| | f|%z   S |%S tI        | ||jJ                  |jL                  |jN                  ||      S d      S )ah  
        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 -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.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, LlavaForConditionalGeneration

        >>> model = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-7b-hf")
        >>> processor = AutoProcessor.from_pretrained("llava-hf/llava-1.5-7b-hf")

        >>> prompt = "USER: <image>\nWhat's the content of the image? ASSISTANT:"
        >>> url = "https://www.ilankelman.org/stopsigns/australia.jpg"
        >>> 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_new_tokens=15)
        >>> processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
        "USER:  \nWhat's the content of the image? ASSISTANT: The image features a busy city street with a stop sign prominently displayed"
        ```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 oneFr   r`   )r   r   r   a  Expanding inputs for image tokens in LLaVa should be done in processing. Please add `patch_size` and `vision_feature_select_strategy` to the model's processing config or set directly with `processor.patch_size = {{patch_size}}` and processor.vision_feature_select_strategy = {{vision_feature_select_strategy}}`. Using processors without these attributes in the config is deprecated and will throw an error in v4.50.)r   r   r   r   z6Image features and image tokens do not match: tokens: z, features )
r   r   r   r   r   r   r   r   r   r   .)r   r   r   r   r   r   )(r+   r   r   use_return_dictr   r   r   ri   r   r   r   image_seq_lengthr   r   loggerwarning_oncer   r#   aranger   r   floatonesr   sizecat	unsqueezeitem	expand_asr   masked_scatterre   r   r   CrossEntropyLossviewr   r   r   r   )&r9   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   legacy_processingr=   first_layer_past_key_valuebatch_indexnon_attended_tokenstarget_lengthpast_lengthextended_attention_maskvalid_indicesnew_batch_indexnew_non_attended_tokensn_image_tokensn_image_featuresspecial_image_maskoutputsr   r   shift_attention_maskshift_logitsshift_labelsloss_fctoutputs&                                         r(   r>   z%LlavaForConditionalGeneration.forward  s   r 2C1N-TXT_T_TqTq$8$D $++JjJj 	 &1%<k$++B]B]$8$D $++JjJj 	
 .9 +;; 	' -t";<YZZ#(Av  " 7D557	BM dkk;;;@@CGGIDKKLhLhh!I//"%*G|4/G  #!44)%9/M 5 N z q!Q&FJFoFo"M9nfGC~v| "'n.B.B1.EnNcNc!d .=Q-?-B1aA:-N* 49;;?Y?_?_?a?e?efh?imn?n3o00 !* 28>>rB*/**#))!,k:(..)00+' !46M6R6RSU6V V"-m"<*=m*L' UV'9P(PQ!&,C^TUXeWeWfTfEg+hno!p$yyQ?II"MPQQ!&n.B.B1.EnNcNc!dfseset!u ''4;;+H+HHMMOTTVN-33A69M9Ma9PP!11 L^L\\ghxgyz  dkk;;;2=)M(()	  ,..}/C/C]EXEXYN)889K^\M%%)%+'/!5#)1 & 
 ) (6a6<<?Q;N9O9Q6Q'R'U'UV\VcVc'd$%c3B3k23G3J3J6==3Y]^3^_jjl%c12g/C/F/Fv}}/UYZ/Z[ffh%c3B3k2==?%c12g99;**,H!!"l&7&7&;<l>O>OPR>S>V>VWcWjWj>kD Y,F'+'7D7V#CVC*#33!//))2>2J
 	
 QU
 	
r'   c           	      f     | j                   j                  |f|||||d|}	|d   dk(  r||	d<   |	S )N)r   r   r   r   r   r   r   )re   prepare_inputs_for_generation)
r9   r   r   r   r   r   r   r   kwargsmodel_inputss
             r(   r   z;LlavaForConditionalGeneration.prepare_inputs_for_generationP  s_     It**HH
+'))1
 
 !! ,8L(r'   )NN)NNNNNNNNNNNNNNr   )NNNNNN)$r   r    r!   r   r/   ri   rl   ro   rq   rt   rw   rz   r   intr   rQ   r~   r#   r$   strr   r   r   LLAVA_INPUTS_DOCSTRINGr   r   _CONFIG_FOR_DOC
LongTensorTensorr   r   r   r   r>   r   r?   r@   s   @r(   r^   r^      s   
{ :8;B111hsm hjhtht !--EHjm:QQf ++AB+FUde '+*.1537=A59.28<-1$(,0/3&*59"#!K
##K
 ''K
 !.	K

 u//0K
 "$u'8'8"9:K
   1 12K
 'smK
 )1K
 ))*K
 D>K
 $D>K
 'tnK
 d^K
 !!1!12K
   !K
" 
u11	2#K
 f CK
` r'   r^   ))r"   dataclassesr   typingr   r   r   r   r#   torch.utils.checkpointr   activationsr
   
generationr   modeling_outputsr   modeling_utilsr   utilsr   r   r   r   autor   r   configuration_llavar   
get_loggerr   r   r   _CHECKPOINT_FOR_DOCr   Moduler*   LLAVA_START_DOCSTRINGrB   r   r^   r&   r'   r(   <module>r     s     ! / /    ! ) + -  3 , 
		H	% 1  $<+ $< $<Nryy  " Y?? ?	?BH V SB$8/ B	Br'   