_SCREAMING_SNAKE_CASE   						=    [0.485, 0.456, 0.406]
_SCREAMING_SNAKE_CASE   						=    [0.229, 0.224, 0.225]
_SCREAMING_SNAKE_CASE   						=    [0.5, 0.5, 0.5]
_SCREAMING_SNAKE_CASE   						=    [0.5, 0.5, 0.5]
_SCREAMING_SNAKE_CASE   						=    [0.48145466, 0.4578275, 0.40821073]
_SCREAMING_SNAKE_CASE   						=    [0.26862954, 0.26130258, 0.27577711]


import copy

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


_SCREAMING_SNAKE_CASE   						=    logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE   						=    {
    """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_				(							_a    ):




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







class 					UpperCAmelCase_				(							_a    ):




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







class 					UpperCAmelCase_				(							_a    ):




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

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







class 					UpperCAmelCase_				(							_a    ):
    UpperCAmelCase_			:       Optional[Any]						 =							'sam'
    UpperCAmelCase_			:       List[Any]						 =							True




    def __init__(					self  :   Dict      ,      lowerCAmelCase  :   Any=None      ,      lowerCAmelCase  :   Optional[Any]=None      ,      lowerCAmelCase  :   Optional[Any]=None      ,      lowerCAmelCase  :   str=0.02      ,      **lowerCAmelCase  :   int      ,      )	-> Dict:
      super().__init__(**lowerCAmelCase   )
      a__     		=     vision_config if vision_config is not None else {}
      a__     		=     prompt_encoder_config if prompt_encoder_config is not None else {}
      a__     		=     mask_decoder_config if mask_decoder_config is not None else {}

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

      a__     		=     SamVisionConfig(**lowerCAmelCase   )
      a__     		=     SamPromptEncoderConfig(**lowerCAmelCase   )
      a__     		=     SamMaskDecoderConfig(**lowerCAmelCase   )
      a__     		=     initializer_range




    def 						__lowerCamelCase (					self  :   Optional[Any]   )	-> Union[str, Any]:
      a__     		=     copy.deepcopy(self.__dict__   )
      a__     		=     self.vision_config.to_dict()
      a__     		=     self.prompt_encoder_config.to_dict()
      a__     		=     self.mask_decoder_config.to_dict()
      a__     		=     self.__class__.model_type
      return output

