
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_					(						__UpperCamelCase			):

						"""simple docstring"""



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



						def __init__(self:				Optional[Any]   ,				__UpperCAmelCase:				int=512   ,				__UpperCAmelCase:				Any=2.65_92   ,				**__UpperCAmelCase:				Optional[int]      )						->    Optional[int]:




											'''simple docstring'''



											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				:	Dict			=				kwargs.pop("vision_config"      )
											__a				:	str			=				kwargs.pop("text_config"      )

											__a				:	Optional[Any]			=				vision_config.pop("model_type"      )
											__a				:	Union[str, Any]			=				text_config.pop("model_type"      )

											if vision_model_type == "clip":
																__a				:	Optional[Any]			=				AutoConfig.for_model(__UpperCAmelCase   ,				**__UpperCAmelCase      ).vision_config
											elif vision_model_type == "clip_vision_model":
																__a				:	Optional[int]			=				CLIPVisionConfig(**__UpperCAmelCase      )
											else:
																__a				:	str			=				AutoConfig.for_model(__UpperCAmelCase   ,				**__UpperCAmelCase      )

											__a				:	int			=				AutoConfig.for_model(__UpperCAmelCase   ,				**__UpperCAmelCase      )

											__a				:	Any			=				projection_dim
											__a				:	List[str]			=				logit_scale_init_value



						@classmethod
						def 					UpperCAmelCase__				(cls:				Any   ,				__UpperCAmelCase:				Dict   ,				__UpperCAmelCase:				List[Any]   ,				**__UpperCAmelCase:				Dict      )						->    Dict:




											'''simple docstring'''



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



						def 					UpperCAmelCase__				(self:				Union[str, Any]      )						->    Dict:




											'''simple docstring'''



											__a				:	Optional[int]			=				copy.deepcopy(self.__dict__      )
											__a				:	Tuple			=				self.vision_config.to_dict()
											__a				:	Dict			=				self.text_config.to_dict()
											__a				:	Optional[Any]			=				self.__class__.model_type
											return output













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,
)


UpperCAmelCase__			 =	{'''configuration_pegasus''': ['''PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusConfig''']}

try:
			if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__			 =	['''PegasusTokenizer''']

try:
			if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__			 =	['''PegasusTokenizerFast''']

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__			 =	[
			    '''PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST''',
			    '''PegasusForCausalLM''',
			    '''PegasusForConditionalGeneration''',
			    '''PegasusModel''',
			    '''PegasusPreTrainedModel''',
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__			 =	[
			    '''TFPegasusForConditionalGeneration''',
			    '''TFPegasusModel''',
			    '''TFPegasusPreTrainedModel''',
			]

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			UpperCAmelCase__			 =	[
			    '''FlaxPegasusForConditionalGeneration''',
			    '''FlaxPegasusModel''',
			    '''FlaxPegasusPreTrainedModel''',
			]


if TYPE_CHECKING:
			from .configuration_pegasus import PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusConfig

			try:
						if not is_sentencepiece_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_pegasus import PegasusTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_pegasus_fast import PegasusTokenizerFast

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_pegasus import (
						    PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
						    PegasusForCausalLM,
						    PegasusForConditionalGeneration,
						    PegasusModel,
						    PegasusPreTrainedModel,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_pegasus import TFPegasusForConditionalGeneration, TFPegasusModel, TFPegasusPreTrainedModel

			try:
						if not is_flax_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_flax_pegasus import (
						    FlaxPegasusForConditionalGeneration,
						    FlaxPegasusModel,
						    FlaxPegasusPreTrainedModel,
						)

else:
			import sys

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





