



import copy

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


__A             =logging.get_logger(__name__)

__A             ={
    "facebook/sam-vit-huge": "https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json",
    "facebook/sam-vit-large": "https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json",
    "facebook/sam-vit-base": "https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json",
}

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			def __init__(       self							:			str	,	a_							:			Union[str, Any]=2_56	,	a_							:			Dict=10_24	,	a_							:			Tuple=16	,	a_							:			List[str]=16	,	a_							:			List[str]=4	,	a_							:			int="gelu"	,	a_							:			Dict=1e-6	,	**a_							:			Optional[int]	,	):
					'''simple docstring'''





					super().__init__(**a_			)
					__UpperCAmelCase   :					Optional[Any]													=     hidden_size
					__UpperCAmelCase   :					int													=     image_size
					__UpperCAmelCase   :					str													=     patch_size
					__UpperCAmelCase   :					int													=     image_size // patch_size
					__UpperCAmelCase   :					Any													=     mask_input_channels
					__UpperCAmelCase   :					Union[str, Any]													=     num_point_embeddings
					__UpperCAmelCase   :					Optional[Any]													=     hidden_act
					__UpperCAmelCase   :					Optional[Any]													=     layer_norm_eps

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			def __init__(       self							:			Optional[Any]	,	a_							:			Optional[int]=2_56	,	a_							:			Union[str, Any]="relu"	,	a_							:			List[Any]=20_48	,	a_							:			Optional[Any]=2	,	a_							:			List[Any]=8	,	a_							:			Tuple=2	,	a_							:			List[str]=3	,	a_							:			Union[str, Any]=3	,	a_							:			Any=2_56	,	a_							:			str=1e-6	,	**a_							:			Any	,	):
					'''simple docstring'''





					super().__init__(**a_			)
					__UpperCAmelCase   :					Any													=     hidden_size
					__UpperCAmelCase   :					List[str]													=     hidden_act
					__UpperCAmelCase   :					Any													=     mlp_dim
					__UpperCAmelCase   :					Optional[Any]													=     num_hidden_layers
					__UpperCAmelCase   :					Any													=     num_attention_heads
					__UpperCAmelCase   :					Optional[Any]													=     attention_downsample_rate
					__UpperCAmelCase   :					List[str]													=     num_multimask_outputs
					__UpperCAmelCase   :					Dict													=     iou_head_depth
					__UpperCAmelCase   :					int													=     iou_head_hidden_dim
					__UpperCAmelCase   :					Any													=     layer_norm_eps

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			def __init__(       self							:			Union[str, Any]	,	a_							:			Any=7_68	,	a_							:			List[Any]=2_56	,	a_							:			int=12	,	a_							:			Dict=12	,	a_							:			List[str]=3	,	a_							:			Any=10_24	,	a_							:			str=16	,	a_							:			List[str]="gelu"	,	a_							:			Tuple=1e-06	,	a_							:			List[str]=0.0	,	a_							:			int=1e-10	,	a_							:			List[str]=True	,	a_							:			Optional[int]=4.0	,	a_							:			Union[str, Any]=True	,	a_							:			str=True	,	a_							:			Any=14	,	a_							:			int=[2, 5, 8, 11]	,	a_							:			Any=1_28	,	a_							:			List[Any]=None	,	**a_							:			Any	,	):
					'''simple docstring'''





					super().__init__(**a_			)

					__UpperCAmelCase   :					List[str]													=     hidden_size
					__UpperCAmelCase   :					Dict													=     output_channels
					__UpperCAmelCase   :					Union[str, Any]													=     num_hidden_layers
					__UpperCAmelCase   :					Tuple													=     num_attention_heads
					__UpperCAmelCase   :					Tuple													=     num_channels
					__UpperCAmelCase   :					int													=     image_size
					__UpperCAmelCase   :					Optional[Any]													=     patch_size
					__UpperCAmelCase   :					Dict													=     hidden_act
					__UpperCAmelCase   :					Any													=     layer_norm_eps
					__UpperCAmelCase   :					Dict													=     attention_dropout
					__UpperCAmelCase   :					List[str]													=     initializer_range
					__UpperCAmelCase   :					Any													=     qkv_bias
					__UpperCAmelCase   :					Union[str, Any]													=     mlp_ratio
					__UpperCAmelCase   :					Any													=     use_abs_pos
					__UpperCAmelCase   :					Union[str, Any]													=     use_rel_pos
					__UpperCAmelCase   :					List[str]													=     window_size
					__UpperCAmelCase   :					Union[str, Any]													=     global_attn_indexes
					__UpperCAmelCase   :					int													=     num_pos_feats
					__UpperCAmelCase   :					Optional[Any]													=     int(hidden_size * mlp_ratio			) if mlp_dim is None else mlp_dim

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			UpperCamelCase      						=	"""sam"""
			UpperCamelCase      						=	True




			def __init__(       self							:			List[Any]	,	a_							:			List[Any]=None	,	a_							:			List[Any]=None	,	a_							:			Optional[Any]=None	,	a_							:			Any=0.0_2	,	**a_							:			Optional[int]	,	):
					'''simple docstring'''





					super().__init__(**a_			)
					__UpperCAmelCase   :					Tuple													=     vision_config if vision_config is not None else {}
					__UpperCAmelCase   :					Tuple													=     prompt_encoder_config if prompt_encoder_config is not None else {}
					__UpperCAmelCase   :					List[str]													=     mask_decoder_config if mask_decoder_config is not None else {}

					if isinstance(a_	,	a_			):
							__UpperCAmelCase   :					Optional[Any]													=     vision_config.to_dict()
					if isinstance(a_	,	a_			):
							__UpperCAmelCase   :					Tuple													=     prompt_encoder_config.to_dict()
					if isinstance(a_	,	a_			):
							__UpperCAmelCase   :					int													=     mask_decoder_config.to_dict()

					__UpperCAmelCase   :					str													=     SamVisionConfig(**a_			)
					__UpperCAmelCase   :					Union[str, Any]													=     SamPromptEncoderConfig(**a_			)
					__UpperCAmelCase   :					Tuple													=     SamMaskDecoderConfig(**a_			)
					__UpperCAmelCase   :					str													=     initializer_range




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





					__UpperCAmelCase   :					Dict													=     copy.deepcopy(self.__dict__			)
					__UpperCAmelCase   :					Dict													=     self.vision_config.to_dict()
					__UpperCAmelCase   :					Tuple													=     self.prompt_encoder_config.to_dict()
					__UpperCAmelCase   :					Dict													=     self.mask_decoder_config.to_dict()
					__UpperCAmelCase   :					str													=     self.__class__.model_type
					return output










def 	a						(				_UpperCAmelCase							: str						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[Any]													=     53_81
		for x in s:
				__UpperCAmelCase   :					str													=     ((hash_value << 5) + hash_value) + ord(_UpperCAmelCase						)
		return hash_value & 0xFFFF_FFFF





