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 						snake_case_ (	__A ):






   def __init__(   self       :  str			,		lowercase_       :  Optional[int]=2_56			,		lowercase_       :  str=10_24			,		lowercase_       :  str=16			,		lowercase_       :  Dict=16			,		lowercase_       :  List[Any]=4			,		lowercase_       :  Tuple="gelu"			,		lowercase_       :  Any=1E-6			,		**lowercase_       :  List[Any]			,		)      ->		int:
       super().__init__(**lowercase_						)
       lowercase__				:     Dict					      =       hidden_size
       lowercase__				:     Optional[int]					      =       image_size
       lowercase__				:     List[Any]					      =       patch_size
       lowercase__				:     Union[str, Any]					      =       image_size // patch_size
       lowercase__				:     Tuple					      =       mask_input_channels
       lowercase__				:     List[str]					      =       num_point_embeddings
       lowercase__				:     Any					      =       hidden_act
       lowercase__				:     Optional[Any]					      =       layer_norm_eps



class 						snake_case_ (	__A ):






   def __init__(   self       :  Optional[int]			,		lowercase_       :  Union[str, Any]=2_56			,		lowercase_       :  List[str]="relu"			,		lowercase_       :  List[str]=20_48			,		lowercase_       :  str=2			,		lowercase_       :  Optional[int]=8			,		lowercase_       :  Optional[int]=2			,		lowercase_       :  str=3			,		lowercase_       :  str=3			,		lowercase_       :  str=2_56			,		lowercase_       :  Dict=1E-6			,		**lowercase_       :  Any			,		)      ->		Any:
       super().__init__(**lowercase_						)
       lowercase__				:     str					      =       hidden_size
       lowercase__				:     Union[str, Any]					      =       hidden_act
       lowercase__				:     Union[str, Any]					      =       mlp_dim
       lowercase__				:     Union[str, Any]					      =       num_hidden_layers
       lowercase__				:     Dict					      =       num_attention_heads
       lowercase__				:     Any					      =       attention_downsample_rate
       lowercase__				:     List[Any]					      =       num_multimask_outputs
       lowercase__				:     Optional[int]					      =       iou_head_depth
       lowercase__				:     Union[str, Any]					      =       iou_head_hidden_dim
       lowercase__				:     str					      =       layer_norm_eps



class 						snake_case_ (	__A ):






   def __init__(   self       :  Union[str, Any]			,		lowercase_       :  int=7_68			,		lowercase_       :  List[str]=2_56			,		lowercase_       :  Union[str, Any]=12			,		lowercase_       :  Tuple=12			,		lowercase_       :  List[Any]=3			,		lowercase_       :  Tuple=10_24			,		lowercase_       :  Dict=16			,		lowercase_       :  Tuple="gelu"			,		lowercase_       :  Any=1E-06			,		lowercase_       :  List[str]=0.0			,		lowercase_       :  int=1E-10			,		lowercase_       :  Tuple=True			,		lowercase_       :  Optional[int]=4.0			,		lowercase_       :  List[Any]=True			,		lowercase_       :  Optional[Any]=True			,		lowercase_       :  str=14			,		lowercase_       :  str=[2, 5, 8, 11]			,		lowercase_       :  Tuple=1_28			,		lowercase_       :  Optional[Any]=None			,		**lowercase_       :  Any			,		)      ->		int:
       super().__init__(**lowercase_						)

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



class 						snake_case_ (	__A ):
   __A			:	str        =       "sam"
   __A			:	int        =       True






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

       if isinstance(lowercase_			,		lowercase_						):
           lowercase__				:     Optional[Any]					      =       vision_config.to_dict()
       if isinstance(lowercase_			,		lowercase_						):
           lowercase__				:     Optional[Any]					      =       prompt_encoder_config.to_dict()
       if isinstance(lowercase_			,		lowercase_						):
           lowercase__				:     Any					      =       mask_decoder_config.to_dict()

       lowercase__				:     Optional[Any]					      =       SamVisionConfig(**lowercase_						)
       lowercase__				:     List[str]					      =       SamPromptEncoderConfig(**lowercase_						)
       lowercase__				:     Optional[Any]					      =       SamMaskDecoderConfig(**lowercase_						)
       lowercase__				:     Tuple					      =       initializer_range







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




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCamelCase													=		{
    '''configuration_mobilenet_v1''': [
        '''MOBILENET_V1_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''MobileNetV1Config''',
        '''MobileNetV1OnnxConfig''',
    ],
}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase													=		['''MobileNetV1FeatureExtractor''']
      UpperCamelCase													=		['''MobileNetV1ImageProcessor''']

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase													=		[
          '''MOBILENET_V1_PRETRAINED_MODEL_ARCHIVE_LIST''',
          '''MobileNetV1ForImageClassification''',
          '''MobileNetV1Model''',
          '''MobileNetV1PreTrainedModel''',
          '''load_tf_weights_in_mobilenet_v1''',
      ]


if TYPE_CHECKING:
      from .configuration_mobilenet_va import (
          MOBILENET_V1_PRETRAINED_CONFIG_ARCHIVE_MAP,
          MobileNetVaConfig,
          MobileNetVaOnnxConfig,
      )

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_mobilenet_va import MobileNetVaFeatureExtractor
            from .image_processing_mobilenet_va import MobileNetVaImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_mobilenet_va import (
                MOBILENET_V1_PRETRAINED_MODEL_ARCHIVE_LIST,
                MobileNetVaForImageClassification,
                MobileNetVaModel,
                MobileNetVaPreTrainedModel,
                load_tf_weights_in_mobilenet_va,
            )


else:
      import sys

      UpperCamelCase													=		_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



