






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

lowerCAmelCase_	:    Optional[Any]            =      logging.get_logger(__name__)





class   UpperCamelCase_ (       lowercase__  ):
  _A       :					Union[str, Any]				=	'vision-encoder-decoder'
  _A       :					List[str]				=	True



  def __init__(      self ,		**snake_case__				)			->			Any:



      """simple docstring"""





      super().__init__(**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(snake_case__ ,		**snake_case__				)
      UpperCAmelCase	    =			AutoConfig.for_model(snake_case__ ,		**snake_case__				)
      UpperCAmelCase	    =			True



  @classmethod
  def 		UpperCamelCase_				(      cls ,		snake_case__ ,		snake_case__ ,		**snake_case__				)			->			List[Any]:



      """simple docstring"""





      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() ,		**snake_case__				)



  def 		UpperCamelCase_				(      self				)			->			str:



      """simple docstring"""





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





class   UpperCamelCase_ (       lowercase__  ):
  _A       :					Any				=	version.parse('1.11'  )



  @property
  def 		UpperCamelCase_				(      self				)			->			List[str]:



      """simple docstring"""





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



  @property
  def 		UpperCamelCase_				(      self				)			->			Any:



      """simple docstring"""





      return 1e-4



  @property
  def 		UpperCamelCase_				(      self				)			->			int:



      """simple docstring"""





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





class   UpperCamelCase_ (       lowercase__  ):



  @property
  def 		UpperCamelCase_				(      self				)			->			Any:



      """simple docstring"""





      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 ,		snake_case__ ,		snake_case__ = -1 ,		snake_case__ = -1 ,		snake_case__ = False ,		snake_case__ = None ,		)			->			Optional[Any]:



      """simple docstring"""





      import torch

      UpperCAmelCase	    =			OrderedDict()

      UpperCAmelCase	    =			super().generate_dummy_inputs(
          snake_case__ ,		batch_size=snake_case__ ,		seq_length=snake_case__ ,		is_pair=snake_case__ ,		framework=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(snake_case__				)

      return common_inputs





class   UpperCamelCase_ (       lowercase__  ):



  @property
  def 		UpperCamelCase_				(      self				)			->			List[Any]:



      """simple docstring"""





      pass



  def 		UpperCamelCase_				(      self ,		snake_case__				)			->			Optional[int]:



      """simple docstring"""





      return VisionEncoderDecoderEncoderOnnxConfig(snake_case__				)



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__ ,		snake_case__ = "default"				)			->			str:



      """simple docstring"""





      UpperCAmelCase	    =			encoder_config.hidden_size
      return VisionEncoderDecoderDecoderOnnxConfig(snake_case__ ,		snake_case__				)








"""simple docstring"""







from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase_	:    int            =      logging.get_logger(__name__)

lowerCAmelCase_	:    List[Any]            =      {
    '''facebook/xlm-roberta-xl''': '''https://huggingface.co/facebook/xlm-roberta-xl/resolve/main/config.json''',
    '''facebook/xlm-roberta-xxl''': '''https://huggingface.co/facebook/xlm-roberta-xxl/resolve/main/config.json''',
    # See all XLM-RoBERTa-XL models at https://huggingface.co/models?filter=xlm-roberta-xl
}





class   UpperCamelCase_ (       a_  ):
  _A       :					int				=	'xlm-roberta-xl'



  def __init__(      self ,		snake_case__=25_08_80 ,		snake_case__=25_60 ,		snake_case__=36 ,		snake_case__=32 ,		snake_case__=1_02_40 ,		snake_case__="gelu" ,		snake_case__=0.1 ,		snake_case__=0.1 ,		snake_case__=5_14 ,		snake_case__=1 ,		snake_case__=0.02 ,		snake_case__=1e-05 ,		snake_case__=1 ,		snake_case__=0 ,		snake_case__=2 ,		snake_case__="absolute" ,		snake_case__=True ,		snake_case__=None ,		**snake_case__ ,		)			->			Union[str, Any]:



         """simple docstring"""





         super().__init__(pad_token_id=snake_case__ ,		bos_token_id=snake_case__ ,		eos_token_id=snake_case__ ,		**snake_case__				)
         UpperCAmelCase	    =			vocab_size
         UpperCAmelCase	    =			hidden_size
         UpperCAmelCase	    =			num_hidden_layers
         UpperCAmelCase	    =			num_attention_heads
         UpperCAmelCase	    =			hidden_act
         UpperCAmelCase	    =			intermediate_size
         UpperCAmelCase	    =			hidden_dropout_prob
         UpperCAmelCase	    =			attention_probs_dropout_prob
         UpperCAmelCase	    =			max_position_embeddings
         UpperCAmelCase	    =			type_vocab_size
         UpperCAmelCase	    =			initializer_range
         UpperCAmelCase	    =			layer_norm_eps
         UpperCAmelCase	    =			position_embedding_type
         UpperCAmelCase	    =			use_cache
         UpperCAmelCase	    =			classifier_dropout





class   UpperCamelCase_ (       a_  ):



  @property
  def 		UpperCamelCase_				(      self				)			->			Mapping[str, Mapping[int, str]]:



         """simple docstring"""





         if self.task == "multiple-choice":
                UpperCAmelCase	    =			{0: """batch""", 1: """choice""", 2: """sequence"""}
         else:
                UpperCAmelCase	    =			{0: """batch""", 1: """sequence"""}
         return OrderedDict(
             [
                 ("""input_ids""", dynamic_axis),
                 ("""attention_mask""", dynamic_axis),
             ]				)
