
import copy

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


snake_case__  							=							logging.get_logger(__name__)

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[Any] ,      lowerCAmelCase      :					Optional[Any]=256 ,      lowerCAmelCase      :					str=1024 ,      lowerCAmelCase      :					Any=16 ,      lowerCAmelCase      :					Optional[Any]=16 ,      lowerCAmelCase      :					Union[str, Any]=4 ,      lowerCAmelCase      :					str="gelu" ,      lowerCAmelCase      :					Dict=1E-6 ,      **lowerCAmelCase      :					Tuple ,      ):
											super().__init__(**lowerCAmelCase					)
											lowercase       :    Union[str, Any]											=  hidden_size
											lowercase       :    Optional[Any]											=  image_size
											lowercase       :    Tuple											=  patch_size
											lowercase       :    List[str]											=  image_size // patch_size
											lowercase       :    Optional[Any]											=  mask_input_channels
											lowercase       :    str											=  num_point_embeddings
											lowercase       :    List[Any]											=  hidden_act
											lowercase       :    Union[str, Any]											=  layer_norm_eps







class 							UpperCAmelCase	(   A_					):

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







class 							UpperCAmelCase	(   A_					):

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

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







class 							UpperCAmelCase	(   A_					):
					a__: Optional[Any]			  =				"""sam"""
					a__: str			  =				True

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

											if isinstance(lowerCAmelCase ,      lowerCAmelCase					):
																	lowercase       :    Dict											=  vision_config.to_dict()
											if isinstance(lowerCAmelCase ,      lowerCAmelCase					):
																	lowercase       :    List[str]											=  prompt_encoder_config.to_dict()
											if isinstance(lowerCAmelCase ,      lowerCAmelCase					):
																	lowercase       :    Optional[int]											=  mask_decoder_config.to_dict()

											lowercase       :    Union[str, Any]											=  SamVisionConfig(**lowerCAmelCase					)
											lowercase       :    Optional[Any]											=  SamPromptEncoderConfig(**lowerCAmelCase					)
											lowercase       :    List[Any]											=  SamMaskDecoderConfig(**lowerCAmelCase					)
											lowercase       :    Union[str, Any]											=  initializer_range




					def        _lowerCAmelCase	(			self      :					Union[str, Any]					):
											lowercase       :    List[Any]											=  copy.deepcopy(self.__dict__					)
											lowercase       :    int											=  self.vision_config.to_dict()
											lowercase       :    Optional[int]											=  self.prompt_encoder_config.to_dict()
											lowercase       :    List[Any]											=  self.mask_decoder_config.to_dict()
											lowercase       :    List[Any]											=  self.__class__.model_type
											return output







snake_case__  							=							"""
# Diffusers installation
! pip install diffusers transformers datasets accelerate
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/diffusers.git
"""

snake_case__  							=							[{"""type""": """code""", """content""": INSTALL_CONTENT}]


