'''simple docstring'''





import copy

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


UpperCamelCase       :     int			=    logging.get_logger(__name__)

UpperCamelCase       :     str			=    {
    """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_       ):







    """simple docstring"""





    def __init__(					self     :						Optional[Any]							,							UpperCAmelCase_     :						str=2_5_6							,							UpperCAmelCase_     :						str=1_0_2_4							,							UpperCAmelCase_     :						Union[str, Any]=1_6							,							UpperCAmelCase_     :						str=1_6							,							UpperCAmelCase_     :						str=4							,							UpperCAmelCase_     :						Optional[int]="gelu"							,							UpperCAmelCase_     :						Any=1e-6							,							**UpperCAmelCase_     :						str							,							):


         """simple docstring"""







         super().__init__(**UpperCAmelCase_)
         a					:							Optional[int]							= hidden_size
         a					:							Optional[int]							= image_size
         a					:							Dict							= patch_size
         a					:							Optional[int]							= image_size // patch_size
         a					:							Dict							= mask_input_channels
         a					:							Optional[int]							= num_point_embeddings
         a					:							str							= hidden_act
         a					:							Optional[Any]							= layer_norm_eps






class   UpperCamelCase					(       a_       ):







    """simple docstring"""





    def __init__(					self     :						Optional[Any]							,							UpperCAmelCase_     :						Any=2_5_6							,							UpperCAmelCase_     :						Dict="relu"							,							UpperCAmelCase_     :						Union[str, Any]=2_0_4_8							,							UpperCAmelCase_     :						str=2							,							UpperCAmelCase_     :						Optional[int]=8							,							UpperCAmelCase_     :						Optional[Any]=2							,							UpperCAmelCase_     :						Optional[Any]=3							,							UpperCAmelCase_     :						str=3							,							UpperCAmelCase_     :						List[str]=2_5_6							,							UpperCAmelCase_     :						Union[str, Any]=1e-6							,							**UpperCAmelCase_     :						int							,							):


         """simple docstring"""







         super().__init__(**UpperCAmelCase_)
         a					:							str							= hidden_size
         a					:							int							= hidden_act
         a					:							List[Any]							= mlp_dim
         a					:							Optional[Any]							= num_hidden_layers
         a					:							List[Any]							= num_attention_heads
         a					:							List[str]							= attention_downsample_rate
         a					:							int							= num_multimask_outputs
         a					:							Any							= iou_head_depth
         a					:							Union[str, Any]							= iou_head_hidden_dim
         a					:							Union[str, Any]							= layer_norm_eps






class   UpperCamelCase					(       a_       ):







    """simple docstring"""





    def __init__(					self     :						str							,							UpperCAmelCase_     :						Optional[Any]=7_6_8							,							UpperCAmelCase_     :						Dict=2_5_6							,							UpperCAmelCase_     :						Optional[int]=1_2							,							UpperCAmelCase_     :						Any=1_2							,							UpperCAmelCase_     :						Optional[int]=3							,							UpperCAmelCase_     :						Dict=1_0_2_4							,							UpperCAmelCase_     :						Any=1_6							,							UpperCAmelCase_     :						Any="gelu"							,							UpperCAmelCase_     :						List[str]=1e-06							,							UpperCAmelCase_     :						Optional[Any]=0.0							,							UpperCAmelCase_     :						Optional[Any]=1e-10							,							UpperCAmelCase_     :						str=True							,							UpperCAmelCase_     :						List[str]=4.0							,							UpperCAmelCase_     :						Union[str, Any]=True							,							UpperCAmelCase_     :						List[str]=True							,							UpperCAmelCase_     :						Optional[Any]=1_4							,							UpperCAmelCase_     :						List[str]=[2, 5, 8, 1_1]							,							UpperCAmelCase_     :						str=1_2_8							,							UpperCAmelCase_     :						List[Any]=None							,							**UpperCAmelCase_     :						str							,							):


         """simple docstring"""







         super().__init__(**UpperCAmelCase_)

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






class   UpperCamelCase					(       a_       ):







    """simple docstring"""





    A     :    List[Any]				=			"sam"
    A     :    Union[str, Any]				=			True





    def __init__(					self     :						Any							,							UpperCAmelCase_     :						Optional[Any]=None							,							UpperCAmelCase_     :						Optional[Any]=None							,							UpperCAmelCase_     :						int=None							,							UpperCAmelCase_     :						Optional[Any]=0.02							,							**UpperCAmelCase_     :						Dict							,							):


         """simple docstring"""







         super().__init__(**UpperCAmelCase_)
         a					:							Union[str, Any]							= vision_config if vision_config is not None else {}
         a					:							Union[str, Any]							= prompt_encoder_config if prompt_encoder_config is not None else {}
         a					:							Dict							= mask_decoder_config if mask_decoder_config is not None else {}

         if isinstance(UpperCAmelCase_							,							UpperCAmelCase_):
              a					:							Union[str, Any]							= vision_config.to_dict()
         if isinstance(UpperCAmelCase_							,							UpperCAmelCase_):
              a					:							int							= prompt_encoder_config.to_dict()
         if isinstance(UpperCAmelCase_							,							UpperCAmelCase_):
              a					:							Any							= mask_decoder_config.to_dict()

         a					:							str							= SamVisionConfig(**UpperCAmelCase_)
         a					:							Optional[Any]							= SamPromptEncoderConfig(**UpperCAmelCase_)
         a					:							List[str]							= SamMaskDecoderConfig(**UpperCAmelCase_)
         a					:							Optional[int]							= initializer_range







    def    SCREAMING_SNAKE_CASE_     (					self     :						Dict):


         """simple docstring"""







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


'''simple docstring'''





import glob
import os

from get_test_info import get_tester_classes


if __name__ == "__main__":
      UpperCamelCase       :     List[Any]			=    []

      UpperCamelCase       :     Tuple			=    os.path.join("""tests""", """models""", """**""", """test_modeling_*.py""")
      UpperCamelCase       :     List[str]			=    glob.glob(pattern)
      # TODO: deal with TF/Flax too
      UpperCamelCase       :     List[Any]			=    [
          x for x in test_files if not (x.startswith("""test_modeling_tf_""") or x.startswith("""test_modeling_flax_"""))
      ]

      for test_file in test_files:
            UpperCamelCase       :     List[str]			=    get_tester_classes(test_file)
            for tester_class in tester_classes:
                  # A few tester classes don't have `parent` parameter in `__init__`.
                  # TODO: deal this better
                  try:
                        UpperCamelCase       :     int			=    tester_class(parent=None)
                  except Exception:
                        continue
                  if hasattr(tester, """get_config"""):
                        UpperCamelCase       :     Union[str, Any]			=    tester.get_config()
                        for k, v in config.to_dict().items():
                              if isinstance(v, int):
                                    UpperCamelCase       :     List[Any]			=    None
                                    if k in ["vocab_size"]:
                                          UpperCamelCase       :     List[Any]			=    100
                                    elif k in ["max_position_embeddings"]:
                                          UpperCamelCase       :     Tuple			=    128
                                    elif k in ["hidden_size", "d_model"]:
                                          UpperCamelCase       :     Any			=    40
                                    elif k == ["num_layers", "num_hidden_layers", "num_encoder_layers", "num_decoder_layers"]:
                                          UpperCamelCase       :     Tuple			=    5
                                    if target is not None and v > target:
                                          failures.append(
                                              f'''{tester_class.__name__} will produce a `config` of type `{config.__class__.__name__}`'''
                                              f''' with config["{k}"] = {v} which is too large for testing! Set its value to be smaller'''
                                              f''' than {target}.'''
                                          )

      if len(failures) > 0:
            raise Exception(f'''There were {len(failures)} failures:\n''' + """\n""".join(failures))

