'''simple docstring'''


from collections import OrderedDict
from typing import Mapping

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


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

snake_case__	:     int      =    {
    '''uclanlp/plbart-base''': '''https://huggingface.co/uclanlp/plbart-base/resolve/main/config.json''',
    # See all PLBART models at https://huggingface.co/models?filter=plbart
}






class 	__SCREAMING_SNAKE_CASE		(			snake_case_			):







  '''simple docstring'''






  lowerCamelCase_						:Tuple		       =						'''plbart'''
  lowerCamelCase_						:Any		       =						['''past_key_values''']
  lowerCamelCase_						:int		       =						{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}


  def __init__(					self ,						snake_case_=5_0_0_0_5 ,						snake_case_=1_0_2_4 ,						snake_case_=6 ,						snake_case_=3_0_7_2 ,						snake_case_=1_2 ,						snake_case_=6 ,						snake_case_=3_0_7_2 ,						snake_case_=1_2 ,						snake_case_=0.0 ,						snake_case_=0.0 ,						snake_case_=True ,						snake_case_=True ,						snake_case_="gelu" ,						snake_case_=7_6_8 ,						snake_case_=0.1 ,						snake_case_=0.1 ,						snake_case_=0.0 ,						snake_case_=0.02 ,						snake_case_=0.0 ,						snake_case_=True ,						snake_case_=1 ,						snake_case_=0 ,						snake_case_=2 ,						snake_case_=2 ,						**snake_case_ ,						):




       '''simple docstring'''

       UpperCAmelCase_				:  str  = vocab_size
       UpperCAmelCase_				:  str  = max_position_embeddings
       UpperCAmelCase_				:  List[str]  = d_model
       UpperCAmelCase_				:  Optional[Any]  = encoder_ffn_dim
       UpperCAmelCase_				:  Union[str, Any]  = encoder_layers
       UpperCAmelCase_				:  Optional[Any]  = encoder_attention_heads
       UpperCAmelCase_				:  Optional[int]  = decoder_ffn_dim
       UpperCAmelCase_				:  List[str]  = decoder_layers
       UpperCAmelCase_				:  Optional[int]  = decoder_attention_heads
       UpperCAmelCase_				:  Optional[Any]  = dropout
       UpperCAmelCase_				:  Any  = attention_dropout
       UpperCAmelCase_				:  Dict  = activation_dropout
       UpperCAmelCase_				:  Any  = activation_function
       UpperCAmelCase_				:  str  = init_std
       UpperCAmelCase_				:  int  = encoder_layerdrop
       UpperCAmelCase_				:  Dict  = decoder_layerdrop
       UpperCAmelCase_				:  Any  = classifier_dropout
       UpperCAmelCase_				:  Optional[int]  = use_cache
       UpperCAmelCase_				:  Tuple  = encoder_layers
       UpperCAmelCase_				:  List[str]  = scale_embedding  # scale factor will be sqrt(d_model) if True
       super().__init__(
           pad_token_id=_lowerCAmelCase ,						bos_token_id=_lowerCAmelCase ,						eos_token_id=_lowerCAmelCase ,						is_encoder_decoder=_lowerCAmelCase ,						forced_eos_token_id=_lowerCAmelCase ,						**_lowerCAmelCase ,						)







class 	__SCREAMING_SNAKE_CASE		(			snake_case_			):







  '''simple docstring'''






  @property
  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       return OrderedDict(
           [
               ('input_ids', {0: 'batch', 1: 'sequence'}),
               ('attention_mask', {0: 'batch', 1: 'sequence'}),
           ]		)






  @property
  def _UpperCamelCase	(					self		):




       '''simple docstring'''

       if self.use_past:
            return OrderedDict(
                [
                    ('last_hidden_state', {0: 'batch', 1: 'sequence'}),
                    ('past_keys', {0: 'batch', 2: 'sequence'}),
                    ('encoder_last_hidden_state', {0: 'batch', 1: 'sequence'}),
                ]		)
       else:
            return OrderedDict(
                [
                    ('last_hidden_state', {0: 'batch', 1: 'sequence'}),
                    ('encoder_last_hidden_state', {0: 'batch', 1: 'sequence'}),
                ]		)











import copy

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


UpperCAmelCase_          =				logging.get_logger(__name__)

UpperCAmelCase_          =				{
    "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    (    snake_case_					):





   def __init__(						self							,  _lowerCAmelCase=256							,  _lowerCAmelCase=1_024							,  _lowerCAmelCase=16							,  _lowerCAmelCase=16							,  _lowerCAmelCase=4							,  _lowerCAmelCase="gelu"							,  _lowerCAmelCase=1E-6							,  **_lowerCAmelCase							,  ):
         super().__init__(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	hidden_size
         _lowerCAmelCase			      =	image_size
         _lowerCAmelCase			      =	patch_size
         _lowerCAmelCase			      =	image_size // patch_size
         _lowerCAmelCase			      =	mask_input_channels
         _lowerCAmelCase			      =	num_point_embeddings
         _lowerCAmelCase			      =	hidden_act
         _lowerCAmelCase			      =	layer_norm_eps






class 		UpperCAmelCase    (    snake_case_					):





   def __init__(						self							,  _lowerCAmelCase=256							,  _lowerCAmelCase="relu"							,  _lowerCAmelCase=2_048							,  _lowerCAmelCase=2							,  _lowerCAmelCase=8							,  _lowerCAmelCase=2							,  _lowerCAmelCase=3							,  _lowerCAmelCase=3							,  _lowerCAmelCase=256							,  _lowerCAmelCase=1E-6							,  **_lowerCAmelCase							,  ):
         super().__init__(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	hidden_size
         _lowerCAmelCase			      =	hidden_act
         _lowerCAmelCase			      =	mlp_dim
         _lowerCAmelCase			      =	num_hidden_layers
         _lowerCAmelCase			      =	num_attention_heads
         _lowerCAmelCase			      =	attention_downsample_rate
         _lowerCAmelCase			      =	num_multimask_outputs
         _lowerCAmelCase			      =	iou_head_depth
         _lowerCAmelCase			      =	iou_head_hidden_dim
         _lowerCAmelCase			      =	layer_norm_eps






class 		UpperCAmelCase    (    snake_case_					):





   def __init__(						self							,  _lowerCAmelCase=768							,  _lowerCAmelCase=256							,  _lowerCAmelCase=12							,  _lowerCAmelCase=12							,  _lowerCAmelCase=3							,  _lowerCAmelCase=1_024							,  _lowerCAmelCase=16							,  _lowerCAmelCase="gelu"							,  _lowerCAmelCase=1E-06							,  _lowerCAmelCase=0.0							,  _lowerCAmelCase=1E-10							,  _lowerCAmelCase=True							,  _lowerCAmelCase=4.0							,  _lowerCAmelCase=True							,  _lowerCAmelCase=True							,  _lowerCAmelCase=14							,  _lowerCAmelCase=[2, 5, 8, 11]							,  _lowerCAmelCase=128							,  _lowerCAmelCase=None							,  **_lowerCAmelCase							,  ):
         super().__init__(**_lowerCAmelCase      )

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






class 		UpperCAmelCase    (    snake_case_					):
   SCREAMING_SNAKE_CASE__					      =  '''sam'''
   SCREAMING_SNAKE_CASE__					      =  True





   def __init__(						self							,  _lowerCAmelCase=None							,  _lowerCAmelCase=None							,  _lowerCAmelCase=None							,  _lowerCAmelCase=0.02							,  **_lowerCAmelCase							,  ):
         super().__init__(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	vision_config if vision_config is not None else {}
         _lowerCAmelCase			      =	prompt_encoder_config if prompt_encoder_config is not None else {}
         _lowerCAmelCase			      =	mask_decoder_config if mask_decoder_config is not None else {}

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

         _lowerCAmelCase			      =	SamVisionConfig(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	SamPromptEncoderConfig(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	SamMaskDecoderConfig(**_lowerCAmelCase      )
         _lowerCAmelCase			      =	initializer_range





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	copy.deepcopy(self.__dict__      )
         _lowerCAmelCase			      =	self.vision_config.to_dict()
         _lowerCAmelCase			      =	self.prompt_encoder_config.to_dict()
         _lowerCAmelCase			      =	self.mask_decoder_config.to_dict()
         _lowerCAmelCase			      =	self.__class__.model_type
         return output