




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

_lowerCamelCase  :			Optional[int]        =       logging.get_logger(__name__)

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    List[str]         =   """vision-encoder-decoder"""
				__lowerCAmelCase    :    Any         =   True







				def __init__(							self   :					str      ,     **_lowerCamelCase   :					Any       ):



					"""simple docstring"""

					super().__init__(**_lowerCamelCase       )
					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}"""       )

					A_  :				str	   =		kwargs.pop('''encoder'''       )
					A_  :				Optional[int]	   =		encoder_config.pop('''model_type'''       )
					A_  :				Tuple	   =		kwargs.pop('''decoder'''       )
					A_  :				int	   =		decoder_config.pop('''model_type'''       )

					A_  :				Dict	   =		AutoConfig.for_model(_lowerCamelCase      ,     **_lowerCamelCase       )
					A_  :				Tuple	   =		AutoConfig.for_model(_lowerCamelCase      ,     **_lowerCamelCase       )
					A_  :				Dict	   =		True







				@classmethod
				def 					a_  (							cls   :					str      ,     _lowerCamelCase   :					PretrainedConfig      ,     _lowerCamelCase   :					PretrainedConfig      ,     **_lowerCamelCase   :					Optional[Any]       ):



					"""simple docstring"""

					logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'''       )
					A_  :				List[str]	   =		True
					A_  :				Optional[Any]	   =		True

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







				def 					a_  (							self   :					str       ):



					"""simple docstring"""

					A_  :				List[Any]	   =		copy.deepcopy(self.__dict__       )
					A_  :				Dict	   =		self.encoder.to_dict()
					A_  :				int	   =		self.decoder.to_dict()
					A_  :				Union[str, Any]	   =		self.__class__.model_type
					return output

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Dict         =   version.parse("""1.11""")







				@property
				def 					a_  (							self   :					List[str]       ):



					"""simple docstring"""

					return OrderedDict(
					    [
					        ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
					    ]       )







				@property
				def 					a_  (							self   :					Optional[int]       ):



					"""simple docstring"""

					return 1E-4







				@property
				def 					a_  (							self   :					Optional[Any]       ):



					"""simple docstring"""

					return OrderedDict({'''last_hidden_state''': {0: '''batch''', 1: '''encoder_sequence'''}}       )

class        lowercase      (    __UpperCAmelCase):







				@property
				def 					a_  (							self   :					str       ):



					"""simple docstring"""

					A_  :				Any	   =		OrderedDict()
					A_  :				Optional[Any]	   =		{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
					A_  :				int	   =		{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
					A_  :				Optional[int]	   =		{0: '''batch''', 1: '''encoder_sequence'''}

					return common_inputs







				def 					a_  (							self   :					List[Any]      ,     _lowerCamelCase   :					"PreTrainedTokenizerBase"      ,     _lowerCamelCase   :					int = -1      ,     _lowerCamelCase   :					int = -1      ,     _lowerCamelCase   :					bool = False      ,     _lowerCamelCase   :					Optional["TensorType"] = None      ,     ):



					"""simple docstring"""

					import torch

					A_  :				Optional[int]	   =		OrderedDict()

					A_  :				Optional[Any]	   =		super().generate_dummy_inputs(
					    _lowerCamelCase      ,     batch_size=_lowerCamelCase      ,     seq_length=_lowerCamelCase      ,     is_pair=_lowerCamelCase      ,     framework=_lowerCamelCase       )

					A_   , A_  :				Any	   =		dummy_input['''input_ids'''].shape
					A_  :				str	   =		(batch, encoder_sequence, self._config.encoder_hidden_size)
					A_  :				List[Any]	   =		dummy_input.pop('''input_ids'''       )
					A_  :				Union[str, Any]	   =		dummy_input.pop('''attention_mask'''       )
					A_  :				Dict	   =		torch.zeros(_lowerCamelCase       )

					return common_inputs

class        lowercase      (    __UpperCAmelCase):







				@property
				def 					a_  (							self   :					str       ):



					"""simple docstring"""

					pass







				def 					a_  (							self   :					Optional[Any]      ,     _lowerCamelCase   :					PretrainedConfig       ):



					"""simple docstring"""

					return VisionEncoderDecoderEncoderOnnxConfig(_lowerCamelCase       )







				def 					a_  (							self   :					Tuple      ,     _lowerCamelCase   :					PretrainedConfig      ,     _lowerCamelCase   :					PretrainedConfig      ,     _lowerCamelCase   :					str = "default"       ):



					"""simple docstring"""

					A_  :				Optional[Any]	   =		encoder_config.hidden_size
					return VisionEncoderDecoderDecoderOnnxConfig(_lowerCamelCase      ,     _lowerCamelCase       )











"""simple docstring"""

from typing import TYPE_CHECKING

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


_lowerCamelCase  :			Optional[Any]        =       {
    'configuration_mask2former': [
        'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Mask2FormerConfig',
    ],
}

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase  :			int        =       ['Mask2FormerImageProcessor']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase  :			Tuple        =       [
		    'MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'Mask2FormerForUniversalSegmentation',
		    'Mask2FormerModel',
		    'Mask2FormerPreTrainedModel',
		]

if TYPE_CHECKING:
		from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .image_processing_maskaformer import MaskaFormerImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_maskaformer import (
				    MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    MaskaFormerForUniversalSegmentation,
				    MaskaFormerModel,
				    MaskaFormerPreTrainedModel,
				)


else:
		import sys

		_lowerCamelCase  :			Optional[Any]        =       _LazyModule(__name__, globals()['__file__'], _import_structure)





