


import copy

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


lowerCAmelCase__       :	Optional[Any]     				=logging.get_logger(__name__)

lowerCAmelCase__       :	int     				={
    '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      __lowercase  (__SCREAMING_SNAKE_CASE   ):





							"""simple docstring"""







							def __init__(	self       ,		lowerCAmelCase__=2_5_6       ,		lowerCAmelCase__=1_0_2_4       ,		lowerCAmelCase__=1_6       ,		lowerCAmelCase__=1_6       ,		lowerCAmelCase__=4       ,		lowerCAmelCase__="gelu"       ,		lowerCAmelCase__=1E-6       ,		**lowerCAmelCase__       ,		):





										"""simple docstring"""




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







class      __lowercase  (__SCREAMING_SNAKE_CASE   ):





							"""simple docstring"""







							def __init__(	self       ,		lowerCAmelCase__=2_5_6       ,		lowerCAmelCase__="relu"       ,		lowerCAmelCase__=2_0_4_8       ,		lowerCAmelCase__=2       ,		lowerCAmelCase__=8       ,		lowerCAmelCase__=2       ,		lowerCAmelCase__=3       ,		lowerCAmelCase__=3       ,		lowerCAmelCase__=2_5_6       ,		lowerCAmelCase__=1E-6       ,		**lowerCAmelCase__       ,		):





										"""simple docstring"""




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







class      __lowercase  (__SCREAMING_SNAKE_CASE   ):





							"""simple docstring"""







							def __init__(	self       ,		lowerCAmelCase__=7_6_8       ,		lowerCAmelCase__=2_5_6       ,		lowerCAmelCase__=1_2       ,		lowerCAmelCase__=1_2       ,		lowerCAmelCase__=3       ,		lowerCAmelCase__=1_0_2_4       ,		lowerCAmelCase__=1_6       ,		lowerCAmelCase__="gelu"       ,		lowerCAmelCase__=1E-06       ,		lowerCAmelCase__=0.0       ,		lowerCAmelCase__=1E-10       ,		lowerCAmelCase__=True       ,		lowerCAmelCase__=4.0       ,		lowerCAmelCase__=True       ,		lowerCAmelCase__=True       ,		lowerCAmelCase__=1_4       ,		lowerCAmelCase__=[2, 5, 8, 1_1]       ,		lowerCAmelCase__=1_2_8       ,		lowerCAmelCase__=None       ,		**lowerCAmelCase__       ,		):





										"""simple docstring"""




										super().__init__(**lowerCAmelCase__    )

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







class      __lowercase  (__SCREAMING_SNAKE_CASE   ):





							"""simple docstring"""







							_UpperCAmelCase     =		"""sam"""
							_UpperCAmelCase     =		True






							def __init__(	self       ,		lowerCAmelCase__=None       ,		lowerCAmelCase__=None       ,		lowerCAmelCase__=None       ,		lowerCAmelCase__=0.02       ,		**lowerCAmelCase__       ,		):





										"""simple docstring"""




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

										if isinstance(lowerCAmelCase__       ,		lowerCAmelCase__    ):
													SCREAMING_SNAKE_CASE_						:			Optional[int]       						= vision_config.to_dict()
										if isinstance(lowerCAmelCase__       ,		lowerCAmelCase__    ):
													SCREAMING_SNAKE_CASE_						:			str       						= prompt_encoder_config.to_dict()
										if isinstance(lowerCAmelCase__       ,		lowerCAmelCase__    ):
													SCREAMING_SNAKE_CASE_						:			List[str]       						= mask_decoder_config.to_dict()

										SCREAMING_SNAKE_CASE_						:			Any       						= SamVisionConfig(**lowerCAmelCase__    )
										SCREAMING_SNAKE_CASE_						:			Tuple       						= SamPromptEncoderConfig(**lowerCAmelCase__    )
										SCREAMING_SNAKE_CASE_						:			Optional[int]       						= SamMaskDecoderConfig(**lowerCAmelCase__    )
										SCREAMING_SNAKE_CASE_						:			Optional[Any]       						= initializer_range






							def  UpperCamelCase__			(	self    ):





										"""simple docstring"""




										SCREAMING_SNAKE_CASE_						:			str       						= copy.deepcopy(self.__dict__    )
										SCREAMING_SNAKE_CASE_						:			List[Any]       						= self.vision_config.to_dict()
										SCREAMING_SNAKE_CASE_						:			Optional[Any]       						= self.prompt_encoder_config.to_dict()
										SCREAMING_SNAKE_CASE_						:			int       						= self.mask_decoder_config.to_dict()
										SCREAMING_SNAKE_CASE_						:			Union[str, Any]       						= self.__class__.model_type
										return output









from __future__ import annotations






def 		a__       (							A__							):
			if len(A__							) == 0:
						raise ValueError('find_max() arg is an empty sequence'							)
			SCREAMING_SNAKE_CASE_						:			str       						= nums[0]
			for x in nums:
						if x > max_num:
									SCREAMING_SNAKE_CASE_						:			Optional[int]       						= x
			return max_num


if __name__ == "__main__":
				import doctest

				doctest.testmod(verbose=True)





