




'''simple docstring'''







import copy

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


_lowerCamelCase							:						int								=  logging.get_logger(__name__)

_lowerCamelCase							:						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      lowerCamelCase_							(       UpperCAmelCase_							):




					'''simple docstring'''






					def __init__(    self,  __UpperCamelCase=256,  __UpperCamelCase=1_024,  __UpperCamelCase=16,  __UpperCamelCase=16,  __UpperCamelCase=4,  __UpperCamelCase="gelu",  __UpperCamelCase=1E-6,  **__UpperCamelCase,  ):
							super().__init__(**__UpperCamelCase )
							_snake_case	       =       hidden_size
							_snake_case	       =       image_size
							_snake_case	       =       patch_size
							_snake_case	       =       image_size // patch_size
							_snake_case	       =       mask_input_channels
							_snake_case	       =       num_point_embeddings
							_snake_case	       =       hidden_act
							_snake_case	       =       layer_norm_eps





class      lowerCamelCase_							(       UpperCAmelCase_							):




					'''simple docstring'''






					def __init__(    self,  __UpperCamelCase=256,  __UpperCamelCase="relu",  __UpperCamelCase=2_048,  __UpperCamelCase=2,  __UpperCamelCase=8,  __UpperCamelCase=2,  __UpperCamelCase=3,  __UpperCamelCase=3,  __UpperCamelCase=256,  __UpperCamelCase=1E-6,  **__UpperCamelCase,  ):
							super().__init__(**__UpperCamelCase )
							_snake_case	       =       hidden_size
							_snake_case	       =       hidden_act
							_snake_case	       =       mlp_dim
							_snake_case	       =       num_hidden_layers
							_snake_case	       =       num_attention_heads
							_snake_case	       =       attention_downsample_rate
							_snake_case	       =       num_multimask_outputs
							_snake_case	       =       iou_head_depth
							_snake_case	       =       iou_head_hidden_dim
							_snake_case	       =       layer_norm_eps





class      lowerCamelCase_							(       UpperCAmelCase_							):




					'''simple docstring'''






					def __init__(    self,  __UpperCamelCase=768,  __UpperCamelCase=256,  __UpperCamelCase=12,  __UpperCamelCase=12,  __UpperCamelCase=3,  __UpperCamelCase=1_024,  __UpperCamelCase=16,  __UpperCamelCase="gelu",  __UpperCamelCase=1E-06,  __UpperCamelCase=0.0,  __UpperCamelCase=1E-10,  __UpperCamelCase=True,  __UpperCamelCase=4.0,  __UpperCamelCase=True,  __UpperCamelCase=True,  __UpperCamelCase=14,  __UpperCamelCase=[2, 5, 8, 11],  __UpperCamelCase=128,  __UpperCamelCase=None,  **__UpperCamelCase,  ):
							super().__init__(**__UpperCamelCase )

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





class      lowerCamelCase_							(       UpperCAmelCase_							):




					'''simple docstring'''






					lowercase__    = """sam"""
					lowercase__    = True






					def __init__(    self,  __UpperCamelCase=None,  __UpperCamelCase=None,  __UpperCamelCase=None,  __UpperCamelCase=0.02,  **__UpperCamelCase,  ):
							super().__init__(**__UpperCamelCase )
							_snake_case	       =       vision_config if vision_config is not None else {}
							_snake_case	       =       prompt_encoder_config if prompt_encoder_config is not None else {}
							_snake_case	       =       mask_decoder_config if mask_decoder_config is not None else {}

							if isinstance(__UpperCamelCase,  __UpperCamelCase ):
									_snake_case	       =       vision_config.to_dict()
							if isinstance(__UpperCamelCase,  __UpperCamelCase ):
									_snake_case	       =       prompt_encoder_config.to_dict()
							if isinstance(__UpperCamelCase,  __UpperCamelCase ):
									_snake_case	       =       mask_decoder_config.to_dict()

							_snake_case	       =       SamVisionConfig(**__UpperCamelCase )
							_snake_case	       =       SamPromptEncoderConfig(**__UpperCamelCase )
							_snake_case	       =       SamMaskDecoderConfig(**__UpperCamelCase )
							_snake_case	       =       initializer_range






					def 				__SCREAMING_SNAKE_CASE	(    self ):
							_snake_case	       =       copy.deepcopy(self.__dict__ )
							_snake_case	       =       self.vision_config.to_dict()
							_snake_case	       =       self.prompt_encoder_config.to_dict()
							_snake_case	       =       self.mask_decoder_config.to_dict()
							_snake_case	       =       self.__class__.model_type
							return output











'''simple docstring'''







from functools import lru_cache






@lru_cache
def 		_lowercase		(	lowercase_  ):



		'''simple docstring'''







		if not isinstance(lowercase_						,							lowercase_  ):
				raise TypeError("k must be an integer."  )
		if k < 0:
				raise ValueError("k integer must be greater or equal to zero."  )
		if k == 0:
				return 0
		elif k == 1:
				return 1
		else:
				return fibonacci(k - 1  ) + fibonacci(k - 2  )






def 		_lowercase		(	lowercase_						,							lowercase_  ):



		'''simple docstring'''







		_snake_case	       =       len(lowercase_  )
		# Find m such that F_m >= n where F_i is the i_th fibonacci number.
		_snake_case	       =       0
		while True:
				if fibonacci(lowercase_  ) >= len_list:
						_snake_case	       =       i
						break
				i += 1
		_snake_case	       =       0
		while fibb_k > 0:
				_snake_case	       =       min(
				    offset + fibonacci(fibb_k - 1  )						,							len_list - 1  )  # Prevent out of range
				_snake_case	       =       arr[index_k]
				if item_k_1 == val:
						return index_k
				elif val < item_k_1:
						fibb_k -= 1
				elif val > item_k_1:
						offset += fibonacci(fibb_k - 1  )
						fibb_k -= 2
		else:
				return -1


if __name__ == "__main__":
						import doctest

						doctest.testmod()





