





import copy

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


UpperCAmelCase__  :	Union[str, Any]     =logging.get_logger(__name__)

class 					__A   (  a			):
				__A            = """vision-text-dual-encoder"""
				__A            = True


				def __init__(						self      ,       UpperCAmelCase_=512      ,       UpperCAmelCase_=2.6_5_9_2      ,       **UpperCAmelCase_							):
								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 _snake_case				(						cls      ,       UpperCAmelCase_      ,       UpperCAmelCase_      ,       **UpperCAmelCase_							):
								return cls(vision_config=vision_config.to_dict()      ,       text_config=text_config.to_dict()      ,       **UpperCAmelCase_							)


				def _snake_case				(						self							):
								lowerCamelCase		       =copy.deepcopy(self.__dict__							)
								lowerCamelCase		       =self.vision_config.to_dict()
								lowerCamelCase		       =self.text_config.to_dict()
								lowerCamelCase		       =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__  :	Optional[Any]     ={'''configuration_pegasus''': ['''PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusConfig''']}

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

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

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

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

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__  :	Dict     =[
							    '''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__  :	Union[str, Any]     =_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





