

from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType


class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							['image_processor', 'tokenizer']
    lowerCamelCase			=							'BlipImageProcessor'
    lowerCamelCase			=							'AutoTokenizer'


    def __init__(      self :       List[Any],lowercase_ :       Optional[Any],lowercase_ :       List[str]		)->    Optional[int]:





        '''simple docstring'''







        A__          =   False
        super().__init__(lowercase_,lowercase_		)
        A__          =   self.image_processor


    def __call__(      self :       Union[str, Any],lowercase_ :       ImageInput = None,lowercase_ :       Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,lowercase_ :       bool = True,lowercase_ :       Union[bool, str, PaddingStrategy] = False,lowercase_ :       Union[bool, str, TruncationStrategy] = None,lowercase_ :       Optional[int] = None,lowercase_ :       int = 0,lowercase_ :       Optional[int] = None,lowercase_ :       Optional[bool] = None,lowercase_ :       bool = False,lowercase_ :       bool = False,lowercase_ :       bool = False,lowercase_ :       bool = False,lowercase_ :       bool = False,lowercase_ :       bool = True,lowercase_ :       Optional[Union[str, TensorType]] = None,**lowercase_ :       Optional[Any],)->    BatchEncoding:





        '''simple docstring'''







        if images is None and text is None:
            raise ValueError('You have to specify either images or text.'		)

        # Get only text
        if images is None:
            A__          =   self.tokenizer
            A__          =   self.tokenizer(
                text=lowercase_,add_special_tokens=lowercase_,padding=lowercase_,truncation=lowercase_,max_length=lowercase_,stride=lowercase_,pad_to_multiple_of=lowercase_,return_attention_mask=lowercase_,return_overflowing_tokens=lowercase_,return_special_tokens_mask=lowercase_,return_offsets_mapping=lowercase_,return_token_type_ids=lowercase_,return_length=lowercase_,verbose=lowercase_,return_tensors=lowercase_,**lowercase_,)
            return text_encoding

        # add pixel_values
        A__          =   self.image_processor(lowercase_,return_tensors=lowercase_		)

        if text is not None:
            A__          =   self.tokenizer(
                text=lowercase_,add_special_tokens=lowercase_,padding=lowercase_,truncation=lowercase_,max_length=lowercase_,stride=lowercase_,pad_to_multiple_of=lowercase_,return_attention_mask=lowercase_,return_overflowing_tokens=lowercase_,return_special_tokens_mask=lowercase_,return_offsets_mapping=lowercase_,return_token_type_ids=lowercase_,return_length=lowercase_,verbose=lowercase_,return_tensors=lowercase_,**lowercase_,)
        else:
            A__          =   None

        if text_encoding is not None:
            encoding_image_processor.update(lowercase_		)

        return encoding_image_processor


    def 						snake_case__     (      self :       int,*lowercase_ :       Any,**lowercase_ :       str		)->    List[str]:





        '''simple docstring'''







        return self.tokenizer.batch_decode(*lowercase_,**lowercase_		)


    def 						snake_case__     (      self :       Optional[Any],*lowercase_ :       Tuple,**lowercase_ :       Optional[Any]		)->    Tuple:





        '''simple docstring'''







        return self.tokenizer.decode(*lowercase_,**lowercase_		)


    @property
    # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
    def 						snake_case__     (      self :       List[str]		)->    Optional[Any]:





        '''simple docstring'''







        A__          =   self.tokenizer.model_input_names
        A__          =   self.image_processor.model_input_names
        return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names		)		)




from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase_       		=  logging.get_logger(__name__)

lowercase_       		=  {
    "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json",
}


class  A						(							_UpperCAmelCase ):







    """simple docstring"""





    lowerCamelCase			=							'open-llama'


    def __init__(      self :       Any,lowercase_ :       Optional[int]=1_0_0_0_0_0,lowercase_ :       Union[str, Any]=4_0_9_6,lowercase_ :       Dict=1_1_0_0_8,lowercase_ :       Dict=3_2,lowercase_ :       Optional[int]=3_2,lowercase_ :       Dict="silu",lowercase_ :       Union[str, Any]=2_0_4_8,lowercase_ :       Optional[int]=0.02,lowercase_ :       Dict=1E-6,lowercase_ :       Dict=True,lowercase_ :       List[Any]=0,lowercase_ :       Optional[int]=1,lowercase_ :       str=2,lowercase_ :       str=False,lowercase_ :       str=True,lowercase_ :       int=0.1,lowercase_ :       List[Any]=0.1,lowercase_ :       List[Any]=True,lowercase_ :       Union[str, Any]=True,lowercase_ :       Any=None,**lowercase_ :       List[Any],)->    Tuple:





        '''simple docstring'''







        A__          =   vocab_size
        A__          =   max_position_embeddings
        A__          =   hidden_size
        A__          =   intermediate_size
        A__          =   num_hidden_layers
        A__          =   num_attention_heads
        A__          =   hidden_act
        A__          =   initializer_range
        A__          =   rms_norm_eps
        A__          =   use_cache
        A__          =   kwargs.pop(
            'use_memorry_efficient_attention',lowercase_		)
        A__          =   hidden_dropout_prob
        A__          =   attention_dropout_prob
        A__          =   use_stable_embedding
        A__          =   shared_input_output_embedding
        A__          =   rope_scaling
        self._rope_scaling_validation()

        super().__init__(
            pad_token_id=lowercase_,bos_token_id=lowercase_,eos_token_id=lowercase_,tie_word_embeddings=lowercase_,**lowercase_,)


    def 						snake_case__     (      self :       str		)->    str:





        '''simple docstring'''







        if self.rope_scaling is None:
            return

        if not isinstance(self.rope_scaling,lowercase_		) or len(self.rope_scaling		) != 2:
            raise ValueError(
                '`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '
                F'got {self.rope_scaling}'		)
        A__          =   self.rope_scaling.get('type',lowercase_		)
        A__          =   self.rope_scaling.get('factor',lowercase_		)
        if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
            raise ValueError(
                F'`rope_scaling`\'s name field must be one of [\'linear\', \'dynamic\'], got {rope_scaling_type}'		)
        if rope_scaling_factor is None or not isinstance(lowercase_,lowercase_		) or rope_scaling_factor <= 1.0:
            raise ValueError(F'`rope_scaling`\'s factor field must be an float > 1, got {rope_scaling_factor}'		)

