import contextlib
import importlib
import io
import unittest

import transformers

# Try to import everything from transformers to ensure every object can be loaded.
from transformers import *  # noqa F406
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch
from transformers.utils import ContextManagers, find_labels, is_flax_available, is_tf_available, is_torch_available


if is_torch_available():
    from transformers import BertForPreTraining, BertForQuestionAnswering, BertForSequenceClassification

if is_tf_available():
    from transformers import TFBertForPreTraining, TFBertForQuestionAnswering, TFBertForSequenceClassification

if is_flax_available():
    from transformers import FlaxBertForPreTraining, FlaxBertForQuestionAnswering, FlaxBertForSequenceClassification


lowerCAmelCase__     						=			DUMMY_UNKNOWN_IDENTIFIER
# An actual model hosted on huggingface.co

lowerCAmelCase__     						=			'main'
# Default branch name
lowerCAmelCase__     						=			'f2c752cfc5c0ab6f4bdec59acea69eefbee381c2'
# One particular commit (not the top of `main`)
lowerCAmelCase__     						=			'aaaaaaa'
# This commit does not exist, so we should 404.

lowerCAmelCase__     						=			'd9e9f15bc825e4b2c9249e9578f884bbcb5e3684'
# Sha-1 of config.json on the top of `main`, for checking purposes
lowerCAmelCase__     						=			'4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d3'






@contextlib.contextmanager
def 				__lowerCamelCase		(						):
       print('Welcome!'     )
       yield
       print('Bye!'     )






@contextlib.contextmanager
def 				__lowerCamelCase		(						):
       print('Bonjour!'     )
       yield
       print('Au revoir!'     )
class     a_			(						unittest.TestCase						):






 '''simple docstring'''






 def 		__snake_case						(      self :  str):







        '''simple docstring'''



        assert transformers.__spec__ is not None
        assert importlib.util.find_spec('transformers') is not None






class     a_			(						unittest.TestCase						):






 '''simple docstring'''






 @unittest.mock.patch('sys.stdout'      ,   new_callable=io.StringIO)
 def 		__snake_case						(      self :  Tuple      ,   lowercase__ :  int):







        '''simple docstring'''



        with ContextManagers([]):
               print('Transformers are awesome!')
        # The print statement adds a new line at the end of the output
        self.assertEqual(mock_stdout.getvalue()      ,   'Transformers are awesome!\n')




 @unittest.mock.patch('sys.stdout'      ,   new_callable=io.StringIO)
 def 		__snake_case						(      self :  Tuple      ,   lowercase__ :  int):







        '''simple docstring'''



        with ContextManagers([context_en()]):
               print('Transformers are awesome!')
        # The output should be wrapped with an English welcome and goodbye
        self.assertEqual(mock_stdout.getvalue()      ,   'Welcome!\nTransformers are awesome!\nBye!\n')




 @unittest.mock.patch('sys.stdout'      ,   new_callable=io.StringIO)
 def 		__snake_case						(      self :  Optional[Any]      ,   lowercase__ :  Optional[int]):







        '''simple docstring'''



        with ContextManagers([context_fr(), context_en()]):
               print('Transformers are awesome!')
        # The output should be wrapped with an English and French welcome and goodbye
        self.assertEqual(mock_stdout.getvalue()      ,   'Bonjour!\nWelcome!\nTransformers are awesome!\nBye!\nAu revoir!\n')




 @require_torch
 def 		__snake_case						(      self :  Union[str, Any]):







        '''simple docstring'''



        self.assertEqual(find_labels(lowercase__)      ,   ['labels'])
        self.assertEqual(find_labels(lowercase__)      ,   ['labels', 'next_sentence_label'])
        self.assertEqual(find_labels(lowercase__)      ,   ['start_positions', 'end_positions'])
        class     a_			(						SCREAMING_SNAKE_CASE						):






         '''simple docstring'''






         pass






        self.assertEqual(find_labels(lowercase__)      ,   ['labels'])




 @require_tf
 def 		__snake_case						(      self :  Dict):







        '''simple docstring'''



        self.assertEqual(find_labels(lowercase__)      ,   ['labels'])
        self.assertEqual(find_labels(lowercase__)      ,   ['labels', 'next_sentence_label'])
        self.assertEqual(find_labels(lowercase__)      ,   ['start_positions', 'end_positions'])
        class     a_			(						SCREAMING_SNAKE_CASE						):






         '''simple docstring'''






         pass






        self.assertEqual(find_labels(lowercase__)      ,   ['labels'])




 @require_flax
 def 		__snake_case						(      self :  int):







        '''simple docstring'''



        self.assertEqual(find_labels(lowercase__)      ,   [])
        self.assertEqual(find_labels(lowercase__)      ,   [])
        self.assertEqual(find_labels(lowercase__)      ,   [])
        class     a_			(						SCREAMING_SNAKE_CASE						):






         '''simple docstring'''






         pass






        self.assertEqual(find_labels(lowercase__)      ,   [])

from collections import OrderedDict
from typing import Mapping

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


lowerCAmelCase__     						=			logging.get_logger(__name__)

lowerCAmelCase__     						=			{
    '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     a_			(						SCREAMING_SNAKE_CASE						):






 '''simple docstring'''






 UpperCAmelCase_     			= 'xlm-roberta-xl'




 def __init__(      self :  int      ,   lowercase__ :  Optional[int]=250_880      ,   lowercase__ :  Union[str, Any]=2_560      ,   lowercase__ :  int=36      ,   lowercase__ :  int=32      ,   lowercase__ :  List[Any]=10_240      ,   lowercase__ :  Union[str, Any]="gelu"      ,   lowercase__ :  Dict=0.1      ,   lowercase__ :  Any=0.1      ,   lowercase__ :  Any=514      ,   lowercase__ :  Optional[int]=1      ,   lowercase__ :  Any=0.02      ,   lowercase__ :  List[str]=1e-05      ,   lowercase__ :  Dict=1      ,   lowercase__ :  Union[str, Any]=0      ,   lowercase__ :  Dict=2      ,   lowercase__ :  str="absolute"      ,   lowercase__ :  Dict=True      ,   lowercase__ :  List[Any]=None      ,   **lowercase__ :  Optional[Any]      ,   ):







        '''simple docstring'''



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






class     a_			(						SCREAMING_SNAKE_CASE						):






 '''simple docstring'''






 @property
 def 		__snake_case						(      self :  int):







        '''simple docstring'''



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