





'''simple docstring'''






import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


__UpperCamelCase      :   Dict								=     set()
__UpperCamelCase      :   Any								=     get_logger(__name__)





def      lowercase  (  lowerCAmelCase :						Any = None):



				"""simple docstring"""


				def decorator(lowerCAmelCase :						List[str]):
								global _emitted_deprecation_warnings

								if inspect.isclass(_SCREAMING_SNAKE_CASE):
												_A :				Optional[Any]				=  deprecated_class_or_function.__init__
												_A :				Tuple				=  deprecated_class_or_function.__name__
								else:
												_A :				Optional[int]				=  deprecated_class_or_function
												_A :				List[Any]				=  deprecated_function.__name__
												# Support deprecating __init__ class method: class name instead
												_A :				Tuple				=  name if name != '''__init__''' else deprecated_function.__qualname__.split('''.''')[-2]

								_A :				Optional[int]				=  (
								    f"""{name} is deprecated and will be removed in the next major version of datasets.""" + f""" {help_message}"""
								    if help_message
								    else ''''''
								)

								@wraps(_SCREAMING_SNAKE_CASE)
								def wrapper(*lowerCAmelCase :						Union[str, Any]   , **lowerCAmelCase :						int):
												_A :				str				=  hash(_SCREAMING_SNAKE_CASE)
												if func_hash not in _emitted_deprecation_warnings:
																warnings.warn(_SCREAMING_SNAKE_CASE   , category=_SCREAMING_SNAKE_CASE   , stacklevel=2)
																_emitted_deprecation_warnings.add(_SCREAMING_SNAKE_CASE)
												return deprecated_function(*_SCREAMING_SNAKE_CASE   , **_SCREAMING_SNAKE_CASE)

								_A :				Dict				=  '''deprecated'''

								if inspect.isclass(_SCREAMING_SNAKE_CASE):
												_A :				Optional[int]				=  wrapper
												return deprecated_class_or_function
								else:
												return wrapper

				return decorator



class  lowerCamelCase__				(						enum.EnumMeta						):


	"""simple docstring"""





	def __getattribute__(					cls   ,     UpperCAmelCase__			)       ->				Union[str, Any]:
					_A :				Any				=  super().__getattribute__(lowerCamelCase__			)
					if isinstance(lowerCamelCase__   ,     enum.Enum			) and obj._on_access:
									obj._on_access()
					return obj




	def __getitem__(					cls   ,     UpperCAmelCase__			)       ->				Optional[int]:
					_A :				Optional[Any]				=  super().__getitem__(lowerCamelCase__			)
					if member._on_access:
									member._on_access()
					return member




	def __call__(					cls   ,     UpperCAmelCase__   ,     UpperCAmelCase__=None   ,     *, UpperCAmelCase__=None   ,     UpperCAmelCase__=None   ,     UpperCAmelCase__=None   ,     UpperCAmelCase__=1			)       ->				str:
					_A :				Tuple				=  super().__call__(lowerCamelCase__   ,     lowerCamelCase__   ,     module=lowerCamelCase__   ,     qualname=lowerCamelCase__   ,     type=lowerCamelCase__   ,     start=lowerCamelCase__			)
					if isinstance(lowerCamelCase__   ,     enum.Enum			) and obj._on_access:
									obj._on_access()
					return obj



class  lowerCamelCase__				(						enum.Enum  ,							metaclass=lowerCAmelCase_						):


	"""simple docstring"""





	def __new__(					cls   ,     UpperCAmelCase__			)       ->				Optional[int]:
					_A :				Union[str, Any]				=  object.__new__(cls			)
					_A :				str				=  value
					_A :				Tuple				=  member.deprecate
					return member




	@property
	def 				_lowerCamelCase				(					self			)       ->				Union[str, Any]:
					return ""




	def 				_lowerCamelCase				(					self			)       ->				List[str]:
					_A :				List[Any]				=  F""" {self.help_message}""" if self.help_message else ''''''
					warnings.warn(
					    F"""'{self.__objclass__.__name__}' is deprecated and will be removed in the next major version of datasets."""
					    + help_message   ,     lowerCamelCase__   ,     stacklevel=3   ,     )







import copy

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


SCREAMING_SNAKE_CASE_		  =			logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_		  =			{
    """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__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       List[str]		,lowerCamelCase__		:       int=256		,lowerCamelCase__		:       List[Any]=1024		,lowerCamelCase__		:       Any=16		,lowerCamelCase__		:       Union[str, Any]=16		,lowerCamelCase__		:       int=4		,lowerCamelCase__		:       Tuple="gelu"		,lowerCamelCase__		:       Dict=1e-6		,**lowerCamelCase__		:       int		,)	->						List[str]:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		hidden_size
           SCREAMING_SNAKE_CASE						=		image_size
           SCREAMING_SNAKE_CASE						=		patch_size
           SCREAMING_SNAKE_CASE						=		image_size // patch_size
           SCREAMING_SNAKE_CASE						=		mask_input_channels
           SCREAMING_SNAKE_CASE						=		num_point_embeddings
           SCREAMING_SNAKE_CASE						=		hidden_act
           SCREAMING_SNAKE_CASE						=		layer_norm_eps

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       str		,lowerCamelCase__		:       str=256		,lowerCamelCase__		:       Optional[Any]="relu"		,lowerCamelCase__		:       str=2048		,lowerCamelCase__		:       Union[str, Any]=2		,lowerCamelCase__		:       int=8		,lowerCamelCase__		:       Union[str, Any]=2		,lowerCamelCase__		:       List[Any]=3		,lowerCamelCase__		:       int=3		,lowerCamelCase__		:       Optional[Any]=256		,lowerCamelCase__		:       Tuple=1e-6		,**lowerCamelCase__		:       List[str]		,)	->						Dict:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		hidden_size
           SCREAMING_SNAKE_CASE						=		hidden_act
           SCREAMING_SNAKE_CASE						=		mlp_dim
           SCREAMING_SNAKE_CASE						=		num_hidden_layers
           SCREAMING_SNAKE_CASE						=		num_attention_heads
           SCREAMING_SNAKE_CASE						=		attention_downsample_rate
           SCREAMING_SNAKE_CASE						=		num_multimask_outputs
           SCREAMING_SNAKE_CASE						=		iou_head_depth
           SCREAMING_SNAKE_CASE						=		iou_head_hidden_dim
           SCREAMING_SNAKE_CASE						=		layer_norm_eps

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     def __init__(				self		:       Union[str, Any]		,lowerCamelCase__		:       Optional[Any]=768		,lowerCamelCase__		:       Union[str, Any]=256		,lowerCamelCase__		:       Optional[int]=12		,lowerCamelCase__		:       str=12		,lowerCamelCase__		:       Tuple=3		,lowerCamelCase__		:       Optional[Any]=1024		,lowerCamelCase__		:       Optional[int]=16		,lowerCamelCase__		:       Optional[Any]="gelu"		,lowerCamelCase__		:       int=1e-0_6		,lowerCamelCase__		:       Optional[Any]=0.0		,lowerCamelCase__		:       Tuple=1e-1_0		,lowerCamelCase__		:       Any=True		,lowerCamelCase__		:       List[Any]=4.0		,lowerCamelCase__		:       Optional[int]=True		,lowerCamelCase__		:       Union[str, Any]=True		,lowerCamelCase__		:       List[str]=14		,lowerCamelCase__		:       List[str]=[2, 5, 8, 11]		,lowerCamelCase__		:       Tuple=128		,lowerCamelCase__		:       Dict=None		,**lowerCamelCase__		:       Optional[Any]		,)	->						str:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)

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

class 						UpperCamelCase__					( lowerCAmelCase_  ):



     '''simple docstring'''

     __snake_case       :      Any						      =     "sam"
     __snake_case       :      Optional[Any]						      =     True






     def __init__(				self		:       Union[str, Any]		,lowerCamelCase__		:       List[Any]=None		,lowerCamelCase__		:       int=None		,lowerCamelCase__		:       int=None		,lowerCamelCase__		:       int=0.02		,**lowerCamelCase__		:       int		,)	->						str:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		vision_config if vision_config is not None else {}
           SCREAMING_SNAKE_CASE						=		prompt_encoder_config if prompt_encoder_config is not None else {}
           SCREAMING_SNAKE_CASE						=		mask_decoder_config if mask_decoder_config is not None else {}

           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		vision_config.to_dict()
           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		prompt_encoder_config.to_dict()
           if isinstance(lowerCamelCase__		,lowerCamelCase__			):
                 SCREAMING_SNAKE_CASE						=		mask_decoder_config.to_dict()

           SCREAMING_SNAKE_CASE						=		SamVisionConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		SamPromptEncoderConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		SamMaskDecoderConfig(**lowerCamelCase__			)
           SCREAMING_SNAKE_CASE						=		initializer_range






     def 							SCREAMING_SNAKE_CASE__    (				self		:       Union[str, Any]			)	->						Optional[Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE						=		copy.deepcopy(self.__dict__			)
           SCREAMING_SNAKE_CASE						=		self.vision_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.prompt_encoder_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.mask_decoder_config.to_dict()
           SCREAMING_SNAKE_CASE						=		self.__class__.model_type
           return output


