
"""simple docstring"""







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


lowerCamelCase__           =	logging.get_logger(__name__)

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




class 				A__ (			_lowerCamelCase):
		A_		: List[str]            =			'open-llama'

		def __init__(   self ,	_SCREAMING_SNAKE_CASE=10_00_00 ,	_SCREAMING_SNAKE_CASE=40_96 ,	_SCREAMING_SNAKE_CASE=1_10_08 ,	_SCREAMING_SNAKE_CASE=32 ,	_SCREAMING_SNAKE_CASE=32 ,	_SCREAMING_SNAKE_CASE="silu" ,	_SCREAMING_SNAKE_CASE=20_48 ,	_SCREAMING_SNAKE_CASE=0.02 ,	_SCREAMING_SNAKE_CASE=1E-6 ,	_SCREAMING_SNAKE_CASE=True ,	_SCREAMING_SNAKE_CASE=0 ,	_SCREAMING_SNAKE_CASE=1 ,	_SCREAMING_SNAKE_CASE=2 ,	_SCREAMING_SNAKE_CASE=False ,	_SCREAMING_SNAKE_CASE=True ,	_SCREAMING_SNAKE_CASE=0.1 ,	_SCREAMING_SNAKE_CASE=0.1 ,	_SCREAMING_SNAKE_CASE=True ,	_SCREAMING_SNAKE_CASE=True ,	_SCREAMING_SNAKE_CASE=None ,	**_SCREAMING_SNAKE_CASE ,	):
			__lowerCAmelCase    :		Union[str, Any]		    =   vocab_size
			__lowerCAmelCase    :		Dict		    =   max_position_embeddings
			__lowerCAmelCase    :		str		    =   hidden_size
			__lowerCAmelCase    :		str		    =   intermediate_size
			__lowerCAmelCase    :		int		    =   num_hidden_layers
			__lowerCAmelCase    :		Optional[Any]		    =   num_attention_heads
			__lowerCAmelCase    :		Dict		    =   hidden_act
			__lowerCAmelCase    :		List[Any]		    =   initializer_range
			__lowerCAmelCase    :		Any		    =   rms_norm_eps
			__lowerCAmelCase    :		Any		    =   use_cache
			__lowerCAmelCase    :		str		    =   kwargs.pop(
			    'use_memorry_efficient_attention' ,	_SCREAMING_SNAKE_CASE				)
			__lowerCAmelCase    :		int		    =   hidden_dropout_prob
			__lowerCAmelCase    :		List[str]		    =   attention_dropout_prob
			__lowerCAmelCase    :		int		    =   use_stable_embedding
			__lowerCAmelCase    :		Optional[Any]		    =   shared_input_output_embedding
			__lowerCAmelCase    :		Dict		    =   rope_scaling
			self._rope_scaling_validation()

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







		def 							__lowerCamelCase							(   self				):
			if self.rope_scaling is None:
				return

			if not isinstance(self.rope_scaling ,	_SCREAMING_SNAKE_CASE				) 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}"				)
			__lowerCAmelCase    :		Tuple		    =   self.rope_scaling.get('type' ,	_SCREAMING_SNAKE_CASE				)
			__lowerCAmelCase    :		str		    =   self.rope_scaling.get('factor' ,	_SCREAMING_SNAKE_CASE				)
			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(_SCREAMING_SNAKE_CASE ,	_SCREAMING_SNAKE_CASE				) or rope_scaling_factor <= 1.0:
				raise ValueError(f"`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}"				)

"""simple docstring"""







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__ (			_lowerCamelCase):
		A_		: Any            =			['image_processor', 'tokenizer']
		A_		: Optional[Any]            =			'BlipImageProcessor'
		A_		: int            =			'AutoTokenizer'

		def __init__(   self ,	_SCREAMING_SNAKE_CASE ,	_SCREAMING_SNAKE_CASE				):
			__lowerCAmelCase    :		Union[str, Any]		    =   False
			super().__init__(_SCREAMING_SNAKE_CASE ,	_SCREAMING_SNAKE_CASE				)
			__lowerCAmelCase    :		List[Any]		    =   self.image_processor

		def __call__(   self ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = True ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = 0 ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = None ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = False ,	_SCREAMING_SNAKE_CASE = True ,	_SCREAMING_SNAKE_CASE = None ,	**_SCREAMING_SNAKE_CASE ,	):
			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:
				__lowerCAmelCase    :		Optional[int]		    =   self.tokenizer
				__lowerCAmelCase    :		List[str]		    =   self.tokenizer(
				    text=_SCREAMING_SNAKE_CASE ,	add_special_tokens=_SCREAMING_SNAKE_CASE ,	padding=_SCREAMING_SNAKE_CASE ,	truncation=_SCREAMING_SNAKE_CASE ,	max_length=_SCREAMING_SNAKE_CASE ,	stride=_SCREAMING_SNAKE_CASE ,	pad_to_multiple_of=_SCREAMING_SNAKE_CASE ,	return_attention_mask=_SCREAMING_SNAKE_CASE ,	return_overflowing_tokens=_SCREAMING_SNAKE_CASE ,	return_special_tokens_mask=_SCREAMING_SNAKE_CASE ,	return_offsets_mapping=_SCREAMING_SNAKE_CASE ,	return_token_type_ids=_SCREAMING_SNAKE_CASE ,	return_length=_SCREAMING_SNAKE_CASE ,	verbose=_SCREAMING_SNAKE_CASE ,	return_tensors=_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE ,	)
				return text_encoding

			# add pixel_values
			__lowerCAmelCase    :		List[Any]		    =   self.image_processor(_SCREAMING_SNAKE_CASE ,	return_tensors=_SCREAMING_SNAKE_CASE				)

			if text is not None:
				__lowerCAmelCase    :		Optional[int]		    =   self.tokenizer(
				    text=_SCREAMING_SNAKE_CASE ,	add_special_tokens=_SCREAMING_SNAKE_CASE ,	padding=_SCREAMING_SNAKE_CASE ,	truncation=_SCREAMING_SNAKE_CASE ,	max_length=_SCREAMING_SNAKE_CASE ,	stride=_SCREAMING_SNAKE_CASE ,	pad_to_multiple_of=_SCREAMING_SNAKE_CASE ,	return_attention_mask=_SCREAMING_SNAKE_CASE ,	return_overflowing_tokens=_SCREAMING_SNAKE_CASE ,	return_special_tokens_mask=_SCREAMING_SNAKE_CASE ,	return_offsets_mapping=_SCREAMING_SNAKE_CASE ,	return_token_type_ids=_SCREAMING_SNAKE_CASE ,	return_length=_SCREAMING_SNAKE_CASE ,	verbose=_SCREAMING_SNAKE_CASE ,	return_tensors=_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE ,	)
			else:
				__lowerCAmelCase    :		int		    =   None

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

			return encoding_image_processor

		def 							__lowerCamelCase							(   self ,	*_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE				):
			return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE				)

		def 							__lowerCamelCase							(   self ,	*_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE				):
			return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE ,	**_SCREAMING_SNAKE_CASE				)







		@property
		# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
		def 							__lowerCamelCase							(   self				):
			__lowerCAmelCase    :		int		    =   self.tokenizer.model_input_names
			__lowerCAmelCase    :		Union[str, Any]		    =   self.image_processor.model_input_names
			return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)