






import copy
import os
from typing import Union

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


a_		:    str   							=     logging.get_logger(__name__)

a_		:    List[Any]   							=     {
    '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 		_snake_case	(	A__       ):
			_lowercase		:     List[str]        =				'''blip_text_model'''






			def __init__(							self		,       a=3_0524		,       a=768		,       a=768		,       a=3072		,       a=768		,       a=12		,       a=8		,       a=512		,       a="gelu"		,       a=1E-12		,       a=0.0		,       a=0.0		,       a=0.02		,       a=3_0522		,       a=2		,       a=0		,       a=102		,       a=True		,       a=True		,       **a		,       )   ->							Any:
						super().__init__(
						    pad_token_id=a		,       bos_token_id=a		,       eos_token_id=a		,       sep_token_id=a		,       **a		,       )

						SCREAMING_SNAKE_CASE							=			vocab_size
						SCREAMING_SNAKE_CASE							=			hidden_size
						SCREAMING_SNAKE_CASE							=			encoder_hidden_size
						SCREAMING_SNAKE_CASE							=			intermediate_size
						SCREAMING_SNAKE_CASE							=			projection_dim
						SCREAMING_SNAKE_CASE							=			hidden_dropout_prob
						SCREAMING_SNAKE_CASE							=			num_hidden_layers
						SCREAMING_SNAKE_CASE							=			num_attention_heads
						SCREAMING_SNAKE_CASE							=			max_position_embeddings
						SCREAMING_SNAKE_CASE							=			layer_norm_eps
						SCREAMING_SNAKE_CASE							=			hidden_act
						SCREAMING_SNAKE_CASE							=			initializer_range
						SCREAMING_SNAKE_CASE							=			attention_probs_dropout_prob
						SCREAMING_SNAKE_CASE							=			is_decoder
						SCREAMING_SNAKE_CASE							=			use_cache







			@classmethod
			def  SCREAMING_SNAKE_CASE__     (							cls		,       a		,       **a)   ->							"PretrainedConfig":
						cls._set_token_in_kwargs(a)

						SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE							=			cls.get_config_dict(a		,       **a)

						# get the text config dict if we are loading from BlipConfig
						if config_dict.get('model_type') == "blip":
									SCREAMING_SNAKE_CASE							=			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(a		,       **a)



class 		_snake_case	(	A__       ):
			_lowercase		:     Any        =				'''blip_vision_model'''






			def __init__(							self		,       a=768		,       a=3072		,       a=512		,       a=12		,       a=12		,       a=384		,       a=16		,       a="gelu"		,       a=1E-5		,       a=0.0		,       a=1E-10		,       **a		,       )   ->							Optional[int]:
						super().__init__(**a)

						SCREAMING_SNAKE_CASE							=			hidden_size
						SCREAMING_SNAKE_CASE							=			intermediate_size
						SCREAMING_SNAKE_CASE							=			projection_dim
						SCREAMING_SNAKE_CASE							=			num_hidden_layers
						SCREAMING_SNAKE_CASE							=			num_attention_heads
						SCREAMING_SNAKE_CASE							=			patch_size
						SCREAMING_SNAKE_CASE							=			image_size
						SCREAMING_SNAKE_CASE							=			initializer_range
						SCREAMING_SNAKE_CASE							=			attention_dropout
						SCREAMING_SNAKE_CASE							=			layer_norm_eps
						SCREAMING_SNAKE_CASE							=			hidden_act







			@classmethod
			def  SCREAMING_SNAKE_CASE__     (							cls		,       a		,       **a)   ->							"PretrainedConfig":
						cls._set_token_in_kwargs(a)

						SCREAMING_SNAKE_CASE					,    SCREAMING_SNAKE_CASE							=			cls.get_config_dict(a		,       **a)

						# get the vision config dict if we are loading from BlipConfig
						if config_dict.get('model_type') == "blip":
									SCREAMING_SNAKE_CASE							=			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(a		,       **a)



class 		_snake_case	(	A__       ):
			_lowercase		:     Optional[int]        =				'''blip'''
			_lowercase		:     List[Any]        =				True






			def __init__(							self		,       a=None		,       a=None		,       a=512		,       a=2.65_92		,       a=256		,       **a		,       )   ->							Any:
						super().__init__(**a)

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

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

						SCREAMING_SNAKE_CASE							=			BlipTextConfig(**a)
						SCREAMING_SNAKE_CASE							=			BlipVisionConfig(**a)

						SCREAMING_SNAKE_CASE							=			self.vision_config.hidden_size

						SCREAMING_SNAKE_CASE							=			projection_dim
						SCREAMING_SNAKE_CASE							=			logit_scale_init_value
						SCREAMING_SNAKE_CASE							=			1.0
						SCREAMING_SNAKE_CASE							=			0.02
						SCREAMING_SNAKE_CASE							=			image_text_hidden_size






			@classmethod
			def  SCREAMING_SNAKE_CASE__     (							cls		,       a		,       a		,       **a)   ->							Optional[int]:
						return cls(text_config=text_config.to_dict()		,       vision_config=vision_config.to_dict()		,       **a)







			def  SCREAMING_SNAKE_CASE__     (							self)   ->							Tuple:
						SCREAMING_SNAKE_CASE							=			copy.deepcopy(self.__dict__)
						SCREAMING_SNAKE_CASE							=			self.text_config.to_dict()
						SCREAMING_SNAKE_CASE							=			self.vision_config.to_dict()
						SCREAMING_SNAKE_CASE							=			self.__class__.model_type
						return output










import unittest

from accelerate import debug_launcher
from accelerate.test_utils import require_cpu, test_ops, test_script




@require_cpu
class 		__A   (      unittest.TestCase      ):

						def      A__    (		self :Tuple			):
										'''simple docstring'''

										debug_launcher(test_script.main			)


						def      A__    (		self :Dict			):
										'''simple docstring'''

										debug_launcher(test_ops.main			)




