
'''simple docstring'''







import copy

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


lowerCAmelCase_      =   logging.get_logger(__name__)

lowerCAmelCase_      =   {
    "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__						):



   """simple docstring"""





   def __init__( self			,   UpperCamelCase=2_56			,   UpperCamelCase=10_24			,   UpperCamelCase=16			,   UpperCamelCase=16			,   UpperCamelCase=4			,   UpperCamelCase="gelu"			,   UpperCamelCase=1E-6			,   **UpperCamelCase			,   ):
          super().__init__(**UpperCamelCase)
          lowerCamelCase__				   =      hidden_size
          lowerCamelCase__				   =      image_size
          lowerCamelCase__				   =      patch_size
          lowerCamelCase__				   =      image_size // patch_size
          lowerCamelCase__				   =      mask_input_channels
          lowerCamelCase__				   =      num_point_embeddings
          lowerCamelCase__				   =      hidden_act
          lowerCamelCase__				   =      layer_norm_eps







class 		snake_case_       (						A__						):



   """simple docstring"""





   def __init__( self			,   UpperCamelCase=2_56			,   UpperCamelCase="relu"			,   UpperCamelCase=20_48			,   UpperCamelCase=2			,   UpperCamelCase=8			,   UpperCamelCase=2			,   UpperCamelCase=3			,   UpperCamelCase=3			,   UpperCamelCase=2_56			,   UpperCamelCase=1E-6			,   **UpperCamelCase			,   ):
          super().__init__(**UpperCamelCase)
          lowerCamelCase__				   =      hidden_size
          lowerCamelCase__				   =      hidden_act
          lowerCamelCase__				   =      mlp_dim
          lowerCamelCase__				   =      num_hidden_layers
          lowerCamelCase__				   =      num_attention_heads
          lowerCamelCase__				   =      attention_downsample_rate
          lowerCamelCase__				   =      num_multimask_outputs
          lowerCamelCase__				   =      iou_head_depth
          lowerCamelCase__				   =      iou_head_hidden_dim
          lowerCamelCase__				   =      layer_norm_eps







class 		snake_case_       (						A__						):



   """simple docstring"""





   def __init__( self			,   UpperCamelCase=7_68			,   UpperCamelCase=2_56			,   UpperCamelCase=12			,   UpperCamelCase=12			,   UpperCamelCase=3			,   UpperCamelCase=10_24			,   UpperCamelCase=16			,   UpperCamelCase="gelu"			,   UpperCamelCase=1E-0_6			,   UpperCamelCase=0.0			,   UpperCamelCase=1E-1_0			,   UpperCamelCase=True			,   UpperCamelCase=4.0			,   UpperCamelCase=True			,   UpperCamelCase=True			,   UpperCamelCase=14			,   UpperCamelCase=[2, 5, 8, 11]			,   UpperCamelCase=1_28			,   UpperCamelCase=None			,   **UpperCamelCase			,   ):
          super().__init__(**UpperCamelCase)

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







class 		snake_case_       (						A__						):



   """simple docstring"""





   __lowerCAmelCase	:							str								='''sam'''
   __lowerCAmelCase	:							List[Any]								=True







   def __init__( self			,   UpperCamelCase=None			,   UpperCamelCase=None			,   UpperCamelCase=None			,   UpperCamelCase=0.0_2			,   **UpperCamelCase			,   ):
          super().__init__(**UpperCamelCase)
          lowerCamelCase__				   =      vision_config if vision_config is not None else {}
          lowerCamelCase__				   =      prompt_encoder_config if prompt_encoder_config is not None else {}
          lowerCamelCase__				   =      mask_decoder_config if mask_decoder_config is not None else {}

          if isinstance(UpperCamelCase			,   UpperCamelCase):
                 lowerCamelCase__				   =      vision_config.to_dict()
          if isinstance(UpperCamelCase			,   UpperCamelCase):
                 lowerCamelCase__				   =      prompt_encoder_config.to_dict()
          if isinstance(UpperCamelCase			,   UpperCamelCase):
                 lowerCamelCase__				   =      mask_decoder_config.to_dict()

          lowerCamelCase__				   =      SamVisionConfig(**UpperCamelCase)
          lowerCamelCase__				   =      SamPromptEncoderConfig(**UpperCamelCase)
          lowerCamelCase__				   =      SamMaskDecoderConfig(**UpperCamelCase)
          lowerCamelCase__				   =      initializer_range







   def     __UpperCAmelCase      ( self):
          lowerCamelCase__				   =      copy.deepcopy(self.__dict__)
          lowerCamelCase__				   =      self.vision_config.to_dict()
          lowerCamelCase__				   =      self.prompt_encoder_config.to_dict()
          lowerCamelCase__				   =      self.mask_decoder_config.to_dict()
          lowerCamelCase__				   =      self.__class__.model_type
          return output



'''simple docstring'''







from ..utils import DummyObject, requires_backends







class 		snake_case_       (						metaclass=A__						):



   """simple docstring"""





   __lowerCAmelCase	:							List[str]								=['''torch''', '''librosa''']







   def __init__( self			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(self			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







class 		snake_case_       (						metaclass=A__						):



   """simple docstring"""





   __lowerCAmelCase	:							Union[str, Any]								=['''torch''', '''librosa''']







   def __init__( self			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(self			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])







   @classmethod
   def     __UpperCAmelCase      ( cls			,   *UpperCamelCase			,   **UpperCamelCase):
          requires_backends(cls			,   ["torch", "librosa"])

