


'''simple docstring'''





import unittest

from diffusers import __version__
from diffusers.utils import deprecate





class       _a							(       unittest.TestCase):
	_a						:						Optional[Any]   					=							'''.'''.join([str(int(__version__.split('''.''')[0]) + 1)] + __version__.split('''.''')[1:])
	_a						:						List[Any]   					=							'''0.0.1'''




	def 							UpperCAmelCase__(      self		:	Any	)-> Dict:
			lowerCAmelCase__     :    int					  =      {'''deprecated_arg''': 4}

			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					lowerCAmelCase__     :    str					  =      deprecate('''deprecated_arg'''	,      self.higher_version	,      '''message'''	,      take_from=_SCREAMING_SNAKE_CASE	)

			assert output == 4
			assert (
			    str(warning.warning	)
			    == F'The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}.'
			    " message"
			)




	def 							UpperCAmelCase__(      self		:	Optional[int]	)-> List[Any]:
			lowerCAmelCase__     :    List[str]					  =      {'''deprecated_arg''': 4}

			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					lowerCAmelCase__     :    List[Any]					  =      deprecate(('''deprecated_arg''', self.higher_version, '''message''')	,      take_from=_SCREAMING_SNAKE_CASE	)

			assert output == 4
			assert (
			    str(warning.warning	)
			    == F'The `deprecated_arg` argument is deprecated and will be removed in version {self.higher_version}.'
			    " message"
			)




	def 							UpperCAmelCase__(      self		:	int	)-> Optional[int]:
			lowerCAmelCase__     :    List[str]					  =      {'''deprecated_arg_1''': 4, '''deprecated_arg_2''': 8}
			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					lowerCAmelCase__     :    List[Any]					  =      deprecate(
					    ('''deprecated_arg_1''', self.higher_version, '''Hey''')	,      ('''deprecated_arg_2''', self.higher_version, '''Hey''')	,      take_from=_SCREAMING_SNAKE_CASE	,      )
			assert output_a == 4
			assert output_a == 8
			assert (
			    str(warning.warnings[0].message	)
			    == "The `deprecated_arg_1` argument is deprecated and will be removed in version"
			    F' {self.higher_version}. Hey'
			)
			assert (
			    str(warning.warnings[1].message	)
			    == "The `deprecated_arg_2` argument is deprecated and will be removed in version"
			    F' {self.higher_version}. Hey'
			)




	def 							UpperCAmelCase__(      self		:	Union[str, Any]	)-> Dict:
			lowerCAmelCase__     :    Any					  =      {'''deprecated_arg''': 4}

			with self.assertRaises(_SCREAMING_SNAKE_CASE	) as error:
					deprecate(('''wrong_arg''', self.higher_version, '''message''')	,      take_from=_SCREAMING_SNAKE_CASE	)

			assert "test_deprecate_function_incorrect_arg in" in str(error.exception	)
			assert "line" in str(error.exception	)
			assert "got an unexpected keyword argument `deprecated_arg`" in str(error.exception	)




	def 							UpperCAmelCase__(      self		:	int	)-> Dict:
			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					deprecate(('''deprecated_arg''', self.higher_version, '''message''')	)

			assert (
			    str(warning.warning	)
			    == F'`deprecated_arg` is deprecated and will be removed in version {self.higher_version}. message'
			)




	def 							UpperCAmelCase__(      self		:	Tuple	)-> Tuple:
			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					deprecate(
					    ('''deprecated_arg_1''', self.higher_version, '''Hey''')	,      ('''deprecated_arg_2''', self.higher_version, '''Hey''')	,      )
			assert (
			    str(warning.warnings[0].message	)
			    == F'`deprecated_arg_1` is deprecated and will be removed in version {self.higher_version}. Hey'
			)
			assert (
			    str(warning.warnings[1].message	)
			    == F'`deprecated_arg_2` is deprecated and will be removed in version {self.higher_version}. Hey'
			)




	def 							UpperCAmelCase__(      self		:	Any	)-> Optional[int]:





			class       _a							:
				_a						:						Union[str, Any]   					=							5

			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					lowerCAmelCase__     :    str					  =      deprecate(('''arg''', self.higher_version, '''message''')	,      take_from=Args()	)

			assert arg == 5
			assert (
			    str(warning.warning	)
			    == F'The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'
			)




	def 							UpperCAmelCase__(      self		:	Dict	)-> Optional[Any]:





			class       _a							:
				_a						:						str   					=							5
				_a						:						Union[str, Any]   					=							7

			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					lowerCAmelCase__     :    Tuple					  =      deprecate(
					    ('''arg''', self.higher_version, '''message''')	,      ('''foo''', self.higher_version, '''message''')	,      ('''does not exist''', self.higher_version, '''message''')	,      take_from=Args()	,      )

			assert arg_a == 5
			assert arg_a == 7
			assert (
			    str(warning.warning	)
			    == F'The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'
			)
			assert (
			    str(warning.warnings[0].message	)
			    == F'The `arg` attribute is deprecated and will be removed in version {self.higher_version}. message'
			)
			assert (
			    str(warning.warnings[1].message	)
			    == F'The `foo` attribute is deprecated and will be removed in version {self.higher_version}. message'
			)




	def 							UpperCAmelCase__(      self		:	Tuple	)-> Tuple:
			lowerCAmelCase__     :    int					  =      {'''deprecated_arg''': 4}

			with self.assertRaises(_SCREAMING_SNAKE_CASE	) as error:
					deprecate(('''wrong_arg''', self.lower_version, '''message''')	,      take_from=_SCREAMING_SNAKE_CASE	)

			assert (
			    str(error.exception	)
			    == "The deprecation tuple ('wrong_arg', '0.0.1', 'message') should be removed since diffusers' version"
			    F' {__version__} is >= {self.lower_version}'
			)




	def 							UpperCAmelCase__(      self		:	List[str]	)-> int:
			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					deprecate(('''deprecated_arg''', self.higher_version, '''This message is better!!!''')	,      standard_warn=_SCREAMING_SNAKE_CASE	)

			assert str(warning.warning	) == "This message is better!!!"




	def 							UpperCAmelCase__(      self		:	Optional[int]	)-> Optional[int]:
			with self.assertWarns(_SCREAMING_SNAKE_CASE	) as warning:
					deprecate(('''deprecated_arg''', self.higher_version, '''This message is better!!!''')	,      standard_warn=_SCREAMING_SNAKE_CASE	)
			assert str(warning.warning	) == "This message is better!!!"
			assert "diffusers/tests/others/test_utils.py" in warning.filename








import copy

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


lowerCamelCase		=	logging.get_logger(__name__)

lowerCamelCase		=	{
    '''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):




	def __init__(      self		:	Union[str, Any]	,      _SCREAMING_SNAKE_CASE		:	Tuple=256	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=1024	,      _SCREAMING_SNAKE_CASE		:	List[Any]=16	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=16	,      _SCREAMING_SNAKE_CASE		:	Union[str, Any]=4	,      _SCREAMING_SNAKE_CASE		:	Any="gelu"	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=1E-6	,      **_SCREAMING_SNAKE_CASE		:	List[Any]	,      )-> Tuple:
			super().__init__(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Any					  =      hidden_size
			lowerCAmelCase__     :    Tuple					  =      image_size
			lowerCAmelCase__     :    List[Any]					  =      patch_size
			lowerCAmelCase__     :    Any					  =      image_size // patch_size
			lowerCAmelCase__     :    Dict					  =      mask_input_channels
			lowerCAmelCase__     :    Dict					  =      num_point_embeddings
			lowerCAmelCase__     :    str					  =      hidden_act
			lowerCAmelCase__     :    List[Any]					  =      layer_norm_eps





class       _a							(       _lowercase):




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





class       _a							(       _lowercase):




	def __init__(      self		:	List[str]	,      _SCREAMING_SNAKE_CASE		:	int=768	,      _SCREAMING_SNAKE_CASE		:	str=256	,      _SCREAMING_SNAKE_CASE		:	int=12	,      _SCREAMING_SNAKE_CASE		:	Tuple=12	,      _SCREAMING_SNAKE_CASE		:	Dict=3	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=1024	,      _SCREAMING_SNAKE_CASE		:	Tuple=16	,      _SCREAMING_SNAKE_CASE		:	List[Any]="gelu"	,      _SCREAMING_SNAKE_CASE		:	Optional[int]=1E-06	,      _SCREAMING_SNAKE_CASE		:	int=0.0	,      _SCREAMING_SNAKE_CASE		:	int=1E-10	,      _SCREAMING_SNAKE_CASE		:	List[Any]=True	,      _SCREAMING_SNAKE_CASE		:	Any=4.0	,      _SCREAMING_SNAKE_CASE		:	List[str]=True	,      _SCREAMING_SNAKE_CASE		:	int=True	,      _SCREAMING_SNAKE_CASE		:	List[str]=14	,      _SCREAMING_SNAKE_CASE		:	Dict=[2, 5, 8, 11]	,      _SCREAMING_SNAKE_CASE		:	List[Any]=128	,      _SCREAMING_SNAKE_CASE		:	Dict=None	,      **_SCREAMING_SNAKE_CASE		:	str	,      )-> Any:
			super().__init__(**_SCREAMING_SNAKE_CASE	)

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





class       _a							(       _lowercase):
	_a						:						Tuple   					=							'''sam'''
	_a						:						Optional[Any]   					=							True




	def __init__(      self		:	Optional[Any]	,      _SCREAMING_SNAKE_CASE		:	Any=None	,      _SCREAMING_SNAKE_CASE		:	Optional[Any]=None	,      _SCREAMING_SNAKE_CASE		:	int=None	,      _SCREAMING_SNAKE_CASE		:	Tuple=0.02	,      **_SCREAMING_SNAKE_CASE		:	int	,      )-> Optional[int]:
			super().__init__(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Tuple					  =      vision_config if vision_config is not None else {}
			lowerCAmelCase__     :    List[str]					  =      prompt_encoder_config if prompt_encoder_config is not None else {}
			lowerCAmelCase__     :    List[str]					  =      mask_decoder_config if mask_decoder_config is not None else {}

			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    Any					  =      vision_config.to_dict()
			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    Any					  =      prompt_encoder_config.to_dict()
			if isinstance(_SCREAMING_SNAKE_CASE	,      _SCREAMING_SNAKE_CASE	):
					lowerCAmelCase__     :    List[Any]					  =      mask_decoder_config.to_dict()

			lowerCAmelCase__     :    Any					  =      SamVisionConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[Any]					  =      SamPromptEncoderConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    Dict					  =      SamMaskDecoderConfig(**_SCREAMING_SNAKE_CASE	)
			lowerCAmelCase__     :    List[Any]					  =      initializer_range




	def 							UpperCAmelCase__(      self		:	Any	)-> int:
			lowerCAmelCase__     :    Optional[int]					  =      copy.deepcopy(self.__dict__	)
			lowerCAmelCase__     :    Any					  =      self.vision_config.to_dict()
			lowerCAmelCase__     :    Optional[Any]					  =      self.prompt_encoder_config.to_dict()
			lowerCAmelCase__     :    str					  =      self.mask_decoder_config.to_dict()
			lowerCAmelCase__     :    Any					  =      self.__class__.model_type
			return output




