
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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Optional[Any]	=		"blip_text_model"

						def __init__(			self       ,							a=3_05_24       ,							a=7_68       ,							a=7_68       ,							a=30_72       ,							a=7_68       ,							a=12       ,							a=8       ,							a=5_12       ,							a="gelu"       ,							a=1e-12       ,							a=0.0       ,							a=0.0       ,							a=0.02       ,							a=3_05_22       ,							a=2       ,							a=0       ,							a=1_02       ,							a=True       ,							a=True       ,							**a       ,							)					->      Optional[Any]:


								'''simple docstring'''

								super().__init__(
								    pad_token_id=a       ,							bos_token_id=a       ,							eos_token_id=a       ,							sep_token_id=a       ,							**a       ,							)

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







						@classmethod
						def  A_				(			cls       ,							a       ,							**a				)					->      "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(a				)

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

								# get the text config dict if we are loading from BlipConfig
								if config_dict.get("""model_type"""				) == "blip":
										_UpperCamelCase						    =	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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Optional[int]	=		"blip_vision_model"

						def __init__(			self       ,							a=7_68       ,							a=30_72       ,							a=5_12       ,							a=12       ,							a=12       ,							a=3_84       ,							a=16       ,							a="gelu"       ,							a=1e-5       ,							a=0.0       ,							a=1e-10       ,							**a       ,							)					->      Optional[int]:


								'''simple docstring'''

								super().__init__(**a				)

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







						@classmethod
						def  A_				(			cls       ,							a       ,							**a				)					->      "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(a				)

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

								# get the vision config dict if we are loading from BlipConfig
								if config_dict.get("""model_type"""				) == "blip":
										_UpperCamelCase						    =	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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Union[str, Any]	=		"blip"
						UpperCamelCase_							: int	=		True

						def __init__(			self       ,							a=None       ,							a=None       ,							a=5_12       ,							a=2.6592       ,							a=2_56       ,							**a       ,							)					->      Dict:


								'''simple docstring'''

								super().__init__(**a				)

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

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

								_UpperCamelCase						    =	BlipTextConfig(**a				)
								_UpperCamelCase						    =	BlipVisionConfig(**a				)

								_UpperCamelCase						    =	self.vision_config.hidden_size

								_UpperCamelCase						    =	projection_dim
								_UpperCamelCase						    =	logit_scale_init_value
								_UpperCamelCase						    =	1.0
								_UpperCamelCase						    =	0.02
								_UpperCamelCase						    =	image_text_hidden_size

						@classmethod
						def  A_				(			cls       ,							a       ,							a       ,							**a				)					->      Dict:


								'''simple docstring'''

								return cls(text_config=text_config.to_dict()       ,							vision_config=vision_config.to_dict()       ,							**a				)







						def  A_				(			self				)					->      str:


								'''simple docstring'''

								_UpperCamelCase						    =	copy.deepcopy(self.__dict__				)
								_UpperCamelCase						    =	self.text_config.to_dict()
								_UpperCamelCase						    =	self.vision_config.to_dict()
								_UpperCamelCase						    =	self.__class__.model_type
								return output





import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


lowerCamelCase__	=							logging.get_logger(__name__)

lowerCamelCase__	=							{
    "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config.json",
}







class        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: int	=		"deta"
						UpperCamelCase_							: Union[str, Any]	=		{
						    "hidden_size": "d_model",
						    "num_attention_heads": "encoder_attention_heads",
						}

						def __init__(			self       ,							a=None       ,							a=9_00       ,							a=20_48       ,							a=6       ,							a=20_48       ,							a=8       ,							a=6       ,							a=10_24       ,							a=8       ,							a=0.0       ,							a=True       ,							a="relu"       ,							a=2_56       ,							a=0.1       ,							a=0.0       ,							a=0.0       ,							a=0.02       ,							a=1.0       ,							a=True       ,							a=False       ,							a="sine"       ,							a=5       ,							a=4       ,							a=4       ,							a=True       ,							a=3_00       ,							a=True       ,							a=True       ,							a=1       ,							a=5       ,							a=2       ,							a=1       ,							a=1       ,							a=5       ,							a=2       ,							a=0.1       ,							a=0.25       ,							**a       ,							)					->      Dict:


								'''simple docstring'''

								if backbone_config is None:
										logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""				)
										_UpperCamelCase						    =	CONFIG_MAPPING["""resnet"""](out_features=["""stage2""", """stage3""", """stage4"""]				)
								else:
										if isinstance(a       ,							a				):
												_UpperCamelCase						    =	backbone_config.pop("""model_type"""				)
												_UpperCamelCase						    =	CONFIG_MAPPING[backbone_model_type]
												_UpperCamelCase						    =	config_class.from_dict(a				)

								_UpperCamelCase						    =	backbone_config
								_UpperCamelCase						    =	num_queries
								_UpperCamelCase						    =	max_position_embeddings
								_UpperCamelCase						    =	d_model
								_UpperCamelCase						    =	encoder_ffn_dim
								_UpperCamelCase						    =	encoder_layers
								_UpperCamelCase						    =	encoder_attention_heads
								_UpperCamelCase						    =	decoder_ffn_dim
								_UpperCamelCase						    =	decoder_layers
								_UpperCamelCase						    =	decoder_attention_heads
								_UpperCamelCase						    =	dropout
								_UpperCamelCase						    =	attention_dropout
								_UpperCamelCase						    =	activation_dropout
								_UpperCamelCase						    =	activation_function
								_UpperCamelCase						    =	init_std
								_UpperCamelCase						    =	init_xavier_std
								_UpperCamelCase						    =	encoder_layerdrop
								_UpperCamelCase						    =	auxiliary_loss
								_UpperCamelCase						    =	position_embedding_type
								# deformable attributes
								_UpperCamelCase						    =	num_feature_levels
								_UpperCamelCase						    =	encoder_n_points
								_UpperCamelCase						    =	decoder_n_points
								_UpperCamelCase						    =	two_stage
								_UpperCamelCase						    =	two_stage_num_proposals
								_UpperCamelCase						    =	with_box_refine
								_UpperCamelCase						    =	assign_first_stage
								if two_stage is True and with_box_refine is False:
										raise ValueError("""If two_stage is True, with_box_refine must be True."""				)
								# Hungarian matcher
								_UpperCamelCase						    =	class_cost
								_UpperCamelCase						    =	bbox_cost
								_UpperCamelCase						    =	giou_cost
								# Loss coefficients
								_UpperCamelCase						    =	mask_loss_coefficient
								_UpperCamelCase						    =	dice_loss_coefficient
								_UpperCamelCase						    =	bbox_loss_coefficient
								_UpperCamelCase						    =	giou_loss_coefficient
								_UpperCamelCase						    =	eos_coefficient
								_UpperCamelCase						    =	focal_alpha
								super().__init__(is_encoder_decoder=a       ,							**a				)

						@property
						def  A_				(			self				)					->      int:


								'''simple docstring'''

								return self.encoder_attention_heads

						@property
						def  A_				(			self				)					->      int:


								'''simple docstring'''

								return self.d_model







						def  A_				(			self				)					->      Tuple:


								'''simple docstring'''

								_UpperCamelCase						    =	copy.deepcopy(self.__dict__				)
								_UpperCamelCase						    =	self.backbone_config.to_dict()
								_UpperCamelCase						    =	self.__class__.model_type
								return output



