

from collections import OrderedDict
from typing import Mapping

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


_lowerCamelCase							:  str     =				logging.get_logger(__name__)

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





class    __UpperCAmelCase	(			lowercase__		):
   UpperCamelCase  	=	"""mega"""



   def __init__(				self				:	List[Any],						__A				:	List[str]=3_0_5_2_2,						__A				:	Optional[Any]=1_2_8,						__A				:	Optional[int]=4,						__A				:	str=2_5_6,						__A				:	Union[str, Any]=1_6,						__A				:	Any=True,						__A				:	int=6_4,						__A				:	Any=False,						__A				:	List[Any]=-1,						__A				:	Dict=None,						__A				:	Tuple=True,						__A				:	Optional[Any]="scalenorm",						__A				:	Union[str, Any]=True,						__A				:	Union[str, Any]="silu",						__A				:	List[str]="softmax",						__A				:	List[str]=0.1,						__A				:	Union[str, Any]=0.1,						__A				:	Optional[Any]=0.1,						__A				:	List[Any]=False,						__A				:	int=True,						__A				:	Tuple=2_5_6,						__A				:	Optional[Any]=True,						__A				:	List[Any]=0.1,						__A				:	Optional[Any]=2_0_4_8,						__A				:	List[str]=False,						__A				:	Dict=2,						__A				:	int=0.0_2,						__A				:	Optional[int]=0.2,						__A				:	List[str]=0.0_2,						__A				:	List[Any]=1.0,						__A				:	str=1,						__A				:	List[str]=0,						__A				:	Optional[int]=2,						__A				:	Union[str, Any]="rotary",						__A				:	str=None,						__A				:	List[str]=True,						__A				:	List[str]=True,						**__A				:	List[Any],						):
     super().__init__(pad_token_id=__A,						bos_token_id=__A,						eos_token_id=__A,						**__A		)

     UpperCAmelCase			:				Any										=					vocab_size
     UpperCAmelCase			:				str										=					hidden_size
     UpperCAmelCase			:				Optional[int]										=					num_hidden_layers
     UpperCAmelCase			:				Any										=					activation
     UpperCAmelCase			:				str										=					attention_activation
     UpperCAmelCase			:				Dict										=					intermediate_size
     UpperCAmelCase			:				Tuple										=					ema_projection_size
     UpperCAmelCase			:				Any										=					bidirectional
     UpperCAmelCase			:				Dict										=					shared_representation_size
     UpperCAmelCase			:				Any										=					use_chunking
     UpperCAmelCase			:				Tuple										=					chunk_size
     UpperCAmelCase			:				Tuple										=					truncation
     UpperCAmelCase			:				int										=					normalize_before_mega
     UpperCAmelCase			:				Any										=					normalization_type
     UpperCAmelCase			:				Any										=					norm_affine
     UpperCAmelCase			:				Union[str, Any]										=					dropout_prob
     UpperCAmelCase			:				List[Any]										=					hidden_dropout_prob
     UpperCAmelCase			:				List[str]										=					attention_probs_dropout_prob
     UpperCAmelCase			:				Optional[int]										=					use_feature_dropout
     UpperCAmelCase			:				int										=					use_normalized_ffn
     UpperCAmelCase			:				Dict										=					nffn_hidden_size
     UpperCAmelCase			:				Any										=					normalize_before_ffn
     UpperCAmelCase			:				List[Any]										=					nffn_activation_dropout_prob
     UpperCAmelCase			:				Any										=					max_positions
     UpperCAmelCase			:				Optional[Any]										=					add_token_type_embeddings
     UpperCAmelCase			:				Dict										=					type_vocab_size
     UpperCAmelCase			:				str										=					initializer_range
     UpperCAmelCase			:				str										=					ema_delta_alpha_range
     UpperCAmelCase			:				Optional[Any]										=					ema_beta_range
     UpperCAmelCase			:				Optional[int]										=					ema_gamma_omega_range
     UpperCAmelCase			:				Union[str, Any]										=					relative_positional_bias
     UpperCAmelCase			:				Any										=					use_cache
     UpperCAmelCase			:				int										=					classifier_dropout
     UpperCAmelCase			:				int										=					add_lm_hidden_dense_layer
     UpperCAmelCase			:				List[Any]										=					1  # not used but required by Hugging Face






class    __UpperCAmelCase	(			lowercase__		):



   @property
   def 			__magic_name__       (				self				:	Union[str, Any]		):
     if self.task == "multiple-choice":
       UpperCAmelCase			:				List[Any]										=					{0: "batch", 1: "choice", 2: "sequence"}
     else:
       UpperCAmelCase			:				Any										=					{0: "batch", 1: "sequence"}
     return OrderedDict(
         [
             ('''input_ids''', dynamic_axis),
             ('''attention_mask''', dynamic_axis),
         ]		)












import copy

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


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

__lowercase							:Optional[Any]							=	{
    "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__				):






							"""simple docstring"""

							def __init__(   self					:  List[Any]				,						a					:  int=2_56				,						a					:  Tuple=10_24				,						a					:  Optional[Any]=16				,						a					:  Dict=16				,						a					:  str=4				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[Any]=1E-6				,						**a					:  Dict				,						)						->Union[str, Any]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Any =       hidden_size
													SCREAMING_SNAKE_CASE__  :					List[Any] =       image_size
													SCREAMING_SNAKE_CASE__  :					List[str] =       patch_size
													SCREAMING_SNAKE_CASE__  :					str =       image_size // patch_size
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       mask_input_channels
													SCREAMING_SNAKE_CASE__  :					Any =       num_point_embeddings
													SCREAMING_SNAKE_CASE__  :					str =       hidden_act
													SCREAMING_SNAKE_CASE__  :					Union[str, Any] =       layer_norm_eps







class  _a  (					lowercase__				):






							"""simple docstring"""

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







class  _a  (					lowercase__				):






							"""simple docstring"""

							def __init__(   self					:  Tuple				,						a					:  str=7_68				,						a					:  Tuple=2_56				,						a					:  Tuple=12				,						a					:  List[str]=12				,						a					:  Optional[Any]=3				,						a					:  str=10_24				,						a					:  str=16				,						a					:  Union[str, Any]="gelu"				,						a					:  Optional[int]=1E-06				,						a					:  Optional[Any]=0.0				,						a					:  str=1E-10				,						a					:  Optional[int]=True				,						a					:  Dict=4.0				,						a					:  Optional[Any]=True				,						a					:  List[str]=True				,						a					:  str=14				,						a					:  List[str]=[2, 5, 8, 11]				,						a					:  int=1_28				,						a					:  int=None				,						**a					:  List[str]				,						)						->Union[str, Any]:
													super().__init__(**a     )

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







class  _a  (					lowercase__				):






							"""simple docstring"""

							snake_case_							=    "sam"
							snake_case_							=    True

							def __init__(   self					:  str				,						a					:  Optional[int]=None				,						a					:  Any=None				,						a					:  Any=None				,						a					:  str=0.02				,						**a					:  int				,						)						->Optional[int]:
													super().__init__(**a     )
													SCREAMING_SNAKE_CASE__  :					Dict =       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__  :					Tuple =       mask_decoder_config if mask_decoder_config is not None else {}

													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Tuple =       vision_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					Dict =       prompt_encoder_config.to_dict()
													if isinstance(a				,						a     ):
																			SCREAMING_SNAKE_CASE__  :					List[Any] =       mask_decoder_config.to_dict()

													SCREAMING_SNAKE_CASE__  :					str =       SamVisionConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					str =       SamPromptEncoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					int =       SamMaskDecoderConfig(**a     )
													SCREAMING_SNAKE_CASE__  :					List[str] =       initializer_range






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