



'''simple docstring'''
import unittest

from transformers import XLMConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    XLMForMultipleChoice,
					    XLMForQuestionAnswering,
					    XLMForQuestionAnsweringSimple,
					    XLMForSequenceClassification,
					    XLMForTokenClassification,
					    XLMModel,
					    XLMWithLMHeadModel,
					)
					from transformers.models.xlm.modeling_xlm import XLM_PRETRAINED_MODEL_ARCHIVE_LIST






class 							lowercase__     :





	def __init__(			self :    Optional[int]			,lowerCamelCase__ :    List[str]			,lowerCamelCase__ :    Tuple=13			,lowerCamelCase__ :    Tuple=7			,lowerCamelCase__ :    List[str]=True			,lowerCamelCase__ :    Optional[int]=True			,lowerCamelCase__ :    Dict=True			,lowerCamelCase__ :    Optional[int]=True			,lowerCamelCase__ :    List[str]=True			,lowerCamelCase__ :    Tuple=False			,lowerCamelCase__ :    str=False			,lowerCamelCase__ :    Tuple=False			,lowerCamelCase__ :    List[str]=2			,lowerCamelCase__ :    List[str]=99			,lowerCamelCase__ :    Dict=0			,lowerCamelCase__ :    Union[str, Any]=32			,lowerCamelCase__ :    str=5			,lowerCamelCase__ :    Union[str, Any]=4			,lowerCamelCase__ :    Union[str, Any]=0.1			,lowerCamelCase__ :    Optional[Any]=0.1			,lowerCamelCase__ :    Union[str, Any]=512			,lowerCamelCase__ :    Optional[int]=2			,lowerCamelCase__ :    int=0.0_2			,lowerCamelCase__ :    Optional[Any]=2			,lowerCamelCase__ :    List[Any]=4			,lowerCamelCase__ :    List[Any]="last"			,lowerCamelCase__ :    Optional[Any]=True			,lowerCamelCase__ :    Any=None			,lowerCamelCase__ :    str=0			,):







							'''simple docstring'''
							_UpperCamelCase :		Union[str, Any]			    =       parent
							_UpperCamelCase :		Dict			    =       batch_size
							_UpperCamelCase :		str			    =       seq_length
							_UpperCamelCase :		Optional[Any]			    =       is_training
							_UpperCamelCase :		Dict			    =       use_input_lengths
							_UpperCamelCase :		str			    =       use_token_type_ids
							_UpperCamelCase :		str			    =       use_labels
							_UpperCamelCase :		int			    =       gelu_activation
							_UpperCamelCase :		Tuple			    =       sinusoidal_embeddings
							_UpperCamelCase :		List[str]			    =       causal
							_UpperCamelCase :		str			    =       asm
							_UpperCamelCase :		Tuple			    =       n_langs
							_UpperCamelCase :		str			    =       vocab_size
							_UpperCamelCase :		Any			    =       n_special
							_UpperCamelCase :		Tuple			    =       hidden_size
							_UpperCamelCase :		Tuple			    =       num_hidden_layers
							_UpperCamelCase :		Dict			    =       num_attention_heads
							_UpperCamelCase :		List[str]			    =       hidden_dropout_prob
							_UpperCamelCase :		Optional[int]			    =       attention_probs_dropout_prob
							_UpperCamelCase :		List[str]			    =       max_position_embeddings
							_UpperCamelCase :		Dict			    =       type_sequence_label_size
							_UpperCamelCase :		Optional[Any]			    =       initializer_range
							_UpperCamelCase :		str			    =       num_labels
							_UpperCamelCase :		Optional[int]			    =       num_choices
							_UpperCamelCase :		int			    =       summary_type
							_UpperCamelCase :		str			    =       use_proj
							_UpperCamelCase :		Tuple			    =       scope
							_UpperCamelCase :		int			    =       bos_token_id





	def      UpperCamelCase_  (			self :    Any			):







							'''simple docstring'''
							_UpperCamelCase :		List[str]			    =       ids_tensor([self.batch_size, self.seq_length]			,self.vocab_size			)
							_UpperCamelCase :		Tuple			    =       random_attention_mask([self.batch_size, self.seq_length]			)

							_UpperCamelCase :		Union[str, Any]			    =       None
							if self.use_input_lengths:
													_UpperCamelCase :		int			    =       (
													    ids_tensor([self.batch_size]			,vocab_size=2			) + self.seq_length - 2
													)  # small variation of seq_length

							_UpperCamelCase :		Optional[Any]			    =       None
							if self.use_token_type_ids:
													_UpperCamelCase :		Union[str, Any]			    =       ids_tensor([self.batch_size, self.seq_length]			,self.n_langs			)

							_UpperCamelCase :		str			    =       None
							_UpperCamelCase :		int			    =       None
							_UpperCamelCase :		str			    =       None
							if self.use_labels:
													_UpperCamelCase :		List[str]			    =       ids_tensor([self.batch_size]			,self.type_sequence_label_size			)
													_UpperCamelCase :		Any			    =       ids_tensor([self.batch_size, self.seq_length]			,self.num_labels			)
													_UpperCamelCase :		Optional[int]			    =       ids_tensor([self.batch_size]			,2			).float()
													_UpperCamelCase :		Dict			    =       ids_tensor([self.batch_size]			,self.num_choices			)

							_UpperCamelCase :		str			    =       self.get_config()

							return (
							    config,
							    input_ids,
							    token_type_ids,
							    input_lengths,
							    sequence_labels,
							    token_labels,
							    is_impossible_labels,
							    choice_labels,
							    input_mask,
							)





	def      UpperCamelCase_  (			self :    int			):







							'''simple docstring'''
							return XLMConfig(
							    vocab_size=self.vocab_size			,n_special=self.n_special			,emb_dim=self.hidden_size			,n_layers=self.num_hidden_layers			,n_heads=self.num_attention_heads			,dropout=self.hidden_dropout_prob			,attention_dropout=self.attention_probs_dropout_prob			,gelu_activation=self.gelu_activation			,sinusoidal_embeddings=self.sinusoidal_embeddings			,asm=self.asm			,causal=self.causal			,n_langs=self.n_langs			,max_position_embeddings=self.max_position_embeddings			,initializer_range=self.initializer_range			,summary_type=self.summary_type			,use_proj=self.use_proj			,num_labels=self.num_labels			,bos_token_id=self.bos_token_id			,)





	def      UpperCamelCase_  (			self :    Optional[int]			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    List[str]			,lowerCamelCase__ :    List[str]			,lowerCamelCase__ :    Any			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    Tuple			,):







							'''simple docstring'''
							_UpperCamelCase :		Optional[int]			    =       XLMModel(config=lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()
							_UpperCamelCase :		List[str]			    =       model(lowerCamelCase__			,lengths=lowerCamelCase__			,langs=lowerCamelCase__			)
							_UpperCamelCase :		int			    =       model(lowerCamelCase__			,langs=lowerCamelCase__			)
							_UpperCamelCase :		List[Any]			    =       model(lowerCamelCase__			)
							self.parent.assertEqual(result.last_hidden_state.shape			,(self.batch_size, self.seq_length, self.hidden_size)			)





	def      UpperCamelCase_  (			self :    Union[str, Any]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    str			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Optional[Any]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Any			,lowerCamelCase__ :    Dict			,):







							'''simple docstring'''
							_UpperCamelCase :		Dict			    =       XLMWithLMHeadModel(lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()

							_UpperCamelCase :		Union[str, Any]			    =       model(lowerCamelCase__			,token_type_ids=lowerCamelCase__			,labels=lowerCamelCase__			)
							self.parent.assertEqual(result.loss.shape			,()			)
							self.parent.assertEqual(result.logits.shape			,(self.batch_size, self.seq_length, self.vocab_size)			)





	def      UpperCamelCase_  (			self :    List[Any]			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    List[str]			,):







							'''simple docstring'''
							_UpperCamelCase :		Tuple			    =       XLMForQuestionAnsweringSimple(lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()

							_UpperCamelCase :		str			    =       model(lowerCamelCase__			)

							_UpperCamelCase :		Optional[Any]			    =       model(lowerCamelCase__			,start_positions=lowerCamelCase__			,end_positions=lowerCamelCase__			)
							_UpperCamelCase :		Any			    =       outputs
							self.parent.assertEqual(result.start_logits.shape			,(self.batch_size, self.seq_length)			)
							self.parent.assertEqual(result.end_logits.shape			,(self.batch_size, self.seq_length)			)





	def      UpperCamelCase_  (			self :    List[str]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    Any			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Optional[int]			,):







							'''simple docstring'''
							_UpperCamelCase :		Optional[int]			    =       XLMForQuestionAnswering(lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()

							_UpperCamelCase :		Tuple			    =       model(lowerCamelCase__			)

							_UpperCamelCase :		Optional[Any]			    =       model(
							    lowerCamelCase__			,start_positions=lowerCamelCase__			,end_positions=lowerCamelCase__			,cls_index=lowerCamelCase__			,is_impossible=lowerCamelCase__			,p_mask=lowerCamelCase__			,)

							_UpperCamelCase :		List[str]			    =       model(
							    lowerCamelCase__			,start_positions=lowerCamelCase__			,end_positions=lowerCamelCase__			,cls_index=lowerCamelCase__			,is_impossible=lowerCamelCase__			,)

							((_UpperCamelCase)    ,      ) :		int			    =       result_with_labels.to_tuple()

							_UpperCamelCase :		Optional[Any]			    =       model(lowerCamelCase__			,start_positions=lowerCamelCase__			,end_positions=lowerCamelCase__			)

							((_UpperCamelCase)    ,      ) :		Tuple			    =       result_with_labels.to_tuple()

							self.parent.assertEqual(result_with_labels.loss.shape			,()			)
							self.parent.assertEqual(result.start_top_log_probs.shape			,(self.batch_size, model.config.start_n_top)			)
							self.parent.assertEqual(result.start_top_index.shape			,(self.batch_size, model.config.start_n_top)			)
							self.parent.assertEqual(
							    result.end_top_log_probs.shape			,(self.batch_size, model.config.start_n_top * model.config.end_n_top)			)
							self.parent.assertEqual(
							    result.end_top_index.shape			,(self.batch_size, model.config.start_n_top * model.config.end_n_top)			)
							self.parent.assertEqual(result.cls_logits.shape			,(self.batch_size,)			)





	def      UpperCamelCase_  (			self :    int			,lowerCamelCase__ :    Optional[Any]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    str			,lowerCamelCase__ :    int			,):







							'''simple docstring'''
							_UpperCamelCase :		Union[str, Any]			    =       XLMForSequenceClassification(lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()

							_UpperCamelCase :		Optional[Any]			    =       model(lowerCamelCase__			)
							_UpperCamelCase :		Any			    =       model(lowerCamelCase__			,labels=lowerCamelCase__			)
							self.parent.assertEqual(result.loss.shape			,()			)
							self.parent.assertEqual(result.logits.shape			,(self.batch_size, self.type_sequence_label_size)			)





	def      UpperCamelCase_  (			self :    Union[str, Any]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Any			,lowerCamelCase__ :    Any			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    Dict			,):







							'''simple docstring'''
							_UpperCamelCase :		Optional[int]			    =       self.num_labels
							_UpperCamelCase :		Dict			    =       XLMForTokenClassification(lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()

							_UpperCamelCase :		Any			    =       model(lowerCamelCase__			,attention_mask=lowerCamelCase__			,labels=lowerCamelCase__			)
							self.parent.assertEqual(result.logits.shape			,(self.batch_size, self.seq_length, self.num_labels)			)





	def      UpperCamelCase_  (			self :    Dict			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    str			,lowerCamelCase__ :    str			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    str			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Tuple			,):







							'''simple docstring'''
							_UpperCamelCase :		Union[str, Any]			    =       self.num_choices
							_UpperCamelCase :		Tuple			    =       XLMForMultipleChoice(config=lowerCamelCase__			)
							model.to(lowerCamelCase__			)
							model.eval()
							_UpperCamelCase :		Optional[int]			    =       input_ids.unsqueeze(1			).expand(-1			,self.num_choices			,-1			).contiguous()
							_UpperCamelCase :		Optional[Any]			    =       token_type_ids.unsqueeze(1			).expand(-1			,self.num_choices			,-1			).contiguous()
							_UpperCamelCase :		Dict			    =       input_mask.unsqueeze(1			).expand(-1			,self.num_choices			,-1			).contiguous()
							_UpperCamelCase :		Dict			    =       model(
							    lowerCamelCase__			,attention_mask=lowerCamelCase__			,token_type_ids=lowerCamelCase__			,labels=lowerCamelCase__			,)
							self.parent.assertEqual(result.logits.shape			,(self.batch_size, self.num_choices)			)





	def      UpperCamelCase_  (			self :    Dict			):







							'''simple docstring'''
							_UpperCamelCase :		List[str]			    =       self.prepare_config_and_inputs()
							(
							    (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      (
							    _UpperCamelCase
							)    ,      
							) :		Dict			    =       config_and_inputs
							_UpperCamelCase :		Optional[int]			    =       {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'lengths': input_lengths}
							return config, inputs_dict






@require_torch
class 							lowercase__     (							lowercase						, lowercase						, lowercase						, unittest.TestCase       ):
	lowercase__      =      (
	    (
	        XLMModel,
	        XLMWithLMHeadModel,
	        XLMForQuestionAnswering,
	        XLMForSequenceClassification,
	        XLMForQuestionAnsweringSimple,
	        XLMForTokenClassification,
	        XLMForMultipleChoice,
	    )
	    if is_torch_available()
	    else ()
	)
	lowercase__      =      (
	    (XLMWithLMHeadModel,) if is_torch_available() else ()
	)  # TODO (PVP): Check other models whether language generation is also applicable
	lowercase__      =      (
	    {
	        """feature-extraction""": XLMModel,
	        """fill-mask""": XLMWithLMHeadModel,
	        """question-answering""": XLMForQuestionAnsweringSimple,
	        """text-classification""": XLMForSequenceClassification,
	        """text-generation""": XLMWithLMHeadModel,
	        """token-classification""": XLMForTokenClassification,
	        """zero-shot""": XLMForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)





	def      UpperCamelCase_  (			self :    Dict			,lowerCamelCase__ :    str			,lowerCamelCase__ :    str			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Dict			):







							'''simple docstring'''
							if (
							    pipeline_test_casse_name == "QAPipelineTests"
							    and tokenizer_name is not None
							    and not tokenizer_name.endswith('Fast'			)
							):
													# `QAPipelineTests` fails for a few models when the slower tokenizer are used.
													# (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
													# TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
													return True

							return False





	def      UpperCamelCase_  (			self :    str			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    Optional[Any]			,lowerCamelCase__ :    Dict=False			):







							'''simple docstring'''
							_UpperCamelCase :		Dict			    =       super()._prepare_for_class(lowerCamelCase__			,lowerCamelCase__			,return_labels=lowerCamelCase__			)

							if return_labels:
													if model_class.__name__ == "XLMForQuestionAnswering":
																			_UpperCamelCase :		Tuple			    =       torch.zeros(
																			    self.model_tester.batch_size			,dtype=torch.long			,device=lowerCamelCase__			)
																			_UpperCamelCase :		List[Any]			    =       torch.zeros(
																			    self.model_tester.batch_size			,dtype=torch.long			,device=lowerCamelCase__			)

							return inputs_dict





	def      UpperCamelCase_  (			self :    str			):







							'''simple docstring'''
							_UpperCamelCase :		Dict			    =       XLMModelTester(self			)
							_UpperCamelCase :		Dict			    =       ConfigTester(self			,config_class=lowerCamelCase__			,emb_dim=37			)





	def      UpperCamelCase_  (			self :    Dict			):







							'''simple docstring'''
							self.config_tester.run_common_tests()





	def      UpperCamelCase_  (			self :    List[str]			):







							'''simple docstring'''
							_UpperCamelCase :		Union[str, Any]			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_model(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    int			):







							'''simple docstring'''
							_UpperCamelCase :		str			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_lm_head(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    Tuple			):







							'''simple docstring'''
							_UpperCamelCase :		Dict			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_simple_qa(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    Optional[Any]			):







							'''simple docstring'''
							_UpperCamelCase :		Optional[int]			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_qa(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    int			):







							'''simple docstring'''
							_UpperCamelCase :		str			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_sequence_classif(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    List[str]			):







							'''simple docstring'''
							_UpperCamelCase :		Any			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_token_classif(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    int			):







							'''simple docstring'''
							_UpperCamelCase :		Tuple			    =       self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_xlm_for_multiple_choice(*lowerCamelCase__			)





	def      UpperCamelCase_  (			self :    str			,lowerCamelCase__ :    List[str]			,lowerCamelCase__ :    Optional[int]			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    int			,lowerCamelCase__ :    Tuple			,lowerCamelCase__ :    Union[str, Any]=False			,lowerCamelCase__ :    Optional[Any]=1			):







							'''simple docstring'''
							self.assertIsInstance(lowerCamelCase__			,lowerCamelCase__			)
							self.assertListEqual(
							    [isinstance(lowerCamelCase__			,lowerCamelCase__			) for iter_attentions in attentions]			,[True] * len(lowerCamelCase__			)			)
							self.assertEqual(len(lowerCamelCase__			)			,(max_length - min_length) * num_beam_groups			)

							for idx, iter_attentions in enumerate(lowerCamelCase__			):
													# adds PAD dummy token
													_UpperCamelCase :		Any			    =       min_length + idx + 1
													_UpperCamelCase :		int			    =       min_length + idx + 1

													_UpperCamelCase :		Dict			    =       (
													    batch_size * num_beam_groups,
													    config.num_attention_heads,
													    tgt_len,
													    src_len,
													)
													# check attn size
													self.assertListEqual(
													    [layer_attention.shape for layer_attention in iter_attentions]			,[expected_shape] * len(lowerCamelCase__			)			)





	def      UpperCamelCase_  (			self :    Optional[Any]			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    List[str]			,lowerCamelCase__ :    Union[str, Any]			,lowerCamelCase__ :    List[Any]			,lowerCamelCase__ :    Dict			,lowerCamelCase__ :    Optional[Any]=False			,lowerCamelCase__ :    List[str]=1			):







							'''simple docstring'''
							self.assertIsInstance(lowerCamelCase__			,lowerCamelCase__			)
							self.assertListEqual(
							    [isinstance(lowerCamelCase__			,lowerCamelCase__			) for iter_hidden_states in hidden_states]			,[True] * len(lowerCamelCase__			)			,)
							self.assertEqual(len(lowerCamelCase__			)			,(max_length - min_length) * num_beam_groups			)

							for idx, iter_hidden_states in enumerate(lowerCamelCase__			):
													# adds PAD dummy token
													_UpperCamelCase :		Union[str, Any]			    =       min_length + idx + 1
													_UpperCamelCase :		List[Any]			    =       (batch_size * num_beam_groups, seq_len, config.hidden_size)
													# check hidden size
													self.assertListEqual(
													    [layer_hidden_states.shape for layer_hidden_states in iter_hidden_states]			,[expected_shape] * len(lowerCamelCase__			)			,)
							pass





	@slow
	def      UpperCamelCase_  (			self :    Any			):







							'''simple docstring'''
							for model_name in XLM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													_UpperCamelCase :		Union[str, Any]			    =       XLMModel.from_pretrained(lowerCamelCase__			)
													self.assertIsNotNone(lowerCamelCase__			)






@require_torch
class 							lowercase__     (							unittest.TestCase       ):





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







							'''simple docstring'''
							_UpperCamelCase :		Optional[Any]			    =       XLMWithLMHeadModel.from_pretrained('xlm-mlm-en-2048'			)
							model.to(lowerCamelCase__			)
							_UpperCamelCase :		Union[str, Any]			    =       torch.tensor([[14, 447]]			,dtype=torch.long			,device=lowerCamelCase__			)  # the president
							_UpperCamelCase :		List[Any]			    =       [
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							    14,
							    447,
							]  # the president the president the president the president the president the president the president the president the president the president
							# TODO(PVP): this and other input_ids I tried for generation give pretty bad results. Not sure why. Model might just not be made for auto-regressive inference
							_UpperCamelCase :		Any			    =       model.generate(lowerCamelCase__			,do_sample=lowerCamelCase__			)
							self.assertListEqual(output_ids[0].cpu().numpy().tolist()			,lowerCamelCase__			)







'''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),
							    ]			)


