




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 	lowercase_      (			lowercase     ):






      '''simple docstring'''




      def __init__(   self   :		Optional[int]				,      __UpperCAmelCase   :		Dict=256				,      __UpperCAmelCase   :		Any=1_024				,      __UpperCAmelCase   :		Union[str, Any]=16				,      __UpperCAmelCase   :		Optional[int]=16				,      __UpperCAmelCase   :		Dict=4				,      __UpperCAmelCase   :		str="gelu"				,      __UpperCAmelCase   :		Dict=1e-6				,      **__UpperCAmelCase   :		int				,      )					->int:




       """simple docstring"""


       super().__init__(**__UpperCAmelCase						)
       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 	lowercase_      (			lowercase     ):






      '''simple docstring'''




      def __init__(   self   :		Optional[Any]				,      __UpperCAmelCase   :		Optional[Any]=256				,      __UpperCAmelCase   :		Any="relu"				,      __UpperCAmelCase   :		Any=2_048				,      __UpperCAmelCase   :		List[Any]=2				,      __UpperCAmelCase   :		str=8				,      __UpperCAmelCase   :		Optional[int]=2				,      __UpperCAmelCase   :		Optional[int]=3				,      __UpperCAmelCase   :		List[Any]=3				,      __UpperCAmelCase   :		Optional[Any]=256				,      __UpperCAmelCase   :		Dict=1e-6				,      **__UpperCAmelCase   :		Optional[Any]				,      )					->Tuple:




       """simple docstring"""


       super().__init__(**__UpperCAmelCase						)
       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 	lowercase_      (			lowercase     ):






      '''simple docstring'''




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




       """simple docstring"""


       super().__init__(**__UpperCAmelCase						)

       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 	lowercase_      (			lowercase     ):






      '''simple docstring'''




      __snake_case  						=						'''sam'''
      __snake_case  						=						True







      def __init__(   self   :		Any				,      __UpperCAmelCase   :		List[str]=None				,      __UpperCAmelCase   :		List[str]=None				,      __UpperCAmelCase   :		List[Any]=None				,      __UpperCAmelCase   :		str=0.02				,      **__UpperCAmelCase   :		Any				,      )					->Dict:




       """simple docstring"""


       super().__init__(**__UpperCAmelCase						)
       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(__UpperCAmelCase				,      __UpperCAmelCase						):
        a							=   vision_config.to_dict()
       if isinstance(__UpperCAmelCase				,      __UpperCAmelCase						):
        a							=   prompt_encoder_config.to_dict()
       if isinstance(__UpperCAmelCase				,      __UpperCAmelCase						):
        a							=   mask_decoder_config.to_dict()

       a							=   SamVisionConfig(**__UpperCAmelCase						)
       a							=   SamPromptEncoderConfig(**__UpperCAmelCase						)
       a							=   SamMaskDecoderConfig(**__UpperCAmelCase						)
       a							=   initializer_range







      def    __lowerCAmelCase      (   self   :		Any						)					->str:




       """simple docstring"""


       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










from ...utils import is_transformers_available
from .pipeline_latent_diffusion_superresolution import LDMSuperResolutionPipeline


if is_transformers_available():
     from .pipeline_latent_diffusion import LDMBertModel, LDMTextToImagePipeline


