






"""simple docstring"""


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

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






class 						snake_case  (  UpperCAmelCase	):
				__magic_name__   					=					'''vision-encoder-decoder'''
				__magic_name__   					=					True





				def __init__(							self     : Union[str, Any]    ,		**A     : Optional[Any]      ):


						'''simple docstring'''




						super().__init__(**A      )
						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					:      int    =       kwargs.pop('encoder'      )
						a					:      List[str]    =       encoder_config.pop('model_type'      )
						a					:      Any    =       kwargs.pop('decoder'      )
						a					:      Dict    =       decoder_config.pop('model_type'      )

						a					:      Optional[Any]    =       AutoConfig.for_model(A    ,		**A      )
						a					:      List[str]    =       AutoConfig.for_model(A    ,		**A      )
						a					:      Dict    =       True





				@classmethod
				def     lowerCamelCase__				(							cls     : Optional[Any]    ,		A     : PretrainedConfig    ,		A     : PretrainedConfig    ,		**A     : Any      ):


						'''simple docstring'''




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

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





				def     lowerCamelCase__				(							self     : Any      ):


						'''simple docstring'''




						a					:      List[str]    =       copy.deepcopy(self.__dict__      )
						a					:      Optional[Any]    =       self.encoder.to_dict()
						a					:      List[Any]    =       self.decoder.to_dict()
						a					:      Any    =       self.__class__.model_type
						return output






class 						snake_case  (  UpperCAmelCase	):
				__magic_name__   					=					version.parse('''1.11'''	)





				@property
				def     lowerCamelCase__				(							self     : str      ):


						'''simple docstring'''




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





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


						'''simple docstring'''




						return 1E-4





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


						'''simple docstring'''




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






class 						snake_case  (  UpperCAmelCase	):





				@property
				def     lowerCamelCase__				(							self     : Dict      ):


						'''simple docstring'''




						a					:      Union[str, Any]    =       OrderedDict()
						a					:      Any    =       {0: 'batch', 1: 'past_decoder_sequence + sequence'}
						a					:      List[str]    =       {0: 'batch', 1: 'past_decoder_sequence + sequence'}
						a					:      Tuple    =       {0: 'batch', 1: 'encoder_sequence'}

						return common_inputs





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


						'''simple docstring'''




						import torch

						a					:      List[Any]    =       OrderedDict()

						a					:      Union[str, Any]    =       super().generate_dummy_inputs(
						    A    ,		batch_size=A    ,		seq_length=A    ,		is_pair=A    ,		framework=A      )

						a					:      Dict    =       dummy_input['input_ids'].shape
						a					:      Union[str, Any]    =       (batch, encoder_sequence, self._config.encoder_hidden_size)
						a					:      Tuple    =       dummy_input.pop('input_ids'      )
						a					:      str    =       dummy_input.pop('attention_mask'      )
						a					:      Optional[Any]    =       torch.zeros(A      )

						return common_inputs






class 						snake_case  (  UpperCAmelCase	):





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


						'''simple docstring'''




						pass





				def     lowerCamelCase__				(							self     : Dict    ,		A     : PretrainedConfig      ):


						'''simple docstring'''




						return VisionEncoderDecoderEncoderOnnxConfig(A      )





				def     lowerCamelCase__				(							self     : List[Any]    ,		A     : PretrainedConfig    ,		A     : PretrainedConfig    ,		A     : str = "default"      ):


						'''simple docstring'''




						a					:      str    =       encoder_config.hidden_size
						return VisionEncoderDecoderDecoderOnnxConfig(A    ,		A      )












"""simple docstring"""


from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

_UpperCamelCase    :   List[Any]   			=						{
    'microsoft/beit-base-patch16-224-pt22k': (
        'https://huggingface.co/microsoft/beit-base-patch16-224-pt22k/resolve/main/config.json'
    ),
    # See all BEiT models at https://huggingface.co/models?filter=beit
}






class 						snake_case  (  UpperCAmelCase	):
    __magic_name__   					=					'''beit'''





    def __init__(							self     : int    ,		A     : int=8_1_9_2    ,		A     : List[Any]=7_6_8    ,		A     : str=1_2    ,		A     : str=1_2    ,		A     : Dict=3_0_7_2    ,		A     : Optional[int]="gelu"    ,		A     : List[Any]=0.0    ,		A     : Union[str, Any]=0.0    ,		A     : Optional[Any]=0.02    ,		A     : Optional[int]=1E-12    ,		A     : Dict=2_2_4    ,		A     : str=1_6    ,		A     : Optional[Any]=3    ,		A     : List[Any]=False    ,		A     : Union[str, Any]=False    ,		A     : Optional[Any]=False    ,		A     : int=False    ,		A     : List[str]=0.1    ,		A     : Union[str, Any]=0.1    ,		A     : str=True    ,		A     : Tuple=[3, 5, 7, 1_1]    ,		A     : List[str]=[1, 2, 3, 6]    ,		A     : Optional[Any]=True    ,		A     : Union[str, Any]=0.4    ,		A     : Any=2_5_6    ,		A     : List[Any]=1    ,		A     : Optional[Any]=False    ,		A     : Any=2_5_5    ,		**A     : List[Any]    ,		):


      '''simple docstring'''




      super().__init__(**A      )

      a					:      Optional[int]    =       vocab_size
      a					:      Dict    =       hidden_size
      a					:      Optional[int]    =       num_hidden_layers
      a					:      Tuple    =       num_attention_heads
      a					:      Optional[int]    =       intermediate_size
      a					:      Optional[Any]    =       hidden_act
      a					:      Optional[int]    =       hidden_dropout_prob
      a					:      Optional[int]    =       attention_probs_dropout_prob
      a					:      Optional[Any]    =       initializer_range
      a					:      Union[str, Any]    =       layer_norm_eps

      a					:      Union[str, Any]    =       image_size
      a					:      str    =       patch_size
      a					:      Optional[Any]    =       num_channels
      a					:      List[str]    =       use_mask_token
      a					:      Optional[Any]    =       use_absolute_position_embeddings
      a					:      Any    =       use_relative_position_bias
      a					:      Any    =       use_shared_relative_position_bias
      a					:      Dict    =       layer_scale_init_value
      a					:      Optional[int]    =       drop_path_rate
      a					:      Dict    =       use_mean_pooling
      # decode head attributes (semantic segmentation)
      a					:      Optional[Any]    =       out_indices
      a					:      List[str]    =       pool_scales
      # auxiliary head attributes (semantic segmentation)
      a					:      Tuple    =       use_auxiliary_head
      a					:      Dict    =       auxiliary_loss_weight
      a					:      Any    =       auxiliary_channels
      a					:      Dict    =       auxiliary_num_convs
      a					:      List[str]    =       auxiliary_concat_input
      a					:      List[Any]    =       semantic_loss_ignore_index






class 						snake_case  (  UpperCAmelCase	):
    __magic_name__   					=					version.parse('''1.11'''	)





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


      '''simple docstring'''




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





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


      '''simple docstring'''




      return 1E-4




