






import copy

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


A__     :      Any             =			logging.get_logger(__name__)
class 				_UpperCAmelCase (	lowerCAmelCase__     ):
				lowercase__    							=	"""hybrid-clip"""
				lowercase__    							=	True




				def __init__(					self						:   str,  lowerCamelCase						:   str=512,  **lowerCamelCase						:   Union[str, Any]  ):

								'''simple docstring'''
								super().__init__(**UpperCamelCase__  )

								if "text_config" not in kwargs:
												raise ValueError('''`text_config` can not be `None`.'''  )

								if "vision_config" not in kwargs:
												raise ValueError('''`vision_config` can not be `None`.'''  )

								lowercase__       			=      kwargs.pop('''text_config'''  )
								lowercase__       			=      kwargs.pop('''vision_config'''  )

								lowercase__       			=      text_config.pop('''model_type'''  )
								lowercase__       			=      vision_config.pop('''model_type'''  )

								from transformers import AutoConfig

								lowercase__       			=      AutoConfig.for_model(UpperCamelCase__,  **UpperCamelCase__  )

								if vision_model_type == "clip":
												lowercase__       			=      AutoConfig.for_model(UpperCamelCase__,  **UpperCamelCase__  ).vision_config
								elif vision_model_type == "clip_vision_model":
												from transformers import CLIPVisionConfig

												lowercase__       			=      CLIPVisionConfig(**UpperCamelCase__  )
								else:
												lowercase__       			=      AutoConfig.for_model(UpperCamelCase__,  **UpperCamelCase__  )

								lowercase__       			=      projection_dim
								lowercase__       			=      1.0




				@classmethod
				def     lowercase__       (					cls						:   Optional[Any],  lowerCamelCase						:   int,  lowerCamelCase						:   Optional[int],  **lowerCamelCase						:   List[Any]  ):

								'''simple docstring'''
								return cls(text_config=text_config.to_dict(),  vision_config=vision_config.to_dict(),  **UpperCamelCase__  )




				def     lowercase__       (					self						:   Dict  ):

								'''simple docstring'''
								lowercase__       			=      copy.deepcopy(self.__dict__  )
								lowercase__       			=      self.text_config.to_dict()
								lowercase__       			=      self.vision_config.to_dict()
								lowercase__       			=      self.__class__.model_type
								return output












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A__     :      int             =			{
    'configuration_sam': [
        'SAM_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'SamConfig',
        'SamMaskDecoderConfig',
        'SamPromptEncoderConfig',
        'SamVisionConfig',
    ],
    'processing_sam': ['SamProcessor'],
}


try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      List[Any]             =			[
							    'SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'SamModel',
							    'SamPreTrainedModel',
							]
try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      int             =			[
							    'TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'TFSamModel',
							    'TFSamPreTrainedModel',
							]
try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__     :      Tuple             =			['SamImageProcessor']


if TYPE_CHECKING:
							from .configuration_sam import (
							    SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    SamConfig,
							    SamMaskDecoderConfig,
							    SamPromptEncoderConfig,
							    SamVisionConfig,
							)
							from .processing_sam import SamProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .image_processing_sam import SamImageProcessor

else:
							import sys

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




