
"""simple docstring"""


import copy
from typing import Dict

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING
from ..bit import BitConfig


A_						       =				logging.get_logger(__name__)

A_						       =				{
    '''google/vit-hybrid-base-bit-384''': '''https://huggingface.co/vit-hybrid-base-bit-384/resolve/main/config.json''',
    # See all ViT hybrid models at https://huggingface.co/models?filter=vit
}




class    __lowerCamelCase     (   UpperCamelCase_ ):
				a__:			Dict									=						"""vit-hybrid"""




				def __init__(							self       ,	UpperCAmelCase=None       ,	UpperCAmelCase=768       ,	UpperCAmelCase=12       ,	UpperCAmelCase=12       ,	UpperCAmelCase=3072       ,	UpperCAmelCase="gelu"       ,	UpperCAmelCase=0.0       ,	UpperCAmelCase=0.0       ,	UpperCAmelCase=0.0_2       ,	UpperCAmelCase=1e-1_2       ,	UpperCAmelCase=224       ,	UpperCAmelCase=1       ,	UpperCAmelCase=3       ,	UpperCAmelCase=[1, 1024, 24, 24]       ,	UpperCAmelCase=True       ,	**UpperCAmelCase       ,	):
							super().__init__(**__SCREAMING_SNAKE_CASE      )

							if backbone_config is None:
										logger.info('''`backbone_config` is `None`. Initializing the config with a `BiT` backbone.'''      )
										lowerCamelCase_ 		=     {
										    '''global_padding''': '''same''',
										    '''layer_type''': '''bottleneck''',
										    '''depths''': [3, 4, 9],
										    '''out_features''': ['''stage3'''],
										    '''embedding_dynamic_padding''': True,
										}

							if isinstance(__SCREAMING_SNAKE_CASE       ,	__SCREAMING_SNAKE_CASE      ):
										if "model_type" in backbone_config:
													lowerCamelCase_ 		=     CONFIG_MAPPING[backbone_config['''model_type''']]
										else:
													logger.info(
													    '''`model_type` is not found in `backbone_config`. Use `Bit` as the backbone configuration class.'''      )
													lowerCamelCase_ 		=     BitConfig
										lowerCamelCase_ 		=     backbone_config_class(**__SCREAMING_SNAKE_CASE      )

							lowerCamelCase_ 		=     backbone_featmap_shape
							lowerCamelCase_ 		=     backbone_config
							lowerCamelCase_ 		=     hidden_size
							lowerCamelCase_ 		=     num_hidden_layers
							lowerCamelCase_ 		=     num_attention_heads
							lowerCamelCase_ 		=     intermediate_size
							lowerCamelCase_ 		=     hidden_act
							lowerCamelCase_ 		=     hidden_dropout_prob
							lowerCamelCase_ 		=     attention_probs_dropout_prob
							lowerCamelCase_ 		=     initializer_range
							lowerCamelCase_ 		=     layer_norm_eps
							lowerCamelCase_ 		=     image_size
							lowerCamelCase_ 		=     patch_size
							lowerCamelCase_ 		=     num_channels
							lowerCamelCase_ 		=     qkv_bias





				def 					UpperCAmelCase__	(							self      ):
							lowerCamelCase_ 		=     copy.deepcopy(self.__dict__      )
							lowerCamelCase_ 		=     self.backbone_config.to_dict()
							lowerCamelCase_ 		=     self.__class__.model_type
							return output





"""simple docstring"""


import copy

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


A_						       =				logging.get_logger(__name__)




class    __lowerCamelCase     (   lowerCAmelCase ):
				a__:			List[str]									=						'hybrid-clip'
				a__:			List[Any]									=						True




				def __init__(							self       ,	UpperCAmelCase=512       ,	**UpperCAmelCase      ):
							super().__init__(**UpperCAmelCase      )

							if "text_config" not in kwargs:
										raise ValueError('''`text_config` can not be `None`.'''      )

							if "vision_config" not in kwargs:
										raise ValueError('''`vision_config` can not be `None`.'''      )

							lowerCamelCase_ 		=     kwargs.pop('''text_config'''      )
							lowerCamelCase_ 		=     kwargs.pop('''vision_config'''      )

							lowerCamelCase_ 		=     text_config.pop('''model_type'''      )
							lowerCamelCase_ 		=     vision_config.pop('''model_type'''      )

							from transformers import AutoConfig

							lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      )

							if vision_model_type == "clip":
										lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      ).vision_config
							elif vision_model_type == "clip_vision_model":
										from transformers import CLIPVisionConfig

										lowerCamelCase_ 		=     CLIPVisionConfig(**UpperCAmelCase      )
							else:
										lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      )

							lowerCamelCase_ 		=     projection_dim
							lowerCamelCase_ 		=     1.0




				@classmethod
				def 					UpperCAmelCase__	(							cls       ,	UpperCAmelCase       ,	UpperCAmelCase       ,	**UpperCAmelCase      ):
							return cls(text_config=text_config.to_dict()       ,	vision_config=vision_config.to_dict()       ,	**UpperCAmelCase      )





				def 					UpperCAmelCase__	(							self      ):
							lowerCamelCase_ 		=     copy.deepcopy(self.__dict__      )
							lowerCamelCase_ 		=     self.text_config.to_dict()
							lowerCamelCase_ 		=     self.vision_config.to_dict()
							lowerCamelCase_ 		=     self.__class__.model_type
							return output



