

"""simple docstring"""





import unittest

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

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import (
							    RemBertConfig,
							    RemBertForCausalLM,
							    RemBertForMaskedLM,
							    RemBertForMultipleChoice,
							    RemBertForQuestionAnswering,
							    RemBertForSequenceClassification,
							    RemBertForTokenClassification,
							    RemBertModel,
							)
							from transformers.models.rembert.modeling_rembert import REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST







class        SCREAMING_SNAKE_CASE      :






					"""simple docstring"""



					def __init__( self    :       Union[str, Any]     ,lowercase_    :       Any     ,lowercase_    :       Optional[Any]=1_3     ,lowercase_    :       str=7     ,lowercase_    :       Optional[Any]=True     ,lowercase_    :       Any=True     ,lowercase_    :       Tuple=True     ,lowercase_    :       Tuple=True     ,lowercase_    :       Union[str, Any]=9_9     ,lowercase_    :       Optional[int]=3_2     ,lowercase_    :       Tuple=1_8     ,lowercase_    :       str=4_3     ,lowercase_    :       List[str]=5     ,lowercase_    :       str=4     ,lowercase_    :       Tuple=3_7     ,lowercase_    :       List[Any]="gelu"     ,lowercase_    :       str=0.1     ,lowercase_    :       str=0.1     ,lowercase_    :       Tuple=5_1_2     ,lowercase_    :       Union[str, Any]=1_6     ,lowercase_    :       Union[str, Any]=2     ,lowercase_    :       List[Any]=0.02     ,lowercase_    :       Dict=3     ,lowercase_    :       str=4     ,lowercase_    :       Optional[Any]=None     ,):
						lowerCAmelCase__			:		Any						       =			parent
						lowerCAmelCase__			:		Union[str, Any]						       =			batch_size
						lowerCAmelCase__			:		int						       =			seq_length
						lowerCAmelCase__			:		Optional[int]						       =			is_training
						lowerCAmelCase__			:		Dict						       =			use_input_mask
						lowerCAmelCase__			:		str						       =			use_token_type_ids
						lowerCAmelCase__			:		Any						       =			use_labels
						lowerCAmelCase__			:		Optional[Any]						       =			vocab_size
						lowerCAmelCase__			:		Optional[int]						       =			hidden_size
						lowerCAmelCase__			:		Optional[Any]						       =			input_embedding_size
						lowerCAmelCase__			:		List[Any]						       =			output_embedding_size
						lowerCAmelCase__			:		Any						       =			num_hidden_layers
						lowerCAmelCase__			:		Union[str, Any]						       =			num_attention_heads
						lowerCAmelCase__			:		Union[str, Any]						       =			intermediate_size
						lowerCAmelCase__			:		str						       =			hidden_act
						lowerCAmelCase__			:		List[str]						       =			hidden_dropout_prob
						lowerCAmelCase__			:		List[Any]						       =			attention_probs_dropout_prob
						lowerCAmelCase__			:		List[str]						       =			max_position_embeddings
						lowerCAmelCase__			:		Optional[int]						       =			type_vocab_size
						lowerCAmelCase__			:		List[str]						       =			type_sequence_label_size
						lowerCAmelCase__			:		Optional[Any]						       =			initializer_range
						lowerCAmelCase__			:		Tuple						       =			num_labels
						lowerCAmelCase__			:		Optional[int]						       =			num_choices
						lowerCAmelCase__			:		Tuple						       =			scope







					def  __lowerCAmelCase				( self    :       Tuple	):
						lowerCAmelCase__			:		Union[str, Any]						       =			ids_tensor([self.batch_size, self.seq_length]     ,self.vocab_size	)

						lowerCAmelCase__			:		str						       =			None
						if self.use_input_mask:
							lowerCAmelCase__			:		Dict						       =			random_attention_mask([self.batch_size, self.seq_length]	)

						lowerCAmelCase__			:		str						       =			None
						if self.use_token_type_ids:
							lowerCAmelCase__			:		Optional[Any]						       =			ids_tensor([self.batch_size, self.seq_length]     ,self.type_vocab_size	)

						lowerCAmelCase__			:		Any						       =			None
						lowerCAmelCase__			:		Tuple						       =			None
						lowerCAmelCase__			:		Dict						       =			None
						if self.use_labels:
							lowerCAmelCase__			:		int						       =			ids_tensor([self.batch_size]     ,self.type_sequence_label_size	)
							lowerCAmelCase__			:		Tuple						       =			ids_tensor([self.batch_size, self.seq_length]     ,self.num_labels	)
							lowerCAmelCase__			:		Optional[Any]						       =			ids_tensor([self.batch_size]     ,self.num_choices	)

						lowerCAmelCase__			:		str						       =			RemBertConfig(
						    vocab_size=self.vocab_size     ,hidden_size=self.hidden_size     ,input_embedding_size=self.input_embedding_size     ,output_embedding_size=self.output_embedding_size     ,num_hidden_layers=self.num_hidden_layers     ,num_attention_heads=self.num_attention_heads     ,intermediate_size=self.intermediate_size     ,hidden_act=self.hidden_act     ,hidden_dropout_prob=self.hidden_dropout_prob     ,attention_probs_dropout_prob=self.attention_probs_dropout_prob     ,max_position_embeddings=self.max_position_embeddings     ,type_vocab_size=self.type_vocab_size     ,is_decoder=lowercase_     ,initializer_range=self.initializer_range     ,)

						return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







					def  __lowerCAmelCase				( self    :       Optional[Any]	):
						(
						    (
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,
						)			:		int						       =			self.prepare_config_and_inputs()

						lowerCAmelCase__			:		Union[str, Any]						       =			True
						lowerCAmelCase__			:		Dict						       =			floats_tensor([self.batch_size, self.seq_length, self.hidden_size]	)
						lowerCAmelCase__			:		Any						       =			ids_tensor([self.batch_size, self.seq_length]     ,vocab_size=2	)

						return (
						    config,
						    input_ids,
						    token_type_ids,
						    input_mask,
						    sequence_labels,
						    token_labels,
						    choice_labels,
						    encoder_hidden_states,
						    encoder_attention_mask,
						)







					def  __lowerCAmelCase				( self    :       str     ,lowercase_    :       Optional[Any]     ,lowercase_    :       Any     ,lowercase_    :       Tuple     ,lowercase_    :       int     ,lowercase_    :       int     ,lowercase_    :       Any     ,lowercase_    :       List[Any]	):
						lowerCAmelCase__			:		List[str]						       =			RemBertModel(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		Dict						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_	)
						lowerCAmelCase__			:		Optional[int]						       =			model(lowercase_     ,token_type_ids=lowercase_	)
						lowerCAmelCase__			:		Optional[Any]						       =			model(lowercase_	)
						self.parent.assertEqual(result.last_hidden_state.shape     ,(self.batch_size, self.seq_length, self.hidden_size)	)







					def  __lowerCAmelCase				( self    :       Tuple     ,lowercase_    :       Optional[int]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Tuple     ,lowercase_    :       Dict     ,lowercase_    :       Optional[int]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Dict     ,lowercase_    :       Optional[Any]     ,):
						lowerCAmelCase__			:		Union[str, Any]						       =			True
						lowerCAmelCase__			:		Tuple						       =			RemBertModel(lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		List[str]						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,encoder_hidden_states=lowercase_     ,encoder_attention_mask=lowercase_     ,)
						lowerCAmelCase__			:		int						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,encoder_hidden_states=lowercase_     ,)
						lowerCAmelCase__			:		Dict						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_	)
						self.parent.assertEqual(result.last_hidden_state.shape     ,(self.batch_size, self.seq_length, self.hidden_size)	)







					def  __lowerCAmelCase				( self    :       List[str]     ,lowercase_    :       List[Any]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Optional[Any]     ,lowercase_    :       str     ,lowercase_    :       Optional[int]     ,lowercase_    :       List[str]     ,lowercase_    :       Tuple     ,lowercase_    :       Optional[int]     ,lowercase_    :       str     ,):
						lowerCAmelCase__			:		Any						       =			RemBertForCausalLM(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		Dict						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,labels=lowercase_	)
						self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.seq_length, self.vocab_size)	)







					def  __lowerCAmelCase				( self    :       Union[str, Any]     ,lowercase_    :       List[str]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Dict     ,lowercase_    :       int     ,lowercase_    :       Any     ,lowercase_    :       str	):
						lowerCAmelCase__			:		List[str]						       =			RemBertForMaskedLM(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		str						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,labels=lowercase_	)
						self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.seq_length, self.vocab_size)	)







					def  __lowerCAmelCase				( self    :       Any     ,lowercase_    :       str     ,lowercase_    :       Tuple     ,lowercase_    :       Optional[Any]     ,lowercase_    :       Any     ,lowercase_    :       List[str]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Optional[int]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Optional[Any]     ,):
						lowerCAmelCase__			:		Union[str, Any]						       =			True
						lowerCAmelCase__			:		str						       =			True
						lowerCAmelCase__			:		int						       =			RemBertForCausalLM(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()

						# first forward pass
						lowerCAmelCase__			:		List[str]						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,encoder_hidden_states=lowercase_     ,encoder_attention_mask=lowercase_     ,use_cache=lowercase_     ,)
						lowerCAmelCase__			:		Dict						       =			outputs.past_key_values

						# create hypothetical multiple next token and extent to next_input_ids
						lowerCAmelCase__			:		Any						       =			ids_tensor((self.batch_size, 3)     ,config.vocab_size	)
						lowerCAmelCase__			:		Optional[int]						       =			ids_tensor((self.batch_size, 3)     ,vocab_size=2	)

						# append to next input_ids and
						lowerCAmelCase__			:		List[str]						       =			torch.cat([input_ids, next_tokens]     ,dim=-1	)
						lowerCAmelCase__			:		List[Any]						       =			torch.cat([input_mask, next_mask]     ,dim=-1	)

						lowerCAmelCase__			:		Any						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,encoder_hidden_states=lowercase_     ,encoder_attention_mask=lowercase_     ,output_hidden_states=lowercase_     ,)['''hidden_states'''][0]
						lowerCAmelCase__			:		Optional[Any]						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,encoder_hidden_states=lowercase_     ,encoder_attention_mask=lowercase_     ,past_key_values=lowercase_     ,output_hidden_states=lowercase_     ,)['''hidden_states'''][0]

						# select random slice
						lowerCAmelCase__			:		Dict						       =			ids_tensor((1,)     ,output_from_past.shape[-1]	).item()
						lowerCAmelCase__			:		List[Any]						       =			output_from_no_past[:, -3:, random_slice_idx].detach()
						lowerCAmelCase__			:		Dict						       =			output_from_past[:, :, random_slice_idx].detach()

						self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]	)

						# test that outputs are equal for slice
						self.parent.assertTrue(torch.allclose(lowercase_     ,lowercase_     ,atol=1E-3	)	)







					def  __lowerCAmelCase				( self    :       Any     ,lowercase_    :       Dict     ,lowercase_    :       str     ,lowercase_    :       Tuple     ,lowercase_    :       Optional[Any]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Optional[Any]     ,lowercase_    :       Optional[int]	):
						lowerCAmelCase__			:		Optional[int]						       =			RemBertForQuestionAnswering(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		str						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,start_positions=lowercase_     ,end_positions=lowercase_     ,)
						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  __lowerCAmelCase				( self    :       int     ,lowercase_    :       int     ,lowercase_    :       Optional[int]     ,lowercase_    :       Optional[Any]     ,lowercase_    :       List[Any]     ,lowercase_    :       List[Any]     ,lowercase_    :       List[str]     ,lowercase_    :       Union[str, Any]	):
						lowerCAmelCase__			:		Optional[Any]						       =			self.num_labels
						lowerCAmelCase__			:		Optional[int]						       =			RemBertForSequenceClassification(lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		str						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,labels=lowercase_	)
						self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.num_labels)	)







					def  __lowerCAmelCase				( self    :       int     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Any     ,lowercase_    :       List[Any]     ,lowercase_    :       Optional[Any]     ,lowercase_    :       List[str]     ,lowercase_    :       str     ,lowercase_    :       Optional[int]	):
						lowerCAmelCase__			:		Tuple						       =			self.num_labels
						lowerCAmelCase__			:		Tuple						       =			RemBertForTokenClassification(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		List[str]						       =			model(lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,labels=lowercase_	)
						self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.seq_length, self.num_labels)	)







					def  __lowerCAmelCase				( self    :       Dict     ,lowercase_    :       Optional[int]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       Union[str, Any]     ,lowercase_    :       List[str]     ,lowercase_    :       str     ,lowercase_    :       Optional[Any]     ,lowercase_    :       int	):
						lowerCAmelCase__			:		str						       =			self.num_choices
						lowerCAmelCase__			:		str						       =			RemBertForMultipleChoice(config=lowercase_	)
						model.to(lowercase_	)
						model.eval()
						lowerCAmelCase__			:		Tuple						       =			input_ids.unsqueeze(1	).expand(-1     ,self.num_choices     ,-1	).contiguous()
						lowerCAmelCase__			:		Dict						       =			token_type_ids.unsqueeze(1	).expand(-1     ,self.num_choices     ,-1	).contiguous()
						lowerCAmelCase__			:		List[str]						       =			input_mask.unsqueeze(1	).expand(-1     ,self.num_choices     ,-1	).contiguous()
						lowerCAmelCase__			:		str						       =			model(
						    lowercase_     ,attention_mask=lowercase_     ,token_type_ids=lowercase_     ,labels=lowercase_     ,)
						self.parent.assertEqual(result.logits.shape     ,(self.batch_size, self.num_choices)	)







					def  __lowerCAmelCase				( self    :       List[str]	):
						lowerCAmelCase__			:		int						       =			self.prepare_config_and_inputs()
						(
						    (
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,
						)			:		str						       =			config_and_inputs
						lowerCAmelCase__			:		Optional[Any]						       =			{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
						return config, inputs_dict







@require_torch
class        SCREAMING_SNAKE_CASE      (	a_					,							a_					,							unittest.TestCase ):






					"""simple docstring"""



					lowercase__       				= (
					    (
					        RemBertModel,
					        RemBertForMaskedLM,
					        RemBertForCausalLM,
					        RemBertForMultipleChoice,
					        RemBertForQuestionAnswering,
					        RemBertForSequenceClassification,
					        RemBertForTokenClassification,
					    )
					    if is_torch_available()
					    else ()
					)
					lowercase__       				= (RemBertForCausalLM,) if is_torch_available() else ()
					lowercase__       				= (
					    {
					        "feature-extraction": RemBertModel,
					        "fill-mask": RemBertForMaskedLM,
					        "question-answering": RemBertForQuestionAnswering,
					        "text-classification": RemBertForSequenceClassification,
					        "text-generation": RemBertForCausalLM,
					        "token-classification": RemBertForTokenClassification,
					        "zero-shot": RemBertForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)







					def  __lowerCAmelCase				( self    :       int	):
						lowerCAmelCase__			:		Dict						       =			RemBertModelTester(self	)
						lowerCAmelCase__			:		Union[str, Any]						       =			ConfigTester(self     ,config_class=lowercase_     ,hidden_size=3_7	)







					def  __lowerCAmelCase				( self    :       Dict	):
						self.config_tester.run_common_tests()







					def  __lowerCAmelCase				( self    :       Tuple	):
						lowerCAmelCase__			:		int						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Optional[Any]	):
						lowerCAmelCase__			:		str						       =			self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
							lowerCAmelCase__			:		Tuple						       =			type
							self.model_tester.create_and_check_model(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Optional[Any]	):
						lowerCAmelCase__			:		Optional[Any]						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_masked_lm(*lowercase_	)







					def  __lowerCAmelCase				( self    :       int	):
						lowerCAmelCase__			:		List[str]						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_multiple_choice(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Optional[Any]	):
						lowerCAmelCase__			:		Any						       =			self.model_tester.prepare_config_and_inputs_for_decoder()
						self.model_tester.create_and_check_decoder_model_past_large_inputs(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Dict	):
						lowerCAmelCase__			:		int						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_question_answering(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Dict	):
						lowerCAmelCase__			:		List[str]						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_sequence_classification(*lowercase_	)







					def  __lowerCAmelCase				( self    :       List[str]	):
						lowerCAmelCase__			:		str						       =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_token_classification(*lowercase_	)







					def  __lowerCAmelCase				( self    :       List[str]	):
						lowerCAmelCase__			:		str						       =			self.model_tester.prepare_config_and_inputs_for_decoder()
						self.model_tester.create_and_check_model_as_decoder(*lowercase_	)







					def  __lowerCAmelCase				( self    :       Optional[Any]	):
						# This regression test was failing with PyTorch < 1.3
						(
						    (
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,(
						    lowerCAmelCase__
						)       ,
						)			:		List[Any]						       =			self.model_tester.prepare_config_and_inputs_for_decoder()

						lowerCAmelCase__			:		int						       =			None

						self.model_tester.create_and_check_model_as_decoder(
						    lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,lowercase_     ,)







					@slow
					def  __lowerCAmelCase				( self    :       Union[str, Any]	):
						for model_name in REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							lowerCAmelCase__			:		Tuple						       =			RemBertModel.from_pretrained(lowercase_	)
							self.assertIsNotNone(lowercase_	)







@require_torch
class        SCREAMING_SNAKE_CASE      (	unittest.TestCase ):






					"""simple docstring"""



					@slow
					def  __lowerCAmelCase				( self    :       Dict	):
						# Test exact values at the last hidden layer
						lowerCAmelCase__			:		Tuple						       =			RemBertModel.from_pretrained('''google/rembert'''	)
						lowerCAmelCase__			:		Any						       =			torch.tensor([[3_1_2, 5_6_4_9_8, 3_1_3, 2_1_2_5, 3_1_3]]	)
						lowerCAmelCase__			:		Any						       =			torch.tensor([[0, 0, 0, 1, 1]]	)
						with torch.no_grad():
							lowerCAmelCase__			:		Tuple						       =			model(lowercase_     ,token_type_ids=lowercase_     ,output_hidden_states=lowercase_	)

						lowerCAmelCase__			:		Tuple						       =			1_1_5_2

						lowerCAmelCase__			:		Any						       =			torch.Size((1, 5, hidden_size)	)
						self.assertEqual(output['''last_hidden_state'''].shape     ,lowercase_	)

						lowerCAmelCase__			:		List[str]						       =			torch.tensor(
						    [
						        [
						            [0.0754, -0.2022, 0.1904],
						            [-0.3354, -0.3692, -0.4791],
						            [-0.2314, -0.6729, -0.0749],
						            [-0.0396, -0.3105, -0.4234],
						            [-0.1571, -0.0525, 0.5353],
						        ]
						    ]	)

						# Running on the original tf implementation gives slightly different results here.
						# Not clear why this variations is present
						# TODO: Find reason for discrepancy
						# expected_original_implementation = [[
						#     [0.07630594074726105, -0.20146065950393677, 0.19107051193714142],
						#     [-0.3405614495277405, -0.36971670389175415, -0.4808273911476135],
						#     [-0.22587086260318756, -0.6656315922737122, -0.07844287157058716],
						#     [-0.04145475849509239, -0.3077218234539032, -0.42316967248916626],
						#     [-0.15887849032878876, -0.054529931396245956, 0.5356100797653198]
						# ]]

						self.assertTrue(torch.allclose(output['''last_hidden_state'''][:, :, :3]     ,lowercase_     ,atol=1E-4	)	)







"""simple docstring"""





class        SCREAMING_SNAKE_CASE      :






					"""simple docstring"""



					def __init__( self    :       List[Any]	):
						lowerCAmelCase__			:		List[str]						       =			[0, 1]







					def  __lowerCAmelCase				( self    :       str     ,lowercase_    :       int	):
						if (difference := index - (len(self.sequence	) - 2)) >= 1:
							for _ in range(lowercase_	):
								self.sequence.append(self.sequence[-1] + self.sequence[-2]	)
						return self.sequence[:index]

def 						__SCREAMING_SNAKE_CASE						(   ):
	print(
	    '''Fibonacci Series Using Dynamic Programming\n'''		,  '''Enter the index of the Fibonacci number you want to calculate '''		,  '''in the prompt below. (To exit enter exit or Ctrl-C)\n'''		,  sep=''''''		,  )
	lowerCAmelCase__			:		Optional[int]						       =			Fibonacci()

	while True:
		lowerCAmelCase__			:		str						       =			input('''>> '''				)
		if prompt in {"exit", "quit"}:
			break

		try:
			lowerCAmelCase__			:		int						       =			int(A_				)
		except ValueError:
			print('''Enter a number or \'exit\''''				)
			continue

		print(fibonacci.get(A_				)				)


if __name__ == "__main__":
							main()




