






'''simple docstring'''




import copy

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


__SCREAMING_SNAKE_CASE :  str  =						logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE :  Optional[int]  =						{
    """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		:       str		,      A		:       Optional[int]=256		,      A		:       Optional[Any]=1024		,      A		:       Any=16		,      A		:       List[Any]=16		,      A		:       List[str]=4		,      A		:       Union[str, Any]="gelu"		,      A		:       Dict=1E-6		,      **A		:       str		,      ):
             super().__init__(**A )
             _UpperCAmelCase  :						Union[str, Any]							   =					hidden_size
             _UpperCAmelCase  :						int							   =					image_size
             _UpperCAmelCase  :						Tuple							   =					patch_size
             _UpperCAmelCase  :						int							   =					image_size // patch_size
             _UpperCAmelCase  :						Union[str, Any]							   =					mask_input_channels
             _UpperCAmelCase  :						Optional[int]							   =					num_point_embeddings
             _UpperCAmelCase  :						List[str]							   =					hidden_act
             _UpperCAmelCase  :						Union[str, Any]							   =					layer_norm_eps

class 			lowerCamelCase_			(A_					):
      '''simple docstring'''

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

class 			lowerCamelCase_			(A_					):
      '''simple docstring'''

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

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

class 			lowerCamelCase_			(A_					):
      '''simple docstring'''

      __UpperCamelCase:						Optional[int]      			=		'''sam'''
      __UpperCamelCase:						Tuple      			=		True




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

             if isinstance(A		,      A ):
                    _UpperCAmelCase  :						Any							   =					vision_config.to_dict()
             if isinstance(A		,      A ):
                    _UpperCAmelCase  :						List[Any]							   =					prompt_encoder_config.to_dict()
             if isinstance(A		,      A ):
                    _UpperCAmelCase  :						List[str]							   =					mask_decoder_config.to_dict()

             _UpperCAmelCase  :						Any							   =					SamVisionConfig(**A )
             _UpperCAmelCase  :						List[str]							   =					SamPromptEncoderConfig(**A )
             _UpperCAmelCase  :						Optional[Any]							   =					SamMaskDecoderConfig(**A )
             _UpperCAmelCase  :						int							   =					initializer_range





      def   _A			( self		:       Tuple ):
             _UpperCAmelCase  :						List[Any]							   =					copy.deepcopy(self.__dict__ )
             _UpperCAmelCase  :						Union[str, Any]							   =					self.vision_config.to_dict()
             _UpperCAmelCase  :						Union[str, Any]							   =					self.prompt_encoder_config.to_dict()
             _UpperCAmelCase  :						Any							   =					self.mask_decoder_config.to_dict()
             _UpperCAmelCase  :						List[Any]							   =					self.__class__.model_type
             return output


'''simple docstring'''




import pytest

from datasets.utils.version import Version

@pytest.mark.parametrize(
    "other, expected_equality"    ,			[
        (Version("1.0.0"					), True),
        ("1.0.0", True),
        (Version("2.0.0"					), False),
        ("2.0.0", False),
        ("1", False),
        ("a", False),
        (1, False),
        (None, False),
    ]    ,			)
def 			UpperCamelCase_							(      _UpperCAmelCase						:   Tuple    ,			_UpperCAmelCase						:   List[Any]					)					->					int:


       """simple docstring"""







       _UpperCAmelCase  :						Union[str, Any]							   =					Version("1.0.0"					)
       assert (version == other) is expected_equality
       assert (version != other) is not expected_equality
       assert (hash(_UpperCAmelCase					) == hash(_UpperCAmelCase					)) is expected_equality

