
import copy
import os
from typing import Union

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


lowerCAmelCase__								=		logging.get_logger(__name__)

lowerCAmelCase__								=		{
    """Salesforce/blip-vqa-base""": """https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json""",
    """Salesforce/blip-vqa-capfit-large""": (
        """https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-base""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-large""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json"""
    ),
    """Salesforce/blip-itm-base-coco""": """https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-large-coco""": """https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-base-flikr""": """https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json""",
    """Salesforce/blip-itm-large-flikr""": (
        """https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json"""
    ),
}







class 	lowercase    (				__lowerCAmelCase							):


		"""simple docstring"""




		a__					       =  '''blip_text_model'''


		def __init__(				self	,       __snake_case=3_05_24	,       __snake_case=7_68	,       __snake_case=7_68	,       __snake_case=30_72	,       __snake_case=7_68	,       __snake_case=12	,       __snake_case=8	,       __snake_case=5_12	,       __snake_case="gelu"	,       __snake_case=1e-12	,       __snake_case=0.0	,       __snake_case=0.0	,       __snake_case=0.0_2	,       __snake_case=3_05_22	,       __snake_case=2	,       __snake_case=0	,       __snake_case=1_02	,       __snake_case=True	,       __snake_case=True	,       **__snake_case	,       ):
			super().__init__(
			    pad_token_id=lowerCAmelCase_	,       bos_token_id=lowerCAmelCase_	,       eos_token_id=lowerCAmelCase_	,       sep_token_id=lowerCAmelCase_	,       **lowerCAmelCase_	,       )

			_UpperCamelCase   :		Any			=						vocab_size
			_UpperCamelCase   :		Union[str, Any]			=						hidden_size
			_UpperCamelCase   :		Optional[int]			=						encoder_hidden_size
			_UpperCamelCase   :		str			=						intermediate_size
			_UpperCamelCase   :		List[str]			=						projection_dim
			_UpperCamelCase   :		Dict			=						hidden_dropout_prob
			_UpperCamelCase   :		str			=						num_hidden_layers
			_UpperCamelCase   :		Optional[Any]			=						num_attention_heads
			_UpperCamelCase   :		str			=						max_position_embeddings
			_UpperCamelCase   :		str			=						layer_norm_eps
			_UpperCamelCase   :		int			=						hidden_act
			_UpperCamelCase   :		Union[str, Any]			=						initializer_range
			_UpperCamelCase   :		List[Any]			=						attention_probs_dropout_prob
			_UpperCamelCase   :		Dict			=						is_decoder
			_UpperCamelCase   :		Dict			=						use_cache






		@classmethod
		def 		A__					(				cls	,       __snake_case	,       **__snake_case):
			cls._set_token_in_kwargs(lowerCAmelCase_)

			_UpperCamelCase	,		_UpperCamelCase   :		str			=						cls.get_config_dict(lowerCAmelCase_	,       **lowerCAmelCase_)

			# get the text config dict if we are loading from BlipConfig
			if config_dict.get('model_type') == "blip":
				_UpperCamelCase   :		Optional[int]			=						config_dict['text_config']

			if "model_type" in config_dict and hasattr(cls	,       'model_type') and config_dict["model_type"] != cls.model_type:
				logger.warning(
				    f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
				    f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.''')

			return cls.from_dict(lowerCAmelCase_	,       **lowerCAmelCase_)







class 	lowercase    (				__lowerCAmelCase							):


		"""simple docstring"""




		a__					       =  '''blip_vision_model'''


		def __init__(				self	,       __snake_case=7_68	,       __snake_case=30_72	,       __snake_case=5_12	,       __snake_case=12	,       __snake_case=12	,       __snake_case=3_84	,       __snake_case=16	,       __snake_case="gelu"	,       __snake_case=1e-5	,       __snake_case=0.0	,       __snake_case=1e-10	,       **__snake_case	,       ):
			super().__init__(**lowerCAmelCase_)

			_UpperCamelCase   :		str			=						hidden_size
			_UpperCamelCase   :		int			=						intermediate_size
			_UpperCamelCase   :		List[Any]			=						projection_dim
			_UpperCamelCase   :		Optional[Any]			=						num_hidden_layers
			_UpperCamelCase   :		Optional[int]			=						num_attention_heads
			_UpperCamelCase   :		List[str]			=						patch_size
			_UpperCamelCase   :		Dict			=						image_size
			_UpperCamelCase   :		Optional[Any]			=						initializer_range
			_UpperCamelCase   :		List[Any]			=						attention_dropout
			_UpperCamelCase   :		Optional[int]			=						layer_norm_eps
			_UpperCamelCase   :		Dict			=						hidden_act






		@classmethod
		def 		A__					(				cls	,       __snake_case	,       **__snake_case):
			cls._set_token_in_kwargs(lowerCAmelCase_)

			_UpperCamelCase	,		_UpperCamelCase   :		Dict			=						cls.get_config_dict(lowerCAmelCase_	,       **lowerCAmelCase_)

			# get the vision config dict if we are loading from BlipConfig
			if config_dict.get('model_type') == "blip":
				_UpperCamelCase   :		Dict			=						config_dict['vision_config']

			if "model_type" in config_dict and hasattr(cls	,       'model_type') and config_dict["model_type"] != cls.model_type:
				logger.warning(
				    f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
				    f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.''')

			return cls.from_dict(lowerCAmelCase_	,       **lowerCAmelCase_)







class 	lowercase    (				__lowerCAmelCase							):


		"""simple docstring"""




		a__					       =  '''blip'''
		a__					       =  True


		def __init__(				self	,       __snake_case=None	,       __snake_case=None	,       __snake_case=5_12	,       __snake_case=2.6_5_9_2	,       __snake_case=2_56	,       **__snake_case	,       ):
			super().__init__(**lowerCAmelCase_)

			if text_config is None:
				_UpperCamelCase   :		Dict			=						{}
				logger.info('`text_config` is `None`. Initializing the `BlipTextConfig` with default values.')

			if vision_config is None:
				_UpperCamelCase   :		Any			=						{}
				logger.info('`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.')

			_UpperCamelCase   :		List[Any]			=						BlipTextConfig(**lowerCAmelCase_)
			_UpperCamelCase   :		Any			=						BlipVisionConfig(**lowerCAmelCase_)

			_UpperCamelCase   :		Dict			=						self.vision_config.hidden_size

			_UpperCamelCase   :		Optional[Any]			=						projection_dim
			_UpperCamelCase   :		Optional[int]			=						logit_scale_init_value
			_UpperCamelCase   :		Any			=						1.0
			_UpperCamelCase   :		Tuple			=						0.0_2
			_UpperCamelCase   :		Optional[int]			=						image_text_hidden_size


		@classmethod
		def 		A__					(				cls	,       __snake_case	,       __snake_case	,       **__snake_case):
			return cls(text_config=text_config.to_dict()	,       vision_config=vision_config.to_dict()	,       **lowerCAmelCase_)






		def 		A__					(				self):
			_UpperCamelCase   :		str			=						copy.deepcopy(self.__dict__)
			_UpperCamelCase   :		List[Any]			=						self.text_config.to_dict()
			_UpperCamelCase   :		Any			=						self.vision_config.to_dict()
			_UpperCamelCase   :		List[str]			=						self.__class__.model_type
			return output







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


lowerCAmelCase__								=		logging.get_logger(__name__)

lowerCAmelCase__								=		{
    """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json""",
    """RWKV/rwkv-4-430m-pile""": """https://huggingface.co/RWKV/rwkv-4-430m-pile/resolve/main/config.json""",
    """RWKV/rwkv-4-1b5-pile""": """https://huggingface.co/RWKV/rwkv-4-1b5-pile/resolve/main/config.json""",
    """RWKV/rwkv-4-3b-pile""": """https://huggingface.co/RWKV/rwkv-4-3b-pile/resolve/main/config.json""",
    """RWKV/rwkv-4-7b-pile""": """https://huggingface.co/RWKV/rwkv-4-7b-pile/resolve/main/config.json""",
    """RWKV/rwkv-4-14b-pile""": """https://huggingface.co/RWKV/rwkv-4-14b-pile/resolve/main/config.json""",
    """RWKV/rwkv-raven-1b5""": """https://huggingface.co/RWKV/rwkv-raven-1b5/resolve/main/config.json""",
    """RWKV/rwkv-raven-3b""": """https://huggingface.co/RWKV/rwkv-raven-3b/resolve/main/config.json""",
    """RWKV/rwkv-raven-7b""": """https://huggingface.co/RWKV/rwkv-raven-7b/resolve/main/config.json""",
    """RWKV/rwkv-raven-14b""": """https://huggingface.co/RWKV/rwkv-raven-14b/resolve/main/config.json""",
}







class 	lowercase    (				_lowercase							):


		"""simple docstring"""




		a__					       =  "rwkv"
		a__					       =  {"max_position_embeddings": "context_length"}


		def __init__(				self	,       __snake_case=5_02_77	,       __snake_case=10_24	,       __snake_case=40_96	,       __snake_case=32	,       __snake_case=None	,       __snake_case=None	,       __snake_case=1e-5	,       __snake_case=0	,       __snake_case=0	,       __snake_case=6	,       __snake_case=False	,       __snake_case=True	,       **__snake_case	,       ):
			_UpperCamelCase   :		str			=						vocab_size
			_UpperCamelCase   :		int			=						context_length
			_UpperCamelCase   :		Tuple			=						hidden_size
			_UpperCamelCase   :		Tuple			=						num_hidden_layers
			_UpperCamelCase   :		Dict			=						attention_hidden_size if attention_hidden_size is not None else hidden_size
			_UpperCamelCase   :		Tuple			=						intermediate_size if intermediate_size is not None else 4 * hidden_size
			_UpperCamelCase   :		Union[str, Any]			=						layer_norm_epsilon
			_UpperCamelCase   :		Dict			=						rescale_every
			_UpperCamelCase   :		Optional[Any]			=						use_cache

			_UpperCamelCase   :		str			=						bos_token_id
			_UpperCamelCase   :		Optional[Any]			=						eos_token_id

			super().__init__(
			    tie_word_embeddings=__snake_case	,       bos_token_id=__snake_case	,       eos_token_id=__snake_case	,       **__snake_case)




