






'''simple docstring'''







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 					__UpperCAmelCase (		_SCREAMING_SNAKE_CASE	):

      '''simple docstring'''





      def __init__(					self  ,		_UpperCAmelCase=256  ,		_UpperCAmelCase=1024  ,		_UpperCAmelCase=16  ,		_UpperCAmelCase=16  ,		_UpperCAmelCase=4  ,		_UpperCAmelCase="gelu"  ,		_UpperCAmelCase=1E-6  ,		**_UpperCAmelCase  ,		):
             super().__init__(**_UpperCAmelCase						)
             UpperCAmelCase__	:   List[str]												=	hidden_size
             UpperCAmelCase__	:   Any												=	image_size
             UpperCAmelCase__	:   Dict												=	patch_size
             UpperCAmelCase__	:   Union[str, Any]												=	image_size // patch_size
             UpperCAmelCase__	:   List[Any]												=	mask_input_channels
             UpperCAmelCase__	:   str												=	num_point_embeddings
             UpperCAmelCase__	:   Tuple												=	hidden_act
             UpperCAmelCase__	:   List[str]												=	layer_norm_eps




class 					__UpperCAmelCase (		_SCREAMING_SNAKE_CASE	):

      '''simple docstring'''





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




class 					__UpperCAmelCase (		_SCREAMING_SNAKE_CASE	):

      '''simple docstring'''





      def __init__(					self  ,		_UpperCAmelCase=768  ,		_UpperCAmelCase=256  ,		_UpperCAmelCase=12  ,		_UpperCAmelCase=12  ,		_UpperCAmelCase=3  ,		_UpperCAmelCase=1024  ,		_UpperCAmelCase=16  ,		_UpperCAmelCase="gelu"  ,		_UpperCAmelCase=1E-06  ,		_UpperCAmelCase=0.0  ,		_UpperCAmelCase=1E-10  ,		_UpperCAmelCase=True  ,		_UpperCAmelCase=4.0  ,		_UpperCAmelCase=True  ,		_UpperCAmelCase=True  ,		_UpperCAmelCase=14  ,		_UpperCAmelCase=[2, 5, 8, 11]  ,		_UpperCAmelCase=128  ,		_UpperCAmelCase=None  ,		**_UpperCAmelCase  ,		):
             super().__init__(**_UpperCAmelCase						)

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




class 					__UpperCAmelCase (		_SCREAMING_SNAKE_CASE	):

      '''simple docstring'''





      SCREAMING_SNAKE_CASE				:    Optional[int]				       =					"sam"
      SCREAMING_SNAKE_CASE				:    Union[str, Any]				       =					True




      def __init__(					self  ,		_UpperCAmelCase=None  ,		_UpperCAmelCase=None  ,		_UpperCAmelCase=None  ,		_UpperCAmelCase=0.02  ,		**_UpperCAmelCase  ,		):
             super().__init__(**_UpperCAmelCase						)
             UpperCAmelCase__	:   str												=	vision_config if vision_config is not None else {}
             UpperCAmelCase__	:   int												=	prompt_encoder_config if prompt_encoder_config is not None else {}
             UpperCAmelCase__	:   Dict												=	mask_decoder_config if mask_decoder_config is not None else {}

             if isinstance(_UpperCAmelCase  ,		_UpperCAmelCase						):
                    UpperCAmelCase__	:   List[str]												=	vision_config.to_dict()
             if isinstance(_UpperCAmelCase  ,		_UpperCAmelCase						):
                    UpperCAmelCase__	:   Any												=	prompt_encoder_config.to_dict()
             if isinstance(_UpperCAmelCase  ,		_UpperCAmelCase						):
                    UpperCAmelCase__	:   Any												=	mask_decoder_config.to_dict()

             UpperCAmelCase__	:   Any												=	SamVisionConfig(**_UpperCAmelCase						)
             UpperCAmelCase__	:   List[Any]												=	SamPromptEncoderConfig(**_UpperCAmelCase						)
             UpperCAmelCase__	:   Union[str, Any]												=	SamMaskDecoderConfig(**_UpperCAmelCase						)
             UpperCAmelCase__	:   Any												=	initializer_range




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   str												=	copy.deepcopy(self.__dict__						)
             UpperCAmelCase__	:   Dict												=	self.vision_config.to_dict()
             UpperCAmelCase__	:   Any												=	self.prompt_encoder_config.to_dict()
             UpperCAmelCase__	:   str												=	self.mask_decoder_config.to_dict()
             UpperCAmelCase__	:   Optional[int]												=	self.__class__.model_type
             return output

'''simple docstring'''
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


A__ :		str					={'configuration_t5': ['T5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'T5Config', 'T5OnnxConfig']}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A__ :		Optional[int]					=['T5Tokenizer']

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A__ :		Union[str, Any]					=['T5TokenizerFast']

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A__ :		Union[str, Any]					=[
         'T5_PRETRAINED_MODEL_ARCHIVE_LIST',
         'T5EncoderModel',
         'T5ForConditionalGeneration',
         'T5Model',
         'T5PreTrainedModel',
         'load_tf_weights_in_t5',
         'T5ForQuestionAnswering',
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A__ :		List[str]					=[
         'TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST',
         'TFT5EncoderModel',
         'TFT5ForConditionalGeneration',
         'TFT5Model',
         'TFT5PreTrainedModel',
     ]

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A__ :		Union[str, Any]					=[
         'FlaxT5EncoderModel',
         'FlaxT5ForConditionalGeneration',
         'FlaxT5Model',
         'FlaxT5PreTrainedModel',
     ]


if TYPE_CHECKING:
     from .configuration_ta import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, TaConfig, TaOnnxConfig

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_ta import TaTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_ta_fast import TaTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_ta import (
              T5_PRETRAINED_MODEL_ARCHIVE_LIST,
              TaEncoderModel,
              TaForConditionalGeneration,
              TaForQuestionAnswering,
              TaModel,
              TaPreTrainedModel,
              load_tf_weights_in_ta,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_ta import (
              TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFTaEncoderModel,
              TFTaForConditionalGeneration,
              TFTaModel,
              TFTaPreTrainedModel,
          )

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_ta import (
              FlaxTaEncoderModel,
              FlaxTaForConditionalGeneration,
              FlaxTaModel,
              FlaxTaPreTrainedModel,
          )


else:
     import sys

     A__ :		Dict					=_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



