



'''simple docstring'''
import unittest

from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow


if is_flax_available():
					import jax

					from transformers.models.auto.modeling_flax_auto import FlaxAutoModel
					from transformers.models.bert.modeling_flax_bert import FlaxBertModel
					from transformers.models.roberta.modeling_flax_roberta import FlaxRobertaModel






@require_flax
class 							lowercase__     (							unittest.TestCase       ):





	@slow
	def      UpperCamelCase_  (			self :    str			):







							'''simple docstring'''
							for model_name in ["bert-base-cased", "bert-large-uncased"]:
													with self.subTest(__lowerCamelCase			):
																			_UpperCamelCase :		Any			    =       AutoConfig.from_pretrained(__lowerCamelCase			)
																			self.assertIsNotNone(__lowerCamelCase			)
																			self.assertIsInstance(__lowerCamelCase			,__lowerCamelCase			)

																			_UpperCamelCase :		Optional[Any]			    =       FlaxAutoModel.from_pretrained(__lowerCamelCase			)
																			self.assertIsNotNone(__lowerCamelCase			)
																			self.assertIsInstance(__lowerCamelCase			,__lowerCamelCase			)





	@slow
	def      UpperCamelCase_  (			self :    str			):







							'''simple docstring'''
							for model_name in ["roberta-base", "roberta-large"]:
													with self.subTest(__lowerCamelCase			):
																			_UpperCamelCase :		Tuple			    =       AutoConfig.from_pretrained(__lowerCamelCase			)
																			self.assertIsNotNone(__lowerCamelCase			)
																			self.assertIsInstance(__lowerCamelCase			,__lowerCamelCase			)

																			_UpperCamelCase :		Tuple			    =       FlaxAutoModel.from_pretrained(__lowerCamelCase			)
																			self.assertIsNotNone(__lowerCamelCase			)
																			self.assertIsInstance(__lowerCamelCase			,__lowerCamelCase			)





	@slow
	def      UpperCamelCase_  (			self :    Optional[int]			):







							'''simple docstring'''
							for model_name in ["bert-base-cased", "bert-large-uncased"]:
													_UpperCamelCase :		Union[str, Any]			    =       AutoTokenizer.from_pretrained(__lowerCamelCase			)
													_UpperCamelCase :		List[str]			    =       FlaxBertModel.from_pretrained(__lowerCamelCase			)
													_UpperCamelCase :		Union[str, Any]			    =       tokenizer('Do you support jax jitted function?'			,return_tensors=TensorType.JAX			)

													@jax.jit
													def eval(**lowerCamelCase__ :    Union[str, Any]			):
																			return model(**__lowerCamelCase			)

													eval(**__lowerCamelCase			).block_until_ready()





	@slow
	def      UpperCamelCase_  (			self :    List[str]			):







							'''simple docstring'''
							for model_name in ["roberta-base", "roberta-large"]:
													_UpperCamelCase :		str			    =       AutoTokenizer.from_pretrained(__lowerCamelCase			)
													_UpperCamelCase :		int			    =       FlaxRobertaModel.from_pretrained(__lowerCamelCase			)
													_UpperCamelCase :		Optional[Any]			    =       tokenizer('Do you support jax jitted function?'			,return_tensors=TensorType.JAX			)

													@jax.jit
													def eval(**lowerCamelCase__ :    List[Any]			):
																			return model(**__lowerCamelCase			)

													eval(**__lowerCamelCase			).block_until_ready()





	def      UpperCamelCase_  (			self :    Optional[int]			):







							'''simple docstring'''
							with self.assertRaisesRegex(
							    __lowerCamelCase			,'bert-base is not a local folder and is not a valid model identifier'			):
													_UpperCamelCase :		Any			    =       FlaxAutoModel.from_pretrained('bert-base'			)





	def      UpperCamelCase_  (			self :    Union[str, Any]			):







							'''simple docstring'''
							with self.assertRaisesRegex(
							    __lowerCamelCase			,R'aaaaaa is not a valid git identifier \(branch name, tag name or commit id\)'			):
													_UpperCamelCase :		List[Any]			    =       FlaxAutoModel.from_pretrained(__lowerCamelCase			,revision='aaaaaa'			)





	def      UpperCamelCase_  (			self :    Tuple			):







							'''simple docstring'''
							with self.assertRaisesRegex(
							    __lowerCamelCase			,'hf-internal-testing/config-no-model does not appear to have a file named flax_model.msgpack'			,):
													_UpperCamelCase :		Dict			    =       FlaxAutoModel.from_pretrained('hf-internal-testing/config-no-model'			)





	def      UpperCamelCase_  (			self :    Tuple			):







							'''simple docstring'''
							with self.assertRaisesRegex(__lowerCamelCase			,'Use `from_pt=True` to load this model'			):
													_UpperCamelCase :		List[Any]			    =       FlaxAutoModel.from_pretrained('hf-internal-testing/tiny-bert-pt-only'			)








'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

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


snake_case_			:     Optional[int]  	=  logging.get_logger(__name__)

snake_case_			:     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 							lowercase__     (							lowercase       ):
	lowercase__      =      """xlm-roberta-xl"""





	def __init__(			self :    Optional[int]			,lowerCamelCase__ :    Optional[Any]=250880			,lowerCamelCase__ :    Tuple=2560			,lowerCamelCase__ :    Union[str, Any]=36			,lowerCamelCase__ :    List[str]=32			,lowerCamelCase__ :    Optional[Any]=10240			,lowerCamelCase__ :    Tuple="gelu"			,lowerCamelCase__ :    int=0.1			,lowerCamelCase__ :    int=0.1			,lowerCamelCase__ :    Optional[int]=514			,lowerCamelCase__ :    List[str]=1			,lowerCamelCase__ :    Dict=0.0_2			,lowerCamelCase__ :    Any=1E-05			,lowerCamelCase__ :    Union[str, Any]=1			,lowerCamelCase__ :    str=0			,lowerCamelCase__ :    Tuple=2			,lowerCamelCase__ :    Union[str, Any]="absolute"			,lowerCamelCase__ :    Optional[Any]=True			,lowerCamelCase__ :    List[str]=None			,**lowerCamelCase__ :    Dict			,):







							'''simple docstring'''
							super().__init__(pad_token_id=lowerCamelCase__			,bos_token_id=lowerCamelCase__			,eos_token_id=lowerCamelCase__			,**lowerCamelCase__			)
							_UpperCamelCase :		Optional[int]			    =       vocab_size
							_UpperCamelCase :		Optional[Any]			    =       hidden_size
							_UpperCamelCase :		str			    =       num_hidden_layers
							_UpperCamelCase :		str			    =       num_attention_heads
							_UpperCamelCase :		Any			    =       hidden_act
							_UpperCamelCase :		Dict			    =       intermediate_size
							_UpperCamelCase :		Optional[int]			    =       hidden_dropout_prob
							_UpperCamelCase :		Any			    =       attention_probs_dropout_prob
							_UpperCamelCase :		List[Any]			    =       max_position_embeddings
							_UpperCamelCase :		str			    =       type_vocab_size
							_UpperCamelCase :		Optional[Any]			    =       initializer_range
							_UpperCamelCase :		Optional[int]			    =       layer_norm_eps
							_UpperCamelCase :		Optional[int]			    =       position_embedding_type
							_UpperCamelCase :		Optional[Any]			    =       use_cache
							_UpperCamelCase :		Optional[Any]			    =       classifier_dropout






class 							lowercase__     (							lowercase       ):





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







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


