
import copy

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


__magic_name__  :  int     			=   logging.get_logger(__name__)

__magic_name__  :  Tuple     			=   {
    '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       (		_A					):



  """simple docstring"""





  def __init__(					self						,    __UpperCamelCase=256						,    __UpperCamelCase=1024						,    __UpperCamelCase=16						,    __UpperCamelCase=16						,    __UpperCamelCase=4						,    __UpperCamelCase="gelu"						,    __UpperCamelCase=1E-6						,    **__UpperCamelCase						,    ):
      super().__init__(**_UpperCAmelCase					)
      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 							lowerCamelCase       (		_A					):



  """simple docstring"""





  def __init__(					self						,    __UpperCamelCase=256						,    __UpperCamelCase="relu"						,    __UpperCamelCase=2048						,    __UpperCamelCase=2						,    __UpperCamelCase=8						,    __UpperCamelCase=2						,    __UpperCamelCase=3						,    __UpperCamelCase=3						,    __UpperCamelCase=256						,    __UpperCamelCase=1E-6						,    **__UpperCamelCase						,    ):
      super().__init__(**_UpperCAmelCase					)
      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 							lowerCamelCase       (		_A					):



  """simple docstring"""





  def __init__(					self						,    __UpperCamelCase=768						,    __UpperCamelCase=256						,    __UpperCamelCase=12						,    __UpperCamelCase=12						,    __UpperCamelCase=3						,    __UpperCamelCase=1024						,    __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					)

      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 							lowerCamelCase       (		_A					):



  """simple docstring"""





  lowerCAmelCase_								=		"""sam"""
  lowerCAmelCase_								=		True

  def __init__(					self						,    __UpperCamelCase=None						,    __UpperCamelCase=None						,    __UpperCamelCase=None						,    __UpperCamelCase=0.02						,    **__UpperCamelCase						,    ):
      super().__init__(**_UpperCAmelCase					)
      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(_UpperCAmelCase						,    _UpperCAmelCase					):
          A_								=					vision_config.to_dict()
      if isinstance(_UpperCAmelCase						,    _UpperCAmelCase					):
          A_								=					prompt_encoder_config.to_dict()
      if isinstance(_UpperCAmelCase						,    _UpperCAmelCase					):
          A_								=					mask_decoder_config.to_dict()

      A_								=					SamVisionConfig(**_UpperCAmelCase					)
      A_								=					SamPromptEncoderConfig(**_UpperCAmelCase					)
      A_								=					SamMaskDecoderConfig(**_UpperCAmelCase					)
      A_								=					initializer_range

  def 					lowercase_						(					self					):
      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










import math
def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:int					)							->	list:
						if n <= 0:
												raise ValueError('Only positive integers have prime factors'					)
						__magic_name__					:				Union[str, Any]				=   []
						while n % 2 == 0:
												pf.append(2					)
												__magic_name__					:				Union[str, Any]				=   int(n / 2					)
						for i in range(3   ,    int(math.sqrt(lowercase__					)					) + 1   ,    2					):
												while n % i == 0:
																		pf.append(lowercase__					)
																		__magic_name__					:				List[str]				=   int(n / i					)
						if n > 2:
												pf.append(lowercase__					)
						return pf
def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:int					)							->	int:
						if n <= 0:
												raise ValueError('Only positive numbers are accepted'					)
						__magic_name__					:				Union[str, Any]				=   1
						__magic_name__					:				Tuple				=   1
						while n % 2 == 0:
												temp += 1
												__magic_name__					:				Any				=   int(n / 2					)
						div *= temp
						for i in range(3   ,    int(math.sqrt(lowercase__					)					) + 1   ,    2					):
												__magic_name__					:				List[Any]				=   1
												while n % i == 0:
																		temp += 1
																		__magic_name__					:				Any				=   int(n / i					)
												div *= temp
						if n > 1:
												div *= 2
						return div
def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:int					)							->	int:
						if n <= 0:
												raise ValueError('Only positive numbers are accepted'					)
						__magic_name__					:				int				=   1
						__magic_name__					:				List[str]				=   1
						while n % 2 == 0:
												temp += 1
												__magic_name__					:				List[Any]				=   int(n / 2					)
						if temp > 1:
												s *= (2**temp - 1) / (2 - 1)
						for i in range(3   ,    int(math.sqrt(lowercase__					)					) + 1   ,    2					):
												__magic_name__					:				int				=   1
												while n % i == 0:
																		temp += 1
																		__magic_name__					:				Optional[Any]				=   int(n / i					)
												if temp > 1:
																		s *= (i**temp - 1) / (i - 1)
						return int(lowercase__					)
def 			__SCREAMING_SNAKE_CASE							(					lowercase__	:int					)							->	int:
						__magic_name__					:				Dict				=   n
						for x in set(prime_factors(lowercase__					)					):
												s *= (x - 1) / x
						return int(lowercase__					)


if __name__ == "__main__":
			import doctest

			doctest.testmod()


