





'''simple docstring'''







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


A						    =							logging.get_logger(__name__)

A						    =							{
    'google/pegasus-x-base': 'https://huggingface.co/google/pegasus-x-base/resolve/main/config.json',
    'google/pegasus-x-large': 'https://huggingface.co/google/pegasus-x-large/resolve/main/config.json',
    # See all PEGASUS-X models at https://huggingface.co/models?filter=pegasus-x
}



class 							__SCREAMING_SNAKE_CASE			(       lowerCAmelCase__      ):
      '''simple docstring'''



      lowerCAmelCase__       :      List[str] 		=		"pegasus_x"
      lowerCAmelCase__       :      Dict 		=		["past_key_values"]
      lowerCAmelCase__       :      Optional[int] 		=		{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}

      def __init__(							self    : Optional[Any]   ,UpperCamelCase    : Dict=9_6103   ,UpperCamelCase    : Union[str, Any]=1_6384   ,UpperCamelCase    : List[str]=16   ,UpperCamelCase    : Dict=4096   ,UpperCamelCase    : int=16   ,UpperCamelCase    : Optional[Any]=16   ,UpperCamelCase    : List[str]=4096   ,UpperCamelCase    : List[str]=16   ,UpperCamelCase    : List[str]=0.0   ,UpperCamelCase    : int=0.0   ,UpperCamelCase    : Optional[Any]=True   ,UpperCamelCase    : str=True   ,UpperCamelCase    : Any="gelu"   ,UpperCamelCase    : Optional[Any]=1024   ,UpperCamelCase    : Optional[Any]=0.1   ,UpperCamelCase    : Dict=0.0   ,UpperCamelCase    : Tuple=0.0   ,UpperCamelCase    : int=0.0_2   ,UpperCamelCase    : str=0   ,UpperCamelCase    : str=True   ,UpperCamelCase    : Optional[int]=0   ,UpperCamelCase    : List[Any]=1   ,UpperCamelCase    : List[str]=1   ,UpperCamelCase    : Optional[int]=32   ,UpperCamelCase    : Optional[int]=512   ,UpperCamelCase    : List[Any]=True   ,**UpperCamelCase    : Any   ,)		->  int:
           _lowercase							:      List[str]  						=							vocab_size
           _lowercase							:      List[Any]  						=							max_position_embeddings
           _lowercase							:      Any  						=							d_model
           _lowercase							:      Optional[Any]  						=							encoder_ffn_dim
           _lowercase							:      int  						=							encoder_layers
           _lowercase							:      Optional[Any]  						=							encoder_attention_heads
           _lowercase							:      Optional[Any]  						=							decoder_ffn_dim
           _lowercase							:      int  						=							decoder_layers
           _lowercase							:      Tuple  						=							decoder_attention_heads
           _lowercase							:      List[str]  						=							dropout
           _lowercase							:      Any  						=							attention_dropout
           _lowercase							:      Tuple  						=							activation_dropout
           _lowercase							:      List[Any]  						=							activation_function
           _lowercase							:      str  						=							init_std
           _lowercase							:      Optional[int]  						=							encoder_layerdrop
           _lowercase							:      List[Any]  						=							decoder_layerdrop
           _lowercase							:      Dict  						=							use_cache
           _lowercase							:      int  						=							encoder_layers
           _lowercase							:      int  						=							scale_embedding  # scale factor will be sqrt(d_model) if True

           _lowercase							:      Optional[Any]  						=							num_global_tokens
           _lowercase							:      Union[str, Any]  						=							block_size
           _lowercase							:      List[Any]  						=							stagger_local_blocks

           super().__init__(
               pad_token_id=UpperCamelCase   ,eos_token_id=UpperCamelCase   ,is_encoder_decoder=UpperCamelCase   ,decoder_start_token_id=UpperCamelCase   ,forced_eos_token_id=UpperCamelCase   ,**UpperCamelCase   ,)

      @property
      def   _lowerCamelCase		(							self    : Tuple  )		->  int:
           return self.encoder_attention_heads



      @property
      def   _lowerCamelCase		(							self    : str  )		->  int:
           return self.d_model









'''simple docstring'''







import copy

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


A						    =							logging.get_logger(__name__)

A						    =							{
    '''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			(       lowerCAmelCase__      ):
      '''simple docstring'''



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



class 							__SCREAMING_SNAKE_CASE			(       lowerCAmelCase__      ):
      '''simple docstring'''



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



class 							__SCREAMING_SNAKE_CASE			(       lowerCAmelCase__      ):
      '''simple docstring'''



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

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



class 							__SCREAMING_SNAKE_CASE			(       lowerCAmelCase__      ):
      '''simple docstring'''



      lowerCAmelCase__       :      Any 		=		"sam"
      lowerCAmelCase__       :      Optional[int] 		=		True

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

           if isinstance(UpperCamelCase   ,UpperCamelCase  ):
                _lowercase							:      Optional[Any]  						=							vision_config.to_dict()
           if isinstance(UpperCamelCase   ,UpperCamelCase  ):
                _lowercase							:      Union[str, Any]  						=							prompt_encoder_config.to_dict()
           if isinstance(UpperCamelCase   ,UpperCamelCase  ):
                _lowercase							:      List[Any]  						=							mask_decoder_config.to_dict()

           _lowercase							:      Optional[int]  						=							SamVisionConfig(**UpperCamelCase  )
           _lowercase							:      Union[str, Any]  						=							SamPromptEncoderConfig(**UpperCamelCase  )
           _lowercase							:      Union[str, Any]  						=							SamMaskDecoderConfig(**UpperCamelCase  )
           _lowercase							:      Tuple  						=							initializer_range



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