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


SCREAMING_SNAKE_CASE__   :			Dict												=    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__   :			Union[str, Any]												=    {}

class    lowerCAmelCase__     (	__lowercase			):
		a__       :						Union[str, Any]        =		"""llama"""
		a__       :						List[str]        =		["""past_key_values"""]






		def __init__(		self		:							int							,			SCREAMING_SNAKE_CASE__		:							Union[str, Any]=3_20_00							,			SCREAMING_SNAKE_CASE__		:							List[str]=40_96							,			SCREAMING_SNAKE_CASE__		:							Union[str, Any]=1_10_08							,			SCREAMING_SNAKE_CASE__		:							Optional[int]=32							,			SCREAMING_SNAKE_CASE__		:							str=32							,			SCREAMING_SNAKE_CASE__		:							List[Any]=None							,			SCREAMING_SNAKE_CASE__		:							Tuple="silu"							,			SCREAMING_SNAKE_CASE__		:							int=20_48							,			SCREAMING_SNAKE_CASE__		:							Tuple=0.02							,			SCREAMING_SNAKE_CASE__		:							Tuple=1e-6							,			SCREAMING_SNAKE_CASE__		:							Union[str, Any]=True							,			SCREAMING_SNAKE_CASE__		:							List[Any]=0							,			SCREAMING_SNAKE_CASE__		:							Optional[Any]=1							,			SCREAMING_SNAKE_CASE__		:							List[str]=2							,			SCREAMING_SNAKE_CASE__		:							Dict=1							,			SCREAMING_SNAKE_CASE__		:							Any=False							,			SCREAMING_SNAKE_CASE__		:							Optional[Any]=None							,			**SCREAMING_SNAKE_CASE__		:							int							,			)     ->							Tuple:
						__lowerCamelCase    					=	vocab_size
						__lowerCamelCase    					=	max_position_embeddings
						__lowerCamelCase    					=	hidden_size
						__lowerCamelCase    					=	intermediate_size
						__lowerCamelCase    					=	num_hidden_layers
						__lowerCamelCase    					=	num_attention_heads

						# for backward compatibility
						if num_key_value_heads is None:
										__lowerCamelCase    					=	num_attention_heads

						__lowerCamelCase    					=	num_key_value_heads
						__lowerCamelCase    					=	hidden_act
						__lowerCamelCase    					=	initializer_range
						__lowerCamelCase    					=	rms_norm_eps
						__lowerCamelCase    					=	pretraining_tp
						__lowerCamelCase    					=	use_cache
						__lowerCamelCase    					=	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  __A       (		self		:							Any  )     ->							Optional[int]:
						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    					=	self.rope_scaling.get('''type'''							,			SCREAMING_SNAKE_CASE__  )
						__lowerCamelCase    					=	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}'''  )





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


SCREAMING_SNAKE_CASE__   :			List[str]												=    {
    "configuration_blip": [
        "BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BlipConfig",
        "BlipTextConfig",
        "BlipVisionConfig",
    ],
    "processing_blip": ["BlipProcessor"],
}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE__   :			str												=    ["BlipImageProcessor"]


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE__   :			int												=    [
					    "BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "BlipModel",
					    "BlipPreTrainedModel",
					    "BlipForConditionalGeneration",
					    "BlipForQuestionAnswering",
					    "BlipVisionModel",
					    "BlipTextModel",
					    "BlipForImageTextRetrieval",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE__   :			Any												=    [
					    "TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TFBlipModel",
					    "TFBlipPreTrainedModel",
					    "TFBlipForConditionalGeneration",
					    "TFBlipForQuestionAnswering",
					    "TFBlipVisionModel",
					    "TFBlipTextModel",
					    "TFBlipForImageTextRetrieval",
					]

if TYPE_CHECKING:
					from .configuration_blip import BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP, BlipConfig, BlipTextConfig, BlipVisionConfig
					from .processing_blip import BlipProcessor

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .image_processing_blip import BlipImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_blip import (
										    BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
										    BlipForConditionalGeneration,
										    BlipForImageTextRetrieval,
										    BlipForQuestionAnswering,
										    BlipModel,
										    BlipPreTrainedModel,
										    BlipTextModel,
										    BlipVisionModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_blip import (
										    TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFBlipForConditionalGeneration,
										    TFBlipForImageTextRetrieval,
										    TFBlipForQuestionAnswering,
										    TFBlipModel,
										    TFBlipPreTrainedModel,
										    TFBlipTextModel,
										    TFBlipVisionModel,
										)

else:
					import sys

					SCREAMING_SNAKE_CASE__   :			Tuple												=    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



