





from __future__ import annotations

from typing import Any
class      __magic_name__       :




					def __init__(    self     ,					_a     ,					_a		)       -> List[str]:  # noqa: A002
							lowerCAmelCase_				=							item
							lowerCAmelCase_				=							next





class      __magic_name__       :




					def __init__(    self		)       -> Optional[int]:
							lowerCAmelCase_				=							None
							lowerCAmelCase_				=							0




					def  __a			(    self     ,					_a		)       -> Optional[int]:
							lowerCAmelCase_				=							Node(__SCREAMING_SNAKE_CASE     ,					self.head		)
							self.size += 1




					def  __a			(    self		)       -> Tuple:
							# Switched 'self.is_empty()' to 'self.head is None'
							# because mypy was considering the possibility that 'self.head'
							# can be None in below else part and giving error
							if self.head is None:
									return None
							else:
									lowerCAmelCase_				=							self.head.item
									lowerCAmelCase_				=							self.head.next
									self.size -= 1
									return item




					def  __a			(    self		)       -> Any:
							return self.head is None




					def __str__(    self		)       -> Tuple:
							if self.is_empty():
									return ""
							else:
									lowerCAmelCase_				=							self.head
									lowerCAmelCase_				=							""
									lowerCAmelCase_				=							[]
									while iterate:
											item_list.append(str(iterate.item		)		)
											lowerCAmelCase_				=							iterate.next

									lowerCAmelCase_				=							" --> ".join(__SCREAMING_SNAKE_CASE		)

									return item_str




					def __len__(    self		)       -> Optional[Any]:
							return self.size




"""simple docstring"""




import copy

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


__A     :    str    =		logging.get_logger(__name__)

__A     :    Union[str, Any]    =		{
    '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 (   _A						):


		def __init__(self :		int     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=2_5_6     ,     __SCREAMING_SNAKE_CASE :		List[str]=1_0_2_4     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_6     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_6     ,     __SCREAMING_SNAKE_CASE :		List[str]=4     ,     __SCREAMING_SNAKE_CASE :		List[Any]="gelu"     ,     __SCREAMING_SNAKE_CASE :		str=1E-6     ,     **__SCREAMING_SNAKE_CASE :		Optional[int]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					hidden_size
							A			=					image_size
							A			=					patch_size
							A			=					image_size // patch_size
							A			=					mask_input_channels
							A			=					num_point_embeddings
							A			=					hidden_act
							A			=					layer_norm_eps





class 			__UpperCamelCase (   _A						):


		def __init__(self :		List[Any]     ,     __SCREAMING_SNAKE_CASE :		Tuple=2_5_6     ,     __SCREAMING_SNAKE_CASE :		str="relu"     ,     __SCREAMING_SNAKE_CASE :		List[Any]=2_0_4_8     ,     __SCREAMING_SNAKE_CASE :		Tuple=2     ,     __SCREAMING_SNAKE_CASE :		Any=8     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=2     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=3     ,     __SCREAMING_SNAKE_CASE :		List[Any]=3     ,     __SCREAMING_SNAKE_CASE :		Tuple=2_5_6     ,     __SCREAMING_SNAKE_CASE :		int=1E-6     ,     **__SCREAMING_SNAKE_CASE :		int     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					hidden_size
							A			=					hidden_act
							A			=					mlp_dim
							A			=					num_hidden_layers
							A			=					num_attention_heads
							A			=					attention_downsample_rate
							A			=					num_multimask_outputs
							A			=					iou_head_depth
							A			=					iou_head_hidden_dim
							A			=					layer_norm_eps





class 			__UpperCamelCase (   _A						):


		def __init__(self :		List[str]     ,     __SCREAMING_SNAKE_CASE :		List[Any]=7_6_8     ,     __SCREAMING_SNAKE_CASE :		int=2_5_6     ,     __SCREAMING_SNAKE_CASE :		Tuple=1_2     ,     __SCREAMING_SNAKE_CASE :		str=1_2     ,     __SCREAMING_SNAKE_CASE :		Any=3     ,     __SCREAMING_SNAKE_CASE :		Dict=1_0_2_4     ,     __SCREAMING_SNAKE_CASE :		str=1_6     ,     __SCREAMING_SNAKE_CASE :		Tuple="gelu"     ,     __SCREAMING_SNAKE_CASE :		int=1E-06     ,     __SCREAMING_SNAKE_CASE :		Dict=0.0     ,     __SCREAMING_SNAKE_CASE :		str=1E-10     ,     __SCREAMING_SNAKE_CASE :		List[str]=True     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=4.0     ,     __SCREAMING_SNAKE_CASE :		str=True     ,     __SCREAMING_SNAKE_CASE :		Any=True     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=1_4     ,     __SCREAMING_SNAKE_CASE :		Tuple=[2, 5, 8, 1_1]     ,     __SCREAMING_SNAKE_CASE :		str=1_2_8     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=None     ,     **__SCREAMING_SNAKE_CASE :		Optional[Any]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)

							A			=					hidden_size
							A			=					output_channels
							A			=					num_hidden_layers
							A			=					num_attention_heads
							A			=					num_channels
							A			=					image_size
							A			=					patch_size
							A			=					hidden_act
							A			=					layer_norm_eps
							A			=					attention_dropout
							A			=					initializer_range
							A			=					qkv_bias
							A			=					mlp_ratio
							A			=					use_abs_pos
							A			=					use_rel_pos
							A			=					window_size
							A			=					global_attn_indexes
							A			=					num_pos_feats
							A			=					int(hidden_size * mlp_ratio) if mlp_dim is None else mlp_dim





class 			__UpperCamelCase (   _A						):
		SCREAMING_SNAKE_CASE								=    "sam"
		SCREAMING_SNAKE_CASE								=    True


		def __init__(self :		Optional[int]     ,     __SCREAMING_SNAKE_CASE :		Dict=None     ,     __SCREAMING_SNAKE_CASE :		Union[str, Any]=None     ,     __SCREAMING_SNAKE_CASE :		Optional[int]=None     ,     __SCREAMING_SNAKE_CASE :		List[Any]=0.0_2     ,     **__SCREAMING_SNAKE_CASE :		Optional[Any]     ,     ):
							super().__init__(**__SCREAMING_SNAKE_CASE)
							A			=					vision_config if vision_config is not None else {}
							A			=					prompt_encoder_config if prompt_encoder_config is not None else {}
							A			=					mask_decoder_config if mask_decoder_config is not None else {}

							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					vision_config.to_dict()
							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					prompt_encoder_config.to_dict()
							if isinstance(__SCREAMING_SNAKE_CASE     ,     __SCREAMING_SNAKE_CASE):
												A			=					mask_decoder_config.to_dict()

							A			=					SamVisionConfig(**__SCREAMING_SNAKE_CASE)
							A			=					SamPromptEncoderConfig(**__SCREAMING_SNAKE_CASE)
							A			=					SamMaskDecoderConfig(**__SCREAMING_SNAKE_CASE)
							A			=					initializer_range


		def 					SCREAMING_SNAKE_CASE__   (self :		List[str]):
							A			=					copy.deepcopy(self.__dict__)
							A			=					self.vision_config.to_dict()
							A			=					self.prompt_encoder_config.to_dict()
							A			=					self.mask_decoder_config.to_dict()
							A			=					self.__class__.model_type
							return output





