




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  __magic_name__						:
				'''simple docstring'''







				def __init__(							self:   int		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Union[str, Any]=13		,					_lowerCamelCase:   Dict=7		,					_lowerCamelCase:   Union[str, Any]=True		,					_lowerCamelCase:   Optional[Any]=True		,					_lowerCamelCase:   str=True		,					_lowerCamelCase:   List[Any]=True		,					_lowerCamelCase:   List[Any]=True		,					_lowerCamelCase:   List[str]=False		,					_lowerCamelCase:   Dict=False		,					_lowerCamelCase:   Tuple=False		,					_lowerCamelCase:   List[Any]=2		,					_lowerCamelCase:   List[Any]=99		,					_lowerCamelCase:   Optional[int]=0		,					_lowerCamelCase:   Union[str, Any]=32		,					_lowerCamelCase:   Optional[Any]=5		,					_lowerCamelCase:   str=4		,					_lowerCamelCase:   str=0.1		,					_lowerCamelCase:   Optional[int]=0.1		,					_lowerCamelCase:   List[Any]=5_12		,					_lowerCamelCase:   List[Any]=2		,					_lowerCamelCase:   Union[str, Any]=0.02		,					_lowerCamelCase:   str=2		,					_lowerCamelCase:   str=4		,					_lowerCamelCase:   Any="last"		,					_lowerCamelCase:   Optional[int]=True		,					_lowerCamelCase:   List[Any]=None		,					_lowerCamelCase:   Union[str, Any]=0		,					):
											SCREAMING_SNAKE_CASE_   	=    parent
											SCREAMING_SNAKE_CASE_   	=    batch_size
											SCREAMING_SNAKE_CASE_   	=    seq_length
											SCREAMING_SNAKE_CASE_   	=    is_training
											SCREAMING_SNAKE_CASE_   	=    use_input_lengths
											SCREAMING_SNAKE_CASE_   	=    use_token_type_ids
											SCREAMING_SNAKE_CASE_   	=    use_labels
											SCREAMING_SNAKE_CASE_   	=    gelu_activation
											SCREAMING_SNAKE_CASE_   	=    sinusoidal_embeddings
											SCREAMING_SNAKE_CASE_   	=    causal
											SCREAMING_SNAKE_CASE_   	=    asm
											SCREAMING_SNAKE_CASE_   	=    n_langs
											SCREAMING_SNAKE_CASE_   	=    vocab_size
											SCREAMING_SNAKE_CASE_   	=    n_special
											SCREAMING_SNAKE_CASE_   	=    hidden_size
											SCREAMING_SNAKE_CASE_   	=    num_hidden_layers
											SCREAMING_SNAKE_CASE_   	=    num_attention_heads
											SCREAMING_SNAKE_CASE_   	=    hidden_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE_   	=    max_position_embeddings
											SCREAMING_SNAKE_CASE_   	=    type_sequence_label_size
											SCREAMING_SNAKE_CASE_   	=    initializer_range
											SCREAMING_SNAKE_CASE_   	=    num_labels
											SCREAMING_SNAKE_CASE_   	=    num_choices
											SCREAMING_SNAKE_CASE_   	=    summary_type
											SCREAMING_SNAKE_CASE_   	=    use_proj
											SCREAMING_SNAKE_CASE_   	=    scope
											SCREAMING_SNAKE_CASE_   	=    bos_token_id


				def     _A							(							self:   Tuple		):
											SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size, self.seq_length]		,					self.vocab_size		)
											SCREAMING_SNAKE_CASE_   	=    random_attention_mask([self.batch_size, self.seq_length]		)

											SCREAMING_SNAKE_CASE_   	=    None
											if self.use_input_lengths:
																		SCREAMING_SNAKE_CASE_   	=    (
																		    ids_tensor([self.batch_size]		,					vocab_size=2		) + self.seq_length - 2
																		)  # small variation of seq_length

											SCREAMING_SNAKE_CASE_   	=    None
											if self.use_token_type_ids:
																		SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size, self.seq_length]		,					self.n_langs		)

											SCREAMING_SNAKE_CASE_   	=    None
											SCREAMING_SNAKE_CASE_   	=    None
											SCREAMING_SNAKE_CASE_   	=    None
											if self.use_labels:
																		SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size]		,					self.type_sequence_label_size		)
																		SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size, self.seq_length]		,					self.num_labels		)
																		SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size]		,					2		).float()
																		SCREAMING_SNAKE_CASE_   	=    ids_tensor([self.batch_size]		,					self.num_choices		)

											SCREAMING_SNAKE_CASE_   	=    self.get_config()

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


				def     _A							(							self:   Any		):
											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     _A							(							self:   List[str]		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   str		,					_lowerCamelCase:   str		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   Any		,					_lowerCamelCase:   Any		,					):
											SCREAMING_SNAKE_CASE_   	=    XLMModel(config=_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()
											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		,					lengths=_lowerCamelCase		,					langs=_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		,					langs=_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		)
											self.parent.assertEqual(result.last_hidden_state.shape		,					(self.batch_size, self.seq_length, self.hidden_size)		)


				def     _A							(							self:   int		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   int		,					):
											SCREAMING_SNAKE_CASE_   	=    XLMWithLMHeadModel(_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()

											SCREAMING_SNAKE_CASE_   	=    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     _A							(							self:   List[Any]		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Dict		,					_lowerCamelCase:   int		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   List[Any]		,					):
											SCREAMING_SNAKE_CASE_   	=    XLMForQuestionAnsweringSimple(_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		)

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		,					start_positions=_lowerCamelCase		,					end_positions=_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    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     _A							(							self:   Dict		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   List[Any]		,					):
											SCREAMING_SNAKE_CASE_   	=    XLMForQuestionAnswering(_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		)

											SCREAMING_SNAKE_CASE_   	=    model(
											    _lowerCamelCase		,					start_positions=_lowerCamelCase		,					end_positions=_lowerCamelCase		,					cls_index=_lowerCamelCase		,					is_impossible=_lowerCamelCase		,					p_mask=_lowerCamelCase		,					)

											SCREAMING_SNAKE_CASE_   	=    model(
											    _lowerCamelCase		,					start_positions=_lowerCamelCase		,					end_positions=_lowerCamelCase		,					cls_index=_lowerCamelCase		,					is_impossible=_lowerCamelCase		,					)

											((SCREAMING_SNAKE_CASE_	)	,		)   	=    result_with_labels.to_tuple()

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		,					start_positions=_lowerCamelCase		,					end_positions=_lowerCamelCase		)

											((SCREAMING_SNAKE_CASE_	)	,		)   	=    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     _A							(							self:   Any		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   Any		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   Tuple		,					):
											SCREAMING_SNAKE_CASE_   	=    XLMForSequenceClassification(_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    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     _A							(							self:   str		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   Any		,					_lowerCamelCase:   Any		,					_lowerCamelCase:   str		,					_lowerCamelCase:   int		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   Union[str, Any]		,					):
											SCREAMING_SNAKE_CASE_   	=    self.num_labels
											SCREAMING_SNAKE_CASE_   	=    XLMForTokenClassification(_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()

											SCREAMING_SNAKE_CASE_   	=    model(_lowerCamelCase		,					attention_mask=_lowerCamelCase		,					labels=_lowerCamelCase		)
											self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.seq_length, self.num_labels)		)


				def     _A							(							self:   List[Any]		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Any		,					_lowerCamelCase:   str		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   List[Any]		,					):
											SCREAMING_SNAKE_CASE_   	=    self.num_choices
											SCREAMING_SNAKE_CASE_   	=    XLMForMultipleChoice(config=_lowerCamelCase		)
											model.to(_lowerCamelCase		)
											model.eval()
											SCREAMING_SNAKE_CASE_   	=    input_ids.unsqueeze(1		).expand(-1		,					self.num_choices		,					-1		).contiguous()
											SCREAMING_SNAKE_CASE_   	=    token_type_ids.unsqueeze(1		).expand(-1		,					self.num_choices		,					-1		).contiguous()
											SCREAMING_SNAKE_CASE_   	=    input_mask.unsqueeze(1		).expand(-1		,					self.num_choices		,					-1		).contiguous()
											SCREAMING_SNAKE_CASE_   	=    model(
											    _lowerCamelCase		,					attention_mask=_lowerCamelCase		,					token_type_ids=_lowerCamelCase		,					labels=_lowerCamelCase		,					)
											self.parent.assertEqual(result.logits.shape		,					(self.batch_size, self.num_choices)		)





				def     _A							(							self:   Optional[int]		):
											SCREAMING_SNAKE_CASE_   	=    self.prepare_config_and_inputs()
											(
											    (
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,	(
											    SCREAMING_SNAKE_CASE_	
											)	,		
											)   	=    config_and_inputs
											SCREAMING_SNAKE_CASE_   	=    {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''lengths''': input_lengths}
											return config, inputs_dict






@require_torch
class  __magic_name__						(  __UpperCAmelCase    ,  __UpperCAmelCase    ,  __UpperCAmelCase    ,  unittest.TestCase):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							List[str]	      =					(
				    (
				        XLMModel,
				        XLMWithLMHeadModel,
				        XLMForQuestionAnswering,
				        XLMForSequenceClassification,
				        XLMForQuestionAnsweringSimple,
				        XLMForTokenClassification,
				        XLMForMultipleChoice,
				    )
				    if is_torch_available()
				    else ()
				)
				SCREAMING_SNAKE_CASE__					:							List[Any]	      =					(
				    (XLMWithLMHeadModel,) if is_torch_available() else ()
				)  # TODO (PVP): Check other models whether language generation is also applicable
				SCREAMING_SNAKE_CASE__					:							str	      =					(
				    {
				        "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     _A							(							self:   Dict		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   str		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   List[Any]		,					_lowerCamelCase:   str		):
											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     _A							(							self:   Tuple		,					_lowerCamelCase:   List[str]		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   int=False		):
											SCREAMING_SNAKE_CASE_   	=    super()._prepare_for_class(_lowerCamelCase		,					_lowerCamelCase		,					return_labels=_lowerCamelCase		)

											if return_labels:
																		if model_class.__name__ == "XLMForQuestionAnswering":
																									SCREAMING_SNAKE_CASE_   	=    torch.zeros(
																									    self.model_tester.batch_size		,					dtype=torch.long		,					device=_lowerCamelCase		)
																									SCREAMING_SNAKE_CASE_   	=    torch.zeros(
																									    self.model_tester.batch_size		,					dtype=torch.long		,					device=_lowerCamelCase		)

											return inputs_dict


				def     _A							(							self:   Any		):
											SCREAMING_SNAKE_CASE_   	=    XLMModelTester(self		)
											SCREAMING_SNAKE_CASE_   	=    ConfigTester(self		,					config_class=_lowerCamelCase		,					emb_dim=37		)


				def     _A							(							self:   Tuple		):
											self.config_tester.run_common_tests()


				def     _A							(							self:   List[str]		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_model(*_lowerCamelCase		)


				def     _A							(							self:   Union[str, Any]		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_lm_head(*_lowerCamelCase		)


				def     _A							(							self:   str		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_simple_qa(*_lowerCamelCase		)


				def     _A							(							self:   Optional[int]		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_qa(*_lowerCamelCase		)


				def     _A							(							self:   List[Any]		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_sequence_classif(*_lowerCamelCase		)


				def     _A							(							self:   Dict		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_token_classif(*_lowerCamelCase		)


				def     _A							(							self:   Optional[Any]		):
											SCREAMING_SNAKE_CASE_   	=    self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_xlm_for_multiple_choice(*_lowerCamelCase		)


				def     _A							(							self:   Any		,					_lowerCamelCase:   Optional[Any]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   Tuple		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   str=False		,					_lowerCamelCase:   List[Any]=1		):
											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
																		SCREAMING_SNAKE_CASE_   	=    min_length + idx + 1
																		SCREAMING_SNAKE_CASE_   	=    min_length + idx + 1

																		SCREAMING_SNAKE_CASE_   	=    (
																		    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     _A							(							self:   List[Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   Union[str, Any]		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   int		,					_lowerCamelCase:   Union[str, Any]=False		,					_lowerCamelCase:   Optional[int]=1		):
											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
																		SCREAMING_SNAKE_CASE_   	=    min_length + idx + 1
																		SCREAMING_SNAKE_CASE_   	=    (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     _A							(							self:   List[str]		):
											for model_name in XLM_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		SCREAMING_SNAKE_CASE_   	=    XLMModel.from_pretrained(_lowerCamelCase		)
																		self.assertIsNotNone(_lowerCamelCase		)






@require_torch
class  __magic_name__						(  unittest.TestCase):
				'''simple docstring'''







				@slow
				def     _A							(							self:   str		):
											SCREAMING_SNAKE_CASE_   	=    XLMWithLMHeadModel.from_pretrained('''xlm-mlm-en-2048'''		)
											model.to(_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    torch.tensor([[14, 4_47]]		,					dtype=torch.long		,					device=_lowerCamelCase		)  # the president
											SCREAMING_SNAKE_CASE_   	=    [
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											    14,
											    4_47,
											]  # 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
											SCREAMING_SNAKE_CASE_   	=    model.generate(_lowerCamelCase		,					do_sample=_lowerCamelCase		)
											self.assertListEqual(output_ids[0].cpu().numpy().tolist()		,					_lowerCamelCase		)






def 			a   (_lowerCAmelCase     ):
							if number > 0:
														raise ValueError('''input must be a negative integer'''     )
							SCREAMING_SNAKE_CASE_   	=    len(bin(_lowerCAmelCase     )[3:]     )
							SCREAMING_SNAKE_CASE_   	=    bin(abs(_lowerCAmelCase     ) - (1 << binary_number_length)     )[3:]
							SCREAMING_SNAKE_CASE_   	=    (
							    (
							        '''1'''
							        + '''0''' * (binary_number_length - len(_lowerCAmelCase     ))
							        + twos_complement_number
							    )
							    if number < 0
							    else '''0'''
							)
							return "0b" + twos_complement_number


if __name__ == "__main__":
			import doctest

			doctest.testmod()


