
'''simple docstring'''






import unittest

from transformers import ElectraConfig, is_torch_available
from transformers.models.auto import get_values
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 (
							    MODEL_FOR_PRETRAINING_MAPPING,
							    ElectraForCausalLM,
							    ElectraForMaskedLM,
							    ElectraForMultipleChoice,
							    ElectraForPreTraining,
							    ElectraForQuestionAnswering,
							    ElectraForSequenceClassification,
							    ElectraForTokenClassification,
							    ElectraModel,
							)
							from transformers.models.electra.modeling_electra import ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST

class 							_snake_case     :
	"""simple docstring"""





	def __init__(						self				: Tuple					,						UpperCamelCase_				: str					,						UpperCamelCase_				: Tuple=13					,						UpperCamelCase_				: List[str]=7					,						UpperCamelCase_				: Dict=True					,						UpperCamelCase_				: Any=True					,						UpperCamelCase_				: Union[str, Any]=True					,						UpperCamelCase_				: Union[str, Any]=True					,						UpperCamelCase_				: str=99					,						UpperCamelCase_				: List[Any]=32					,						UpperCamelCase_				: Dict=5					,						UpperCamelCase_				: List[Any]=4					,						UpperCamelCase_				: Dict=37					,						UpperCamelCase_				: Dict="gelu"					,						UpperCamelCase_				: str=0.1					,						UpperCamelCase_				: Dict=0.1					,						UpperCamelCase_				: Union[str, Any]=512					,						UpperCamelCase_				: Any=16					,						UpperCamelCase_				: Optional[int]=2					,						UpperCamelCase_				: List[str]=0.0_2					,						UpperCamelCase_				: Tuple=3					,						UpperCamelCase_				: Optional[int]=4					,						UpperCamelCase_				: List[Any]=None					,						):
			lowerCAmelCase_   :       Union[str, Any]    							=parent
			lowerCAmelCase_   :       Dict    							=batch_size
			lowerCAmelCase_   :       str    							=seq_length
			lowerCAmelCase_   :       int    							=is_training
			lowerCAmelCase_   :       Tuple    							=use_input_mask
			lowerCAmelCase_   :       Any    							=use_token_type_ids
			lowerCAmelCase_   :       Tuple    							=use_labels
			lowerCAmelCase_   :       str    							=vocab_size
			lowerCAmelCase_   :       List[Any]    							=hidden_size
			lowerCAmelCase_   :       Any    							=num_hidden_layers
			lowerCAmelCase_   :       int    							=num_attention_heads
			lowerCAmelCase_   :       str    							=intermediate_size
			lowerCAmelCase_   :       int    							=hidden_act
			lowerCAmelCase_   :       Optional[int]    							=hidden_dropout_prob
			lowerCAmelCase_   :       int    							=attention_probs_dropout_prob
			lowerCAmelCase_   :       Any    							=max_position_embeddings
			lowerCAmelCase_   :       List[str]    							=type_vocab_size
			lowerCAmelCase_   :       Any    							=type_sequence_label_size
			lowerCAmelCase_   :       Union[str, Any]    							=initializer_range
			lowerCAmelCase_   :       Tuple    							=num_labels
			lowerCAmelCase_   :       str    							=num_choices
			lowerCAmelCase_   :       Optional[int]    							=scope




	def 	__A      (						self				: List[str]      ):
			lowerCAmelCase_   :       List[Any]    							=ids_tensor([self.batch_size, self.seq_length]					,						self.vocab_size      )

			lowerCAmelCase_   :       Optional[Any]    							=None
			if self.use_input_mask:
					lowerCAmelCase_   :       List[str]    							=random_attention_mask([self.batch_size, self.seq_length]      )

			lowerCAmelCase_   :       List[str]    							=None
			if self.use_token_type_ids:
					lowerCAmelCase_   :       List[str]    							=ids_tensor([self.batch_size, self.seq_length]					,						self.type_vocab_size      )

			lowerCAmelCase_   :       List[str]    							=None
			lowerCAmelCase_   :       Any    							=None
			lowerCAmelCase_   :       str    							=None
			if self.use_labels:
					lowerCAmelCase_   :       List[str]    							=ids_tensor([self.batch_size]					,						self.type_sequence_label_size      )
					lowerCAmelCase_   :       List[Any]    							=ids_tensor([self.batch_size, self.seq_length]					,						self.num_labels      )
					lowerCAmelCase_   :       int    							=ids_tensor([self.batch_size]					,						self.num_choices      )
					lowerCAmelCase_   :       Tuple    							=ids_tensor([self.batch_size, self.seq_length]					,						1      )

			lowerCAmelCase_   :       List[str]    							=self.get_config()

			return (
			    config,
			    input_ids,
			    token_type_ids,
			    input_mask,
			    sequence_labels,
			    token_labels,
			    choice_labels,
			    fake_token_labels,
			)




	def 	__A      (						self				: Any      ):
			return ElectraConfig(
			    vocab_size=self.vocab_size					,						hidden_size=self.hidden_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=SCREAMING_SNAKE_CASE__					,						initializer_range=self.initializer_range					,						)




	def 	__A      (						self				: Dict      ):
			(
			    (
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,									
			)   :       Any    							=self.prepare_config_and_inputs()

			lowerCAmelCase_   :       List[str]    							=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 	__A      (						self				: Optional[int]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: str					,						UpperCamelCase_				: str					,						UpperCamelCase_				: int					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: Any					,						):
			lowerCAmelCase_   :       Optional[Any]    							=ElectraModel(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Optional[int]    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__      )
			lowerCAmelCase_   :       Optional[int]    							=model(SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__      )
			lowerCAmelCase_   :       int    							=model(SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.last_hidden_state.shape					,						(self.batch_size, self.seq_length, self.hidden_size)      )




	def 	__A      (						self				: Dict					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: Dict					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: int					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Optional[int]					,						UpperCamelCase_				: Dict					,						):
			lowerCAmelCase_   :       List[Any]    							=True
			lowerCAmelCase_   :       Any    							=ElectraModel(SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Optional[int]    							=model(
			    SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						encoder_hidden_states=SCREAMING_SNAKE_CASE__					,						encoder_attention_mask=SCREAMING_SNAKE_CASE__					,						)
			lowerCAmelCase_   :       List[str]    							=model(
			    SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						encoder_hidden_states=SCREAMING_SNAKE_CASE__					,						)
			lowerCAmelCase_   :       str    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.last_hidden_state.shape					,						(self.batch_size, self.seq_length, self.hidden_size)      )




	def 	__A      (						self				: Optional[Any]					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: int					,						UpperCamelCase_				: str					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: Dict					,						UpperCamelCase_				: int					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: str					,						):
			lowerCAmelCase_   :       int    							=ElectraForMaskedLM(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Any    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.seq_length, self.vocab_size)      )




	def 	__A      (						self				: List[str]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: Optional[int]					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: Dict					,						UpperCamelCase_				: int					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: Optional[int]					,						):
			lowerCAmelCase_   :       Optional[Any]    							=ElectraForCausalLM(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Union[str, Any]    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.seq_length, self.vocab_size)      )




	def 	__A      (						self				: Dict					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: str					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Optional[int]					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: Any					,						):
			lowerCAmelCase_   :       List[Any]    							=self.num_labels
			lowerCAmelCase_   :       List[Any]    							=ElectraForTokenClassification(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Any    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.seq_length, self.num_labels)      )




	def 	__A      (						self				: str					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: Optional[int]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: int					,						UpperCamelCase_				: int					,						UpperCamelCase_				: Optional[Any]					,						):
			lowerCAmelCase_   :       Dict    							=self.num_labels
			lowerCAmelCase_   :       List[Any]    							=ElectraForPreTraining(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Tuple    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.seq_length)      )




	def 	__A      (						self				: str					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Optional[int]					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: Dict					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: List[str]					,						):
			lowerCAmelCase_   :       int    							=self.num_labels
			lowerCAmelCase_   :       Dict    							=ElectraForSequenceClassification(SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       Dict    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__      )
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.num_labels)      )




	def 	__A      (						self				: int					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: int					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Any					,						UpperCamelCase_				: Dict					,						UpperCamelCase_				: List[str]					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: str					,						):
			lowerCAmelCase_   :       str    							=ElectraForQuestionAnswering(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       int    							=model(
			    SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						start_positions=SCREAMING_SNAKE_CASE__					,						end_positions=SCREAMING_SNAKE_CASE__					,						)
			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				: Any					,						UpperCamelCase_				: Tuple					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: int					,						UpperCamelCase_				: List[Any]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: Optional[Any]					,						):
			lowerCAmelCase_   :       str    							=self.num_choices
			lowerCAmelCase_   :       Dict    							=ElectraForMultipleChoice(config=SCREAMING_SNAKE_CASE__      )
			model.to(SCREAMING_SNAKE_CASE__      )
			model.eval()
			lowerCAmelCase_   :       int    							=input_ids.unsqueeze(1      ).expand(-1					,						self.num_choices					,						-1      ).contiguous()
			lowerCAmelCase_   :       Optional[Any]    							=token_type_ids.unsqueeze(1      ).expand(-1					,						self.num_choices					,						-1      ).contiguous()
			lowerCAmelCase_   :       Optional[Any]    							=input_mask.unsqueeze(1      ).expand(-1					,						self.num_choices					,						-1      ).contiguous()
			lowerCAmelCase_   :       str    							=model(
			    SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__					,						token_type_ids=SCREAMING_SNAKE_CASE__					,						labels=SCREAMING_SNAKE_CASE__					,						)
			self.parent.assertEqual(result.logits.shape					,						(self.batch_size, self.num_choices)      )





	def 	__A      (						self				: Dict      ):
			lowerCAmelCase_   :       Any    							=self.prepare_config_and_inputs()
			(
			    (
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,		(
			    lowerCAmelCase_							
			)							,									
			)   :       Union[str, Any]    							=config_and_inputs
			lowerCAmelCase_   :       Union[str, Any]    							={'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
			return config, inputs_dict







@require_torch
class 							_snake_case     (  __a						,    __a						,    unittest.TestCase ):
	"""simple docstring"""





	_UpperCamelCase							:  str								=		(
	    (
	        ElectraModel,
	        ElectraForPreTraining,
	        ElectraForMaskedLM,
	        ElectraForCausalLM,
	        ElectraForMultipleChoice,
	        ElectraForTokenClassification,
	        ElectraForSequenceClassification,
	        ElectraForQuestionAnswering,
	    )
	    if is_torch_available()
	    else ()
	)
	_UpperCamelCase							:  List[str]								=		(
	    {
	        '''feature-extraction''': ElectraModel,
	        '''fill-mask''': ElectraForMaskedLM,
	        '''question-answering''': ElectraForQuestionAnswering,
	        '''text-classification''': ElectraForSequenceClassification,
	        '''text-generation''': ElectraForCausalLM,
	        '''token-classification''': ElectraForTokenClassification,
	        '''zero-shot''': ElectraForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)
	_UpperCamelCase							:  int								=		True




	def 	__A      (						self				: Optional[int]					,						UpperCamelCase_				: Union[str, Any]					,						UpperCamelCase_				: Optional[Any]					,						UpperCamelCase_				: str=False      ):
			lowerCAmelCase_   :       List[str]    							=super()._prepare_for_class(SCREAMING_SNAKE_CASE__					,						SCREAMING_SNAKE_CASE__					,						return_labels=SCREAMING_SNAKE_CASE__      )

			if return_labels:
					if model_class in get_values(SCREAMING_SNAKE_CASE__      ):
							lowerCAmelCase_   :       Any    							=torch.zeros(
							    (self.model_tester.batch_size, self.model_tester.seq_length)					,						dtype=torch.long					,						device=SCREAMING_SNAKE_CASE__      )
			return inputs_dict




	def 	__A      (						self				: Tuple      ):
			lowerCAmelCase_   :       str    							=ElectraModelTester(self      )
			lowerCAmelCase_   :       List[str]    							=ConfigTester(self					,						config_class=SCREAMING_SNAKE_CASE__					,						hidden_size=37      )




	def 	__A      (						self				: Any      ):
			self.config_tester.run_common_tests()




	def 	__A      (						self				: List[str]      ):
			lowerCAmelCase_   :       List[str]    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: List[Any]      ):
			lowerCAmelCase_   :       Optional[int]    							=self.model_tester.prepare_config_and_inputs_for_decoder()
			self.model_tester.create_and_check_electra_model_as_decoder(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: str      ):
			lowerCAmelCase_   :       Any    							=self.model_tester.prepare_config_and_inputs()
			for type in ["absolute", "relative_key", "relative_key_query"]:
					lowerCAmelCase_   :       Dict    							=type
					self.model_tester.create_and_check_electra_model(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: int      ):
			lowerCAmelCase_   :       Tuple    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_masked_lm(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: Optional[Any]      ):
			lowerCAmelCase_   :       List[Any]    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_token_classification(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: Any      ):
			lowerCAmelCase_   :       List[str]    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_pretraining(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: str      ):
			lowerCAmelCase_   :       Any    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_sequence_classification(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: int      ):
			lowerCAmelCase_   :       int    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_question_answering(*SCREAMING_SNAKE_CASE__      )




	def 	__A      (						self				: Dict      ):
			lowerCAmelCase_   :       str    							=self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_electra_for_multiple_choice(*SCREAMING_SNAKE_CASE__      )




	@slow
	def 	__A      (						self				: List[str]      ):
			for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
					lowerCAmelCase_   :       Dict    							=ElectraModel.from_pretrained(SCREAMING_SNAKE_CASE__      )
					self.assertIsNotNone(SCREAMING_SNAKE_CASE__      )





	def 	__A      (						self				: Dict      ):
			lowerCAmelCase_   :       str    							=self.model_tester.prepare_config_and_inputs_for_decoder()
			self.model_tester.create_and_check_electra_for_causal_lm(*SCREAMING_SNAKE_CASE__      )







@require_torch
class 							_snake_case     (  unittest.TestCase ):
	"""simple docstring"""





	@slow
	def 	__A      (						self				: str      ):
			lowerCAmelCase_   :       int    							=ElectraModel.from_pretrained('''google/electra-small-discriminator'''      )
			lowerCAmelCase_   :       str    							=torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]      )
			lowerCAmelCase_   :       Optional[Any]    							=torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]      )
			lowerCAmelCase_   :       Union[str, Any]    							=model(SCREAMING_SNAKE_CASE__					,						attention_mask=SCREAMING_SNAKE_CASE__      )[0]
			lowerCAmelCase_   :       int    							=torch.Size((1, 11, 256)      )
			self.assertEqual(output.shape					,						SCREAMING_SNAKE_CASE__      )
			lowerCAmelCase_   :       List[Any]    							=torch.tensor(
			    [[[0.4_4_7_1, 0.6_8_2_1, -0.3_2_6_5], [0.4_6_2_7, 0.5_2_5_5, -0.3_6_6_8], [0.4_5_3_2, 0.3_3_1_3, -0.4_3_4_4]]]      )

			self.assertTrue(torch.allclose(output[:, 1:4, 1:4]					,						SCREAMING_SNAKE_CASE__					,						atol=1E-4      )      )









"""simple docstring"""




from __future__ import annotations

import math
from itertools import permutations



def 						UpperCAmelCase__ (					A__ )   ->   bool:




   """simple docstring"""

   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5						,     int(math.sqrt(A__ ) + 1 )						,     6 ):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True



def 						UpperCAmelCase__ (					A__ = 7 )   ->   int:




   """simple docstring"""
   lowerCamelCase__						       =      "".join(str(A__ ) for i in range(1						,     n + 1 ) )
   lowerCamelCase__						       =      [int("".join(A__ ) ) for i in permutations(A__						,     A__ )]
   lowerCamelCase__						       =      [num for num in perm_list if is_prime(A__ )]
   return max(A__ ) if pandigitals else 0


if __name__ == "__main__":
     print(F'''{solution() = }''')




