




import copy
from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


if TYPE_CHECKING:
				from ... import PreTrainedTokenizerBase, TensorType

a													=			logging.get_logger(__name__)




class       _A				(		__lowercase     ):
		__a					    =       """vision-encoder-decoder"""
		__a					    =       True






		def __init__(    self						,		**_SCREAMING_SNAKE_CASE			):
								super().__init__(**_SCREAMING_SNAKE_CASE			)
								if "encoder" not in kwargs or "decoder" not in kwargs:
														raise ValueError(
														    F"A configuraton of type {self.model_type} cannot be instantiated because "
														    F"not both `encoder` and `decoder` sub-configurations are passed, but only {kwargs}"			)

								_UpperCAmelCase      =			kwargs.pop("""encoder"""			)
								_UpperCAmelCase      =			encoder_config.pop("""model_type"""			)
								_UpperCAmelCase      =			kwargs.pop("""decoder"""			)
								_UpperCAmelCase      =			decoder_config.pop("""model_type"""			)

								_UpperCAmelCase      =			AutoConfig.for_model(_SCREAMING_SNAKE_CASE						,		**_SCREAMING_SNAKE_CASE			)
								_UpperCAmelCase      =			AutoConfig.for_model(_SCREAMING_SNAKE_CASE						,		**_SCREAMING_SNAKE_CASE			)
								_UpperCAmelCase      =			True






		@classmethod
		def 				UpperCAmelCase (    cls						,		_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE						,		**_SCREAMING_SNAKE_CASE			):
								logger.info("""Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"""			)
								_UpperCAmelCase      =			True
								_UpperCAmelCase      =			True

								return cls(encoder=encoder_config.to_dict()						,		decoder=decoder_config.to_dict()						,		**_SCREAMING_SNAKE_CASE			)






		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			copy.deepcopy(self.__dict__			)
								_UpperCAmelCase      =			self.encoder.to_dict()
								_UpperCAmelCase      =			self.decoder.to_dict()
								_UpperCAmelCase      =			self.__class__.model_type
								return output




class       _A				(		__lowercase     ):
		__a					    =       version.parse("""1.11"""     )






		@property
		def 				UpperCAmelCase (    self			):
								return OrderedDict(
								    [
								        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
								    ]			)






		@property
		def 				UpperCAmelCase (    self			):
								return 1e-4






		@property
		def 				UpperCAmelCase (    self			):
								return OrderedDict({"""last_hidden_state""": {0: """batch""", 1: """encoder_sequence"""}}			)




class       _A				(		__lowercase     ):






		@property
		def 				UpperCAmelCase (    self			):
								_UpperCAmelCase      =			OrderedDict()
								_UpperCAmelCase      =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
								_UpperCAmelCase      =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
								_UpperCAmelCase      =			{0: """batch""", 1: """encoder_sequence"""}

								return common_inputs






		def 				UpperCAmelCase (    self						,		_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE = -1						,		_SCREAMING_SNAKE_CASE = -1						,		_SCREAMING_SNAKE_CASE = False						,		_SCREAMING_SNAKE_CASE = None						,		):
								import torch

								_UpperCAmelCase      =			OrderedDict()

								_UpperCAmelCase      =			super().generate_dummy_inputs(
								    _SCREAMING_SNAKE_CASE						,		batch_size=_SCREAMING_SNAKE_CASE						,		seq_length=_SCREAMING_SNAKE_CASE						,		is_pair=_SCREAMING_SNAKE_CASE						,		framework=_SCREAMING_SNAKE_CASE			)

								_UpperCAmelCase    ,					_UpperCAmelCase      =			dummy_input["""input_ids"""].shape
								_UpperCAmelCase      =			(batch, encoder_sequence, self._config.encoder_hidden_size)
								_UpperCAmelCase      =			dummy_input.pop("""input_ids"""			)
								_UpperCAmelCase      =			dummy_input.pop("""attention_mask"""			)
								_UpperCAmelCase      =			torch.zeros(_SCREAMING_SNAKE_CASE			)

								return common_inputs




class       _A				(		__lowercase     ):






		@property
		def 				UpperCAmelCase (    self			):
								pass






		def 				UpperCAmelCase (    self						,		_SCREAMING_SNAKE_CASE			):
								return VisionEncoderDecoderEncoderOnnxConfig(_SCREAMING_SNAKE_CASE			)






		def 				UpperCAmelCase (    self						,		_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE = "default"			):
								_UpperCAmelCase      =			encoder_config.hidden_size
								return VisionEncoderDecoderDecoderOnnxConfig(_SCREAMING_SNAKE_CASE						,		_SCREAMING_SNAKE_CASE			)





# flake8: noqa
# Lint as: python3
a													=			[
    "VerificationMode",
    "Version",
    "disable_progress_bar",
    "enable_progress_bar",
    "is_progress_bar_enabled",
    "experimental",
]

from .info_utils import VerificationMode
from .logging import disable_progress_bar, enable_progress_bar, is_progress_bar_enabled
from .version import Version
from .experimental import experimental