
"""simple docstring"""






import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


UpperCamelCase_						   =   logging.get_logger(__name__)





class 							snake_case       (     SCREAMING_SNAKE_CASE_		):
   a_					:		Optional[Any]     					=     """vision-text-dual-encoder"""
   a_					:		Dict     					=     True







   def __init__( self       ,							__UpperCAmelCase=5_12       ,							__UpperCAmelCase=2.6_592       ,							**__UpperCAmelCase)   ->Optional[int]:
      super().__init__(**__UpperCAmelCase)

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

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

      a_						   =     kwargs.pop("vision_config")
      a_						   =     kwargs.pop("text_config")

      a_						   =     vision_config.pop("model_type")
      a_						   =     text_config.pop("model_type")

      if vision_model_type == "clip":
         a_						   =     AutoConfig.for_model(__UpperCAmelCase       ,							**__UpperCAmelCase).vision_config
      elif vision_model_type == "clip_vision_model":
         a_						   =     CLIPVisionConfig(**__UpperCAmelCase)
      else:
         a_						   =     AutoConfig.for_model(__UpperCAmelCase       ,							**__UpperCAmelCase)

      a_						   =     AutoConfig.for_model(__UpperCAmelCase       ,							**__UpperCAmelCase)

      a_						   =     projection_dim
      a_						   =     logit_scale_init_value







   @classmethod
   def    UpperCAmelCase__	( cls       ,							__UpperCAmelCase       ,							__UpperCAmelCase       ,							**__UpperCAmelCase)   ->Dict:
      return cls(vision_config=vision_config.to_dict()       ,							text_config=text_config.to_dict()       ,							**__UpperCAmelCase)







   def    UpperCAmelCase__	( self)   ->Any:
      a_						   =     copy.deepcopy(self.__dict__)
      a_						   =     self.vision_config.to_dict()
      a_						   =     self.text_config.to_dict()
      a_						   =     self.__class__.model_type
      return output

"""simple docstring"""






from typing import TYPE_CHECKING

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


UpperCamelCase_						   =   {
    '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:
      UpperCamelCase_						   =   [
          'SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
          'SamModel',
          'SamPreTrainedModel',
      ]
try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase_						   =   [
          'TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST',
          'TFSamModel',
          'TFSamPreTrainedModel',
      ]
try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCamelCase_						   =   ['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

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