




"""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      lowerCAmelCase_						:


				"""simple docstring"""



				def __init__(self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__=13       ,	SCREAMING_SNAKE_CASE__=7       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=True       ,	SCREAMING_SNAKE_CASE__=99       ,	SCREAMING_SNAKE_CASE__=32       ,	SCREAMING_SNAKE_CASE__=5       ,	SCREAMING_SNAKE_CASE__=4       ,	SCREAMING_SNAKE_CASE__=37       ,	SCREAMING_SNAKE_CASE__="gelu"       ,	SCREAMING_SNAKE_CASE__=0.1       ,	SCREAMING_SNAKE_CASE__=0.1       ,	SCREAMING_SNAKE_CASE__=5_12       ,	SCREAMING_SNAKE_CASE__=16       ,	SCREAMING_SNAKE_CASE__=2       ,	SCREAMING_SNAKE_CASE__=0.02       ,	SCREAMING_SNAKE_CASE__=3       ,	SCREAMING_SNAKE_CASE__=4       ,	SCREAMING_SNAKE_CASE__=None       ,	) ->		List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       parent
											SCREAMING_SNAKE_CASE__						:	List[str]									=       batch_size
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       seq_length
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       is_training
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       use_input_mask
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       use_token_type_ids
											SCREAMING_SNAKE_CASE__						:	List[str]									=       use_labels
											SCREAMING_SNAKE_CASE__						:	int									=       vocab_size
											SCREAMING_SNAKE_CASE__						:	Any									=       hidden_size
											SCREAMING_SNAKE_CASE__						:	str									=       num_hidden_layers
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       num_attention_heads
											SCREAMING_SNAKE_CASE__						:	Any									=       intermediate_size
											SCREAMING_SNAKE_CASE__						:	Dict									=       hidden_act
											SCREAMING_SNAKE_CASE__						:	str									=       hidden_dropout_prob
											SCREAMING_SNAKE_CASE__						:	Tuple									=       attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE__						:	Any									=       max_position_embeddings
											SCREAMING_SNAKE_CASE__						:	Dict									=       type_vocab_size
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       type_sequence_label_size
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       initializer_range
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       num_labels
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       num_choices
											SCREAMING_SNAKE_CASE__						:	List[str]									=       scope



				def      __magic_name__   (self   ) ->		int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[str]									=       ids_tensor([self.batch_size, self.seq_length]       ,	self.vocab_size   )

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

											SCREAMING_SNAKE_CASE__						:	Any									=       None
											if self.use_token_type_ids:
																		SCREAMING_SNAKE_CASE__						:	Dict									=       ids_tensor([self.batch_size, self.seq_length]       ,	self.type_vocab_size   )

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

											SCREAMING_SNAKE_CASE__						:	Dict									=       self.get_config()

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



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											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=__snake_case       ,	initializer_range=self.initializer_range       ,	)



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											(
											    SCREAMING_SNAKE_CASE__		
											)						:	int									=       self.prepare_config_and_inputs()

											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       True
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       floats_tensor([self.batch_size, self.seq_length, self.hidden_size]   )
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       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      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		Optional[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Dict									=       ElectraModel(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       model(__snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case   )
											SCREAMING_SNAKE_CASE__						:	str									=       model(__snake_case       ,	token_type_ids=__snake_case   )
											SCREAMING_SNAKE_CASE__						:	Any									=       model(__snake_case   )
											self.parent.assertEqual(result.last_hidden_state.shape       ,	(self.batch_size, self.seq_length, self.hidden_size)   )



				def      __magic_name__   (self       ,	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__       ,	) ->		Optional[Any]:



											"""simple docstring"""




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



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		List[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Any									=       ElectraForMaskedLM(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       model(__snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	labels=__snake_case   )
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.vocab_size)   )



				def      __magic_name__   (self       ,	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__       ,	) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Tuple									=       ElectraForCausalLM(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	List[Any]									=       model(__snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	labels=__snake_case   )
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.vocab_size)   )



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		Any:



											"""simple docstring"""




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



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[Any]									=       self.num_labels
											SCREAMING_SNAKE_CASE__						:	Tuple									=       ElectraForPreTraining(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	Tuple									=       model(__snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	labels=__snake_case   )
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length)   )



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Dict									=       self.num_labels
											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       ElectraForSequenceClassification(__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	List[str]									=       model(__snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	labels=__snake_case   )
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.num_labels)   )



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		List[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Any									=       ElectraForQuestionAnswering(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	int									=       model(
											    __snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	start_positions=__snake_case       ,	end_positions=__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      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	) ->		List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[str]									=       self.num_choices
											SCREAMING_SNAKE_CASE__						:	List[str]									=       ElectraForMultipleChoice(config=__snake_case   )
											model.to(__snake_case   )
											model.eval()
											SCREAMING_SNAKE_CASE__						:	Tuple									=       input_ids.unsqueeze(1   ).expand(-1       ,	self.num_choices       ,	-1   ).contiguous()
											SCREAMING_SNAKE_CASE__						:	Tuple									=       token_type_ids.unsqueeze(1   ).expand(-1       ,	self.num_choices       ,	-1   ).contiguous()
											SCREAMING_SNAKE_CASE__						:	Any									=       input_mask.unsqueeze(1   ).expand(-1       ,	self.num_choices       ,	-1   ).contiguous()
											SCREAMING_SNAKE_CASE__						:	Any									=       model(
											    __snake_case       ,	attention_mask=__snake_case       ,	token_type_ids=__snake_case       ,	labels=__snake_case       ,	)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.num_choices)   )



				def      __magic_name__   (self   ) ->		Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	int									=       self.prepare_config_and_inputs()
											(
											    SCREAMING_SNAKE_CASE__		
											)						:	List[Any]									=       config_and_inputs
											SCREAMING_SNAKE_CASE__						:	Tuple									=       {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
											return config, inputs_dict






@require_torch
class      lowerCAmelCase_						(A__			, A__			, unittest.TestCase  ):


				"""simple docstring"""



				__UpperCamelCase				:						Optional[Any] 	=       (
				    (
				        ElectraModel,
				        ElectraForPreTraining,
				        ElectraForMaskedLM,
				        ElectraForCausalLM,
				        ElectraForMultipleChoice,
				        ElectraForTokenClassification,
				        ElectraForSequenceClassification,
				        ElectraForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				__UpperCamelCase				:						int 	=       (
				    {
				        '''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				:						List[Any] 	=       True



				def      __magic_name__   (self       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__       ,	SCREAMING_SNAKE_CASE__=False   ) ->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[Any]									=       super()._prepare_for_class(__snake_case       ,	__snake_case       ,	return_labels=__snake_case   )

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



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[str]									=       ElectraModelTester(self   )
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       ConfigTester(self       ,	config_class=__snake_case       ,	hidden_size=37   )



				def      __magic_name__   (self   ) ->		List[str]:



											"""simple docstring"""




											self.config_tester.run_common_tests()



				def      __magic_name__   (self   ) ->		Optional[int]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_model(*__snake_case   )



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       self.model_tester.prepare_config_and_inputs_for_decoder()
											self.model_tester.create_and_check_electra_model_as_decoder(*__snake_case   )



				def      __magic_name__   (self   ) ->		int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	int									=       self.model_tester.prepare_config_and_inputs()
											for type in ["absolute", "relative_key", "relative_key_query"]:
																		SCREAMING_SNAKE_CASE__						:	List[Any]									=       type
																		self.model_tester.create_and_check_electra_model(*__snake_case   )



				def      __magic_name__   (self   ) ->		Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	List[Any]									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_masked_lm(*__snake_case   )



				def      __magic_name__   (self   ) ->		Optional[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	int									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_token_classification(*__snake_case   )



				def      __magic_name__   (self   ) ->		Dict:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Dict									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_pretraining(*__snake_case   )



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Optional[int]									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_sequence_classification(*__snake_case   )



				def      __magic_name__   (self   ) ->		Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_question_answering(*__snake_case   )



				def      __magic_name__   (self   ) ->		Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_electra_for_multiple_choice(*__snake_case   )



				@slow
				def      __magic_name__   (self   ) ->		Optional[Any]:



											"""simple docstring"""




											for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		SCREAMING_SNAKE_CASE__						:	Optional[int]									=       ElectraModel.from_pretrained(__snake_case   )
																		self.assertIsNotNone(__snake_case   )



				def      __magic_name__   (self   ) ->		Union[str, Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	Any									=       self.model_tester.prepare_config_and_inputs_for_decoder()
											self.model_tester.create_and_check_electra_for_causal_lm(*__snake_case   )






@require_torch
class      lowerCAmelCase_						(unittest.TestCase  ):


				"""simple docstring"""



				@slow
				def      __magic_name__   (self   ) ->		List[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__						:	str									=       ElectraModel.from_pretrained("""google/electra-small-discriminator"""   )
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]   )
											SCREAMING_SNAKE_CASE__						:	Union[str, Any]									=       torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]   )
											SCREAMING_SNAKE_CASE__						:	int									=       model(__snake_case       ,	attention_mask=__snake_case   )[0]
											SCREAMING_SNAKE_CASE__						:	Any									=       torch.Size((1, 11, 2_56)   )
											self.assertEqual(output.shape       ,	__snake_case   )
											SCREAMING_SNAKE_CASE__						:	Tuple									=       torch.tensor(
											    [[[0.4471, 0.6821, -0.3265], [0.4627, 0.5255, -0.3668], [0.4532, 0.3313, -0.4344]]]   )

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






"""simple docstring"""




def lowercase_  (       _snake_case       ,_snake_case       ,_snake_case						):
							SCREAMING_SNAKE_CASE__						:	Any									=       index
							SCREAMING_SNAKE_CASE__						:	List[Any]									=       2 * index + 1
							SCREAMING_SNAKE_CASE__						:	Any									=       2 * index + 2
							if left_index < heap_size and unsorted[left_index] > unsorted[largest]:
														SCREAMING_SNAKE_CASE__						:	str									=       left_index

							if right_index < heap_size and unsorted[right_index] > unsorted[largest]:
														SCREAMING_SNAKE_CASE__						:	Any									=       right_index

							if largest != index:
														SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Tuple									=       unsorted[index], unsorted[largest]
														heapify(_snake_case       ,_snake_case       ,_snake_case						)

def lowercase_  (       _snake_case						):
							SCREAMING_SNAKE_CASE__						:	List[Any]									=       len(_snake_case						)
							for i in range(n // 2 - 1       ,-1       ,-1						):
														heapify(_snake_case       ,_snake_case       ,_snake_case						)
							for i in range(n - 1       ,0       ,-1						):
														SCREAMING_SNAKE_CASE__				,				SCREAMING_SNAKE_CASE__						:	Any									=       unsorted[i], unsorted[0]
														heapify(_snake_case       ,0       ,_snake_case						)
							return unsorted


if __name__ == "__main__":
					UpperCAmelCase__				:   Optional[Any]   							=			input('Enter numbers separated by a comma:\n').strip()
					UpperCAmelCase__				:   Optional[int]   							=			[int(item) for item in user_input.split(',')]
					print(heap_sort(unsorted))




