
"""simple docstring"""

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


SCREAMING_SNAKE_CASE_    					=						{
    '''configuration_xlm_roberta_xl''': [
        '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''XLMRobertaXLConfig''',
        '''XLMRobertaXLOnnxConfig''',
    ],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   SCREAMING_SNAKE_CASE_    					=						[
       '''XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''XLMRobertaXLForCausalLM''',
       '''XLMRobertaXLForMaskedLM''',
       '''XLMRobertaXLForMultipleChoice''',
       '''XLMRobertaXLForQuestionAnswering''',
       '''XLMRobertaXLForSequenceClassification''',
       '''XLMRobertaXLForTokenClassification''',
       '''XLMRobertaXLModel''',
       '''XLMRobertaXLPreTrainedModel''',
   ]

if TYPE_CHECKING:
   from .configuration_xlm_roberta_xl import (
       XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
       XLMRobertaXLConfig,
       XLMRobertaXLOnnxConfig,
   )

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_xlm_roberta_xl import (
          XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
          XLMRobertaXLForCausalLM,
          XLMRobertaXLForMaskedLM,
          XLMRobertaXLForMultipleChoice,
          XLMRobertaXLForQuestionAnswering,
          XLMRobertaXLForSequenceClassification,
          XLMRobertaXLForTokenClassification,
          XLMRobertaXLModel,
          XLMRobertaXLPreTrainedModel,
      )

else:
   import sys

   SCREAMING_SNAKE_CASE_    					=						_LazyModule(__name__, globals()['''__file__'''], _import_structure)





"""simple docstring"""

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


SCREAMING_SNAKE_CASE_    					=						logging.get_logger(__name__)
class      _UpperCAmelCase							(		SCREAMING_SNAKE_CASE_							):
      __SCREAMING_SNAKE_CASE   :							Union[str, Any]							      =	"encoder-decoder"
      __SCREAMING_SNAKE_CASE   :							Any							      =	True




      def __init__(							self   ,       **lowercase_							)						->					str:
          super().__init__(**lowercase_							)
          assert (
              "encoder" in kwargs and "decoder" in kwargs
          ), "Config has to be initialized with encoder and decoder config"
          UpperCAmelCase									=					kwargs.pop('encoder'							)
          UpperCAmelCase									=					encoder_config.pop('model_type'							)
          UpperCAmelCase									=					kwargs.pop('decoder'							)
          UpperCAmelCase									=					decoder_config.pop('model_type'							)

          from ..auto.configuration_auto import AutoConfig

          UpperCAmelCase									=					AutoConfig.for_model(lowercase_   ,       **lowercase_							)
          UpperCAmelCase									=					AutoConfig.for_model(lowercase_   ,       **lowercase_							)
          UpperCAmelCase									=					True




      @classmethod
      def     a_      (							cls   ,       lowercase_   ,       lowercase_   ,       **lowercase_							)						->					PretrainedConfig:
          logger.info('Set `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()   ,       **lowercase_							)




      def     a_      (							self							)						->					Optional[int]:
          UpperCAmelCase									=					copy.deepcopy(self.__dict__							)
          UpperCAmelCase									=					self.encoder.to_dict()
          UpperCAmelCase									=					self.decoder.to_dict()
          UpperCAmelCase									=					self.__class__.model_type
          return output



