



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    _SCREAMING_SNAKE_CASE						(_UpperCAmelCase			):





     def __init__(							self			:				List[str]  ,	UpperCamelCase			:				List[Any]=2_5_6  ,	UpperCamelCase			:				Optional[int]=1_0_2_4  ,	UpperCamelCase			:				List[Any]=1_6  ,	UpperCamelCase			:				Union[str, Any]=1_6  ,	UpperCamelCase			:				int=4  ,	UpperCamelCase			:				Dict="gelu"  ,	UpperCamelCase			:				Optional[int]=1E-6  ,	**UpperCamelCase			:				int  ,	)->str:
      super().__init__(**_lowerCAmelCase					)
      __SCREAMING_SNAKE_CASE							:     Optional[int]							=						hidden_size
      __SCREAMING_SNAKE_CASE							:     List[Any]							=						image_size
      __SCREAMING_SNAKE_CASE							:     Optional[Any]							=						patch_size
      __SCREAMING_SNAKE_CASE							:     Any							=						image_size // patch_size
      __SCREAMING_SNAKE_CASE							:     List[Any]							=						mask_input_channels
      __SCREAMING_SNAKE_CASE							:     Any							=						num_point_embeddings
      __SCREAMING_SNAKE_CASE							:     Tuple							=						hidden_act
      __SCREAMING_SNAKE_CASE							:     Optional[int]							=						layer_norm_eps






class    _SCREAMING_SNAKE_CASE						(_UpperCAmelCase			):





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






class    _SCREAMING_SNAKE_CASE						(_UpperCAmelCase			):





     def __init__(							self			:				Any  ,	UpperCamelCase			:				str=7_6_8  ,	UpperCamelCase			:				Optional[int]=2_5_6  ,	UpperCamelCase			:				Tuple=1_2  ,	UpperCamelCase			:				Optional[int]=1_2  ,	UpperCamelCase			:				Tuple=3  ,	UpperCamelCase			:				Optional[int]=1_0_2_4  ,	UpperCamelCase			:				Optional[int]=1_6  ,	UpperCamelCase			:				Optional[int]="gelu"  ,	UpperCamelCase			:				Any=1E-06  ,	UpperCamelCase			:				Dict=0.0  ,	UpperCamelCase			:				Optional[int]=1E-10  ,	UpperCamelCase			:				str=True  ,	UpperCamelCase			:				Union[str, Any]=4.0  ,	UpperCamelCase			:				Optional[int]=True  ,	UpperCamelCase			:				str=True  ,	UpperCamelCase			:				Tuple=1_4  ,	UpperCamelCase			:				Optional[Any]=[2, 5, 8, 1_1]  ,	UpperCamelCase			:				int=1_2_8  ,	UpperCamelCase			:				Tuple=None  ,	**UpperCamelCase			:				Any  ,	)->Union[str, Any]:
      super().__init__(**_lowerCAmelCase					)

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






class    _SCREAMING_SNAKE_CASE						(_UpperCAmelCase			):
     lowerCAmelCase       =      "sam"
     lowerCAmelCase       =      True





     def __init__(							self			:				Tuple  ,	UpperCamelCase			:				Optional[Any]=None  ,	UpperCamelCase			:				Any=None  ,	UpperCamelCase			:				List[Any]=None  ,	UpperCamelCase			:				List[str]=0.0_2  ,	**UpperCamelCase			:				int  ,	)->int:
      super().__init__(**_lowerCAmelCase					)
      __SCREAMING_SNAKE_CASE							:     Optional[int]							=						vision_config if vision_config is not None else {}
      __SCREAMING_SNAKE_CASE							:     str							=						prompt_encoder_config if prompt_encoder_config is not None else {}
      __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						mask_decoder_config if mask_decoder_config is not None else {}

      if isinstance(_lowerCAmelCase  ,	_lowerCAmelCase					):
       __SCREAMING_SNAKE_CASE							:     Any							=						vision_config.to_dict()
      if isinstance(_lowerCAmelCase  ,	_lowerCAmelCase					):
       __SCREAMING_SNAKE_CASE							:     Dict							=						prompt_encoder_config.to_dict()
      if isinstance(_lowerCAmelCase  ,	_lowerCAmelCase					):
       __SCREAMING_SNAKE_CASE							:     Dict							=						mask_decoder_config.to_dict()

      __SCREAMING_SNAKE_CASE							:     Optional[Any]							=						SamVisionConfig(**_lowerCAmelCase					)
      __SCREAMING_SNAKE_CASE							:     Tuple							=						SamPromptEncoderConfig(**_lowerCAmelCase					)
      __SCREAMING_SNAKE_CASE							:     List[Any]							=						SamMaskDecoderConfig(**_lowerCAmelCase					)
      __SCREAMING_SNAKE_CASE							:     Optional[int]							=						initializer_range






     def 						__snake_case     (							self			:				List[str]					)->Dict:
      __SCREAMING_SNAKE_CASE							:     Any							=						copy.deepcopy(self.__dict__					)
      __SCREAMING_SNAKE_CASE							:     Optional[int]							=						self.vision_config.to_dict()
      __SCREAMING_SNAKE_CASE							:     Dict							=						self.prompt_encoder_config.to_dict()
      __SCREAMING_SNAKE_CASE							:     Tuple							=						self.mask_decoder_config.to_dict()
      __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						self.__class__.model_type
      return output










from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


UpperCamelCase			:					List[Any]         =							logging.get_logger(__name__)

UpperCamelCase			:					Tuple         =							{
    '''mnaylor/mega-base-wikitext''': '''https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json''',
}

class      __snake_case				(   _UpperCAmelCase):
					SCREAMING_SNAKE_CASE_		:       str								=			"mega"
					def __init__(						self       :						Optional[int]	,      _lowerCAmelCase       :						List[Any]=3_0_5_2_2	,      _lowerCAmelCase       :						List[str]=1_2_8	,      _lowerCAmelCase       :						Dict=4	,      _lowerCAmelCase       :						Optional[Any]=2_5_6	,      _lowerCAmelCase       :						Optional[Any]=1_6	,      _lowerCAmelCase       :						Dict=True	,      _lowerCAmelCase       :						Optional[Any]=6_4	,      _lowerCAmelCase       :						Optional[Any]=False	,      _lowerCAmelCase       :						Optional[int]=-1	,      _lowerCAmelCase       :						Any=None	,      _lowerCAmelCase       :						List[Any]=True	,      _lowerCAmelCase       :						List[Any]="scalenorm"	,      _lowerCAmelCase       :						str=True	,      _lowerCAmelCase       :						Union[str, Any]="silu"	,      _lowerCAmelCase       :						Optional[Any]="softmax"	,      _lowerCAmelCase       :						Optional[Any]=0.1	,      _lowerCAmelCase       :						Dict=0.1	,      _lowerCAmelCase       :						Any=0.1	,      _lowerCAmelCase       :						Optional[Any]=False	,      _lowerCAmelCase       :						Any=True	,      _lowerCAmelCase       :						int=2_5_6	,      _lowerCAmelCase       :						List[str]=True	,      _lowerCAmelCase       :						str=0.1	,      _lowerCAmelCase       :						List[str]=2_0_4_8	,      _lowerCAmelCase       :						Optional[Any]=False	,      _lowerCAmelCase       :						str=2	,      _lowerCAmelCase       :						Dict=0.02	,      _lowerCAmelCase       :						str=0.2	,      _lowerCAmelCase       :						List[str]=0.02	,      _lowerCAmelCase       :						int=1.0	,      _lowerCAmelCase       :						Optional[int]=1	,      _lowerCAmelCase       :						List[str]=0	,      _lowerCAmelCase       :						str=2	,      _lowerCAmelCase       :						Optional[Any]="rotary"	,      _lowerCAmelCase       :						int=None	,      _lowerCAmelCase       :						int=True	,      _lowerCAmelCase       :						Optional[Any]=True	,      **_lowerCAmelCase       :						str	,      )							->					Any:



											'''simple docstring'''





											super().__init__(pad_token_id=_lowerCAmelCase	,      bos_token_id=_lowerCAmelCase	,      eos_token_id=_lowerCAmelCase	,      **_lowerCAmelCase  )

											__magic_name__					=      vocab_size
											__magic_name__					=      hidden_size
											__magic_name__					=      num_hidden_layers
											__magic_name__					=      activation
											__magic_name__					=      attention_activation
											__magic_name__					=      intermediate_size
											__magic_name__					=      ema_projection_size
											__magic_name__					=      bidirectional
											__magic_name__					=      shared_representation_size
											__magic_name__					=      use_chunking
											__magic_name__					=      chunk_size
											__magic_name__					=      truncation
											__magic_name__					=      normalize_before_mega
											__magic_name__					=      normalization_type
											__magic_name__					=      norm_affine
											__magic_name__					=      dropout_prob
											__magic_name__					=      hidden_dropout_prob
											__magic_name__					=      attention_probs_dropout_prob
											__magic_name__					=      use_feature_dropout
											__magic_name__					=      use_normalized_ffn
											__magic_name__					=      nffn_hidden_size
											__magic_name__					=      normalize_before_ffn
											__magic_name__					=      nffn_activation_dropout_prob
											__magic_name__					=      max_positions
											__magic_name__					=      add_token_type_embeddings
											__magic_name__					=      type_vocab_size
											__magic_name__					=      initializer_range
											__magic_name__					=      ema_delta_alpha_range
											__magic_name__					=      ema_beta_range
											__magic_name__					=      ema_gamma_omega_range
											__magic_name__					=      relative_positional_bias
											__magic_name__					=      use_cache
											__magic_name__					=      classifier_dropout
											__magic_name__					=      add_lm_hidden_dense_layer
											__magic_name__					=      1  # not used but required by Hugging Face







class      __snake_case				(   _UpperCAmelCase):
					@property
					def 	a			(						self       :						int  )							->					Mapping[str, Mapping[int, str]]:



											'''simple docstring'''





											if self.task == "multiple-choice":
																	__magic_name__					=      {0: 'batch', 1: 'choice', 2: 'sequence'}
											else:
																	__magic_name__					=      {0: 'batch', 1: 'sequence'}
											return OrderedDict(
											    [
											        ('input_ids', dynamic_axis),
											        ('attention_mask', dynamic_axis),
											    ]  )

