





from .number_theory.prime_numbers import next_prime



class  _a  :






							"""simple docstring"""

							def __init__(   self					:  int				,						a					:  int				,						a					:  int | None = None				,						a					:  float | None = None				,						)						->None:
													SCREAMING_SNAKE_CASE__  :					str =       size_table
													SCREAMING_SNAKE_CASE__  :					str =       [None] * self.size_table
													SCREAMING_SNAKE_CASE__  :					List[Any] =       0.75 if lim_charge is None else lim_charge
													SCREAMING_SNAKE_CASE__  :					str =       1 if charge_factor is None else charge_factor
													SCREAMING_SNAKE_CASE__  :					list =       []
													SCREAMING_SNAKE_CASE__  :					dict =       {}

							def   A_	(   self					:  List[Any]     )						->Tuple:
													return self._keys

							def   A_	(   self					:  Union[str, Any]     )						->Optional[int]:
													return sum(1 for slot in self.values if slot is not None     ) / (
													    self.size_table * self.charge_factor
													)

							def   A_	(   self					:  Dict				,						a					:  List[str]     )						->Optional[int]:
													return key % self.size_table

							def   A_	(   self					:  Tuple				,						a					:  List[Any]     )						->Tuple:
													print(f"""step {step_ord}"""     )
													print(list(range(len(self.values     )     )     )     )
													print(self.values     )

							def   A_	(   self					:  Dict				,						a					:  Any     )						->str:
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       1
													SCREAMING_SNAKE_CASE__  :					Tuple =       values
													for value in values:
																			self.insert_data(a     )
																			self._step_by_step(a     )
																			i += 1

							def   A_	(   self					:  Tuple				,						a					:  Dict				,						a					:  List[Any]     )						->Optional[Any]:
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       data
													SCREAMING_SNAKE_CASE__  :					List[Any] =       data

							def   A_	(   self					:  str				,						a					:  str				,						a					:  List[str]=None     )						->List[str]:
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.hash_function(key + 1     )

													while self.values[new_key] is not None and self.values[new_key] != key:
																			if self.values.count(a     ) > 0:
																									SCREAMING_SNAKE_CASE__  :					List[Any] =       self.hash_function(new_key + 1     )
																			else:
																									SCREAMING_SNAKE_CASE__  :					List[Any] =       None
																									break

													return new_key

							def   A_	(   self					:  List[Any]     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       [value for value in self.values if value is not None]
													SCREAMING_SNAKE_CASE__  :					List[str] =       next_prime(self.size_table				,						factor=2     )
													self._keys.clear()
													SCREAMING_SNAKE_CASE__  :					Dict =       [None] * self.size_table  # hell's pointers D: don't DRY ;/
													for value in survivor_values:
																			self.insert_data(a     )






							def   A_	(   self					:  Optional[int]				,						a					:  List[Any]     )						->Union[str, Any]:
													SCREAMING_SNAKE_CASE__  :					List[Any] =       self.hash_function(a     )

													if self.values[key] is None:
																			self._set_value(a				,						a     )

													elif self.values[key] == data:
																			pass

													else:
																			SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self._collision_resolution(a				,						a     )
																			if collision_resolution is not None:
																									self._set_value(a				,						a     )
																			else:
																									self.rehashing()
																									self.insert_data(a     )






import copy

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


__lowercase							:List[Any]							=	logging.get_logger(__name__)

__lowercase							:Optional[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  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  List[Any]				,						a					:  int=2_56				,						a					:  Tuple=10_24				,						a					:  Optional[Any]=16				,						a					:  Dict=16				,						a					:  str=4				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[Any]=1E-6				,						**a					:  Dict				,						)						->Union[str, Any]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Any =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       image_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       patch_size
													SCREAMING_SNAKE_CASE__  :					str =       image_size // patch_size
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       mask_input_channels
													SCREAMING_SNAKE_CASE__  :					Any =       num_point_embeddings
													SCREAMING_SNAKE_CASE__  :					str =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Union[str, Any]				,						a					:  Optional[int]=2_56				,						a					:  Dict="relu"				,						a					:  Dict=20_48				,						a					:  Union[str, Any]=2				,						a					:  str=8				,						a					:  str=2				,						a					:  List[Any]=3				,						a					:  str=3				,						a					:  List[str]=2_56				,						a					:  str=1E-6				,						**a					:  Optional[int]				,						)						->Dict:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Dict =       mlp_dim
													SCREAMING_SNAKE_CASE__  :					List[Any] =       num_hidden_layers
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       num_attention_heads
													SCREAMING_SNAKE_CASE__  :					List[Any] =       attention_downsample_rate
													SCREAMING_SNAKE_CASE__  :					List[str] =       num_multimask_outputs
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       iou_head_depth
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       iou_head_hidden_dim
													SCREAMING_SNAKE_CASE__  :					Optional[int] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

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

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







class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    "sam"
							snake_case_							=    True

							def __init__(   self					:  str				,						a					:  Optional[int]=None				,						a					:  Any=None				,						a					:  Any=None				,						a					:  str=0.02				,						**a					:  int				,						)						->Optional[int]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       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__  :					Tuple =       mask_decoder_config if mask_decoder_config is not None else {}

													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Tuple =       vision_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Dict =       prompt_encoder_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       mask_decoder_config.to_dict()

													SCREAMING_SNAKE_CASE__  :					str =       SamVisionConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					str =       SamPromptEncoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					int =       SamMaskDecoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       initializer_range






							def   A_	(   self					:  str     )						->Dict:
													SCREAMING_SNAKE_CASE__  :					int =       copy.deepcopy(self.__dict__     )
													SCREAMING_SNAKE_CASE__  :					str =       self.vision_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       self.prompt_encoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Optional[Any] =       self.mask_decoder_config.to_dict()
													SCREAMING_SNAKE_CASE__  :					Tuple =       self.__class__.model_type
													return output