






'''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      :       Optional[int]      			=      logging.get_logger(__name__)
class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):
      __a  					="vision-encoder-decoder"
      __a  					=True




      def __init__(  self ,   **lowerCamelCase      )							->Optional[int]:



         '''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				     =    kwargs.pop('encoder'      )
         __a				     =    encoder_config.pop('model_type'      )
         __a				     =    kwargs.pop('decoder'      )
         __a				     =    decoder_config.pop('model_type'      )

         __a				     =    AutoConfig.for_model(lowerCamelCase ,   **lowerCamelCase      )
         __a				     =    AutoConfig.for_model(lowerCamelCase ,   **lowerCamelCase      )
         __a				     =    True




      @classmethod
      def  __UpperCamelCase							(  cls ,   lowerCamelCase ,   lowerCamelCase ,   **lowerCamelCase      )							->PretrainedConfig:



         '''simple docstring'''
         logger.info('Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'      )
         __a				     =    True
         __a				     =    True

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






      def  __UpperCamelCase							(  self      )							->str:



         '''simple docstring'''
         __a				     =    copy.deepcopy(self.__dict__      )
         __a				     =    self.encoder.to_dict()
         __a				     =    self.decoder.to_dict()
         __a				     =    self.__class__.model_type
         return output







class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):
      __a  					=version.parse("1.11"     )




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



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




      @property
      def  __UpperCamelCase							(  self      )							->float:



         '''simple docstring'''
         return 1e-4






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



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







class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):




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



         '''simple docstring'''
         __a				     =    OrderedDict()
         __a				     =    {0: 'batch', 1: 'past_decoder_sequence + sequence'}
         __a				     =    {0: 'batch', 1: 'past_decoder_sequence + sequence'}
         __a				     =    {0: 'batch', 1: 'encoder_sequence'}

         return common_inputs






      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase = -1 ,   lowerCamelCase = -1 ,   lowerCamelCase = False ,   lowerCamelCase = None ,   )							->Mapping[str, Any]:



         '''simple docstring'''
         import torch

         __a				     =    OrderedDict()

         __a				     =    super().generate_dummy_inputs(
             lowerCamelCase ,   batch_size=lowerCamelCase ,   seq_length=lowerCamelCase ,   is_pair=lowerCamelCase ,   framework=lowerCamelCase      )

         __a     ,			__a				     =    dummy_input['input_ids'].shape
         __a				     =    (batch, encoder_sequence, self._config.encoder_hidden_size)
         __a				     =    dummy_input.pop('input_ids'      )
         __a				     =    dummy_input.pop('attention_mask'      )
         __a				     =    torch.zeros(lowerCamelCase      )

         return common_inputs







class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):




      @property
      def  __UpperCamelCase							(  self      )							->None:



         '''simple docstring'''
         pass




      def  __UpperCamelCase							(  self ,   lowerCamelCase      )							->OnnxConfig:



         '''simple docstring'''
         return VisionEncoderDecoderEncoderOnnxConfig(lowerCamelCase      )






      def  __UpperCamelCase							(  self ,   lowerCamelCase ,   lowerCamelCase ,   lowerCamelCase = "default"      )							->OnnxConfig:



         '''simple docstring'''
         __a				     =    encoder_config.hidden_size
         return VisionEncoderDecoderDecoderOnnxConfig(lowerCamelCase ,   lowerCamelCase      )







'''simple docstring'''



from collections import OrderedDict
from typing import Mapping

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


__UpperCamelCase      :       Dict      			=      logging.get_logger(__name__)

__UpperCamelCase      :       Optional[int]      			=      {
    """facebook/xmod-base""": """https://huggingface.co/facebook/xmod-base/resolve/main/config.json""",
    """facebook/xmod-large-prenorm""": """https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json""",
    """facebook/xmod-base-13-125k""": """https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json""",
    """facebook/xmod-base-30-125k""": """https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json""",
    """facebook/xmod-base-30-195k""": """https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json""",
    """facebook/xmod-base-60-125k""": """https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json""",
    """facebook/xmod-base-60-265k""": """https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json""",
    """facebook/xmod-base-75-125k""": """https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json""",
    """facebook/xmod-base-75-269k""": """https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json""",
}
class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):
      __a  					="xmod"




      def __init__(  self ,   lowerCamelCase=3_0522 ,   lowerCamelCase=768 ,   lowerCamelCase=12 ,   lowerCamelCase=12 ,   lowerCamelCase=3072 ,   lowerCamelCase="gelu" ,   lowerCamelCase=0.1 ,   lowerCamelCase=0.1 ,   lowerCamelCase=512 ,   lowerCamelCase=2 ,   lowerCamelCase=0.02 ,   lowerCamelCase=1e-12 ,   lowerCamelCase=1 ,   lowerCamelCase=0 ,   lowerCamelCase=2 ,   lowerCamelCase="absolute" ,   lowerCamelCase=True ,   lowerCamelCase=None ,   lowerCamelCase=False ,   lowerCamelCase=2 ,   lowerCamelCase=False ,   lowerCamelCase=True ,   lowerCamelCase=True ,   lowerCamelCase=("en_XX",) ,   lowerCamelCase=None ,   **lowerCamelCase ,   )							->Any:



         '''simple docstring'''
         super().__init__(pad_token_id=lowerCamelCase ,   bos_token_id=lowerCamelCase ,   eos_token_id=lowerCamelCase ,   **lowerCamelCase      )

         __a				     =    vocab_size
         __a				     =    hidden_size
         __a				     =    num_hidden_layers
         __a				     =    num_attention_heads
         __a				     =    hidden_act
         __a				     =    intermediate_size
         __a				     =    hidden_dropout_prob
         __a				     =    attention_probs_dropout_prob
         __a				     =    max_position_embeddings
         __a				     =    type_vocab_size
         __a				     =    initializer_range
         __a				     =    layer_norm_eps
         __a				     =    position_embedding_type
         __a				     =    use_cache
         __a				     =    classifier_dropout
         __a				     =    pre_norm
         __a				     =    adapter_reduction_factor
         __a				     =    adapter_layer_norm
         __a				     =    adapter_reuse_layer_norm
         __a				     =    ln_before_adapter
         __a				     =    list(lowerCamelCase      )
         __a				     =    default_language







class 							__SCREAMING_SNAKE_CASE       (							_lowerCAmelCase     ):




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



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