



import copy

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


UpperCAmelCase				:							Any								=logging.get_logger(__name__)


class  _lowercase				(a_ ):
				'''simple docstring'''







				lowercase__				  =  """vision-text-dual-encoder"""
				lowercase__				  =  True

				def __init__(	self       ,	snake_case__=512       ,	snake_case__=2.6_592       ,	**snake_case__      ):

									'''simple docstring'''


									super().__init__(**snake_case__      )

									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`."      )

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

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

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

									UpperCamelCase_											=				AutoConfig.for_model(snake_case__       ,	**snake_case__      )

									UpperCamelCase_											=				projection_dim
									UpperCamelCase_											=				logit_scale_init_value

				@classmethod
				def  _lowerCamelCase   (	cls       ,	snake_case__       ,	snake_case__       ,	**snake_case__      ):

									'''simple docstring'''


									return cls(vision_config=vision_config.to_dict()       ,	text_config=text_config.to_dict()       ,	**snake_case__      )

				def  _lowerCamelCase   (	self      ):

									'''simple docstring'''


									UpperCamelCase_											=				copy.deepcopy(self.__dict__      )
									UpperCamelCase_											=				self.vision_config.to_dict()
									UpperCamelCase_											=				self.text_config.to_dict()
									UpperCamelCase_											=				self.__class__.model_type
									return output





from typing import TYPE_CHECKING

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


UpperCAmelCase				:							Optional[int]								={
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase				:							Optional[int]								=["""RealmTokenizerFast"""]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase				:							Union[str, Any]								=[
	    """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """RealmEmbedder""",
	    """RealmForOpenQA""",
	    """RealmKnowledgeAugEncoder""",
	    """RealmPreTrainedModel""",
	    """RealmReader""",
	    """RealmScorer""",
	    """load_tf_weights_in_realm""",
	]
	UpperCAmelCase				:							List[str]								=["""RealmRetriever"""]


if TYPE_CHECKING:
	from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
	from .tokenization_realm import RealmTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_realm import RealmTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_realm import (
		    REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    RealmEmbedder,
		    RealmForOpenQA,
		    RealmKnowledgeAugEncoder,
		    RealmPreTrainedModel,
		    RealmReader,
		    RealmScorer,
		    load_tf_weights_in_realm,
		)
		from .retrieval_realm import RealmRetriever


else:
	import sys

	UpperCAmelCase				:							str								=_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
