



"""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


lowercase_							 =       logging.get_logger(__name__)







class       __a	(   __snake_case       ):
				lowerCamelCase    :					int 					="vision-text-dual-encoder"
				lowerCamelCase    :					Dict 					=True







				def __init__(   self			,  UpperCAmelCase=512			,  UpperCAmelCase=2.6_5_9_2			,  **UpperCAmelCase      ):

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

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

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

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

					lowerCAmelCase_			       = AutoConfig.for_model(UpperCAmelCase_			,  **UpperCAmelCase_      )

					lowerCAmelCase_			       = projection_dim
					lowerCAmelCase_			       = logit_scale_init_value







				@classmethod
				def     lowerCamelCase_    (   cls			,  UpperCAmelCase			,  UpperCAmelCase			,  **UpperCAmelCase      ):

					'''simple docstring'''






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







				def     lowerCamelCase_    (   self      ):

					'''simple docstring'''






					lowerCAmelCase_			       = copy.deepcopy(self.__dict__      )
					lowerCAmelCase_			       = self.vision_config.to_dict()
					lowerCAmelCase_			       = self.text_config.to_dict()
					lowerCAmelCase_			       = 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,
)


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

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

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

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

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

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		lowercase_							 =       [
		    '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

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