




'''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 					lowercase_			:





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





     def  _lowerCAmelCase			(    self    :				Tuple ):
           snake_case__					:      Optional[Any]  			=						ids_tensor([self.batch_size, self.seq_length]    ,       self.vocab_size )

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

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

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

           snake_case__					:      Any  			=						self.get_config()

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





     def  _lowerCAmelCase			(    self    :				int ):
           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=__lowerCamelCase    ,       initializer_range=self.initializer_range    ,       )





     def  _lowerCAmelCase			(    self    :				Union[str, Any] ):
           (
               (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       (
               snake_case__
           )			,       
           )					:      Tuple  			=						self.prepare_config_and_inputs()

           snake_case__					:      List[Any]  			=						True
           snake_case__					:      List[Any]  			=						floats_tensor([self.batch_size, self.seq_length, self.hidden_size] )
           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  _lowerCAmelCase			(    self    :				Dict    ,       __lowerCamelCase    :				int    ,       __lowerCamelCase    :				Optional[int]    ,       __lowerCamelCase    :				Optional[Any]    ,       __lowerCamelCase    :				Union[str, Any]    ,       __lowerCamelCase    :				Union[str, Any]    ,       __lowerCamelCase    :				Dict    ,       __lowerCamelCase    :				List[str]    ,       __lowerCamelCase    :				Tuple    ,       ):
           snake_case__					:      Any  			=						ElectraModel(config=__lowerCamelCase )
           model.to(__lowerCamelCase )
           model.eval()
           snake_case__					:      str  			=						model(__lowerCamelCase    ,       attention_mask=__lowerCamelCase    ,       token_type_ids=__lowerCamelCase )
           snake_case__					:      Any  			=						model(__lowerCamelCase    ,       token_type_ids=__lowerCamelCase )
           snake_case__					:      List[str]  			=						model(__lowerCamelCase )
           self.parent.assertEqual(result.last_hidden_state.shape    ,       (self.batch_size, self.seq_length, self.hidden_size) )





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





     def  _lowerCAmelCase			(    self    :				Optional[Any]    ,       __lowerCamelCase    :				str    ,       __lowerCamelCase    :				Dict    ,       __lowerCamelCase    :				Any    ,       __lowerCamelCase    :				Union[str, Any]    ,       __lowerCamelCase    :				Union[str, Any]    ,       __lowerCamelCase    :				Any    ,       __lowerCamelCase    :				Any    ,       __lowerCamelCase    :				Optional[Any]    ,       ):
           snake_case__					:      str  			=						ElectraForMaskedLM(config=__lowerCamelCase )
           model.to(__lowerCamelCase )
           model.eval()
           snake_case__					:      Any  			=						model(__lowerCamelCase    ,       attention_mask=__lowerCamelCase    ,       token_type_ids=__lowerCamelCase    ,       labels=__lowerCamelCase )
           self.parent.assertEqual(result.logits.shape    ,       (self.batch_size, self.seq_length, self.vocab_size) )





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





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





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





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





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





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






@require_torch
class 					lowercase_			(	lowerCAmelCase_	,					lowerCAmelCase_	,					unittest.TestCase       ):
     A_       							= (
         (
             ElectraModel,
             ElectraForPreTraining,
             ElectraForMaskedLM,
             ElectraForCausalLM,
             ElectraForMultipleChoice,
             ElectraForTokenClassification,
             ElectraForSequenceClassification,
             ElectraForQuestionAnswering,
         )
         if is_torch_available()
         else ()
     )
     A_       							= (
         {
             "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 {}
     )
     A_       							= True





     def  _lowerCAmelCase			(    self    :				int    ,       __lowerCamelCase    :				List[str]    ,       __lowerCamelCase    :				str    ,       __lowerCamelCase    :				Dict=False ):
           snake_case__					:      Optional[int]  			=						super()._prepare_for_class(__lowerCamelCase    ,       __lowerCamelCase    ,       return_labels=__lowerCamelCase )

           if return_labels:
                 if model_class in get_values(__lowerCamelCase ):
                       snake_case__					:      Union[str, Any]  			=						torch.zeros(
                           (self.model_tester.batch_size, self.model_tester.seq_length)    ,       dtype=torch.long    ,       device=__lowerCamelCase )
           return inputs_dict





     def  _lowerCAmelCase			(    self    :				List[str] ):
           snake_case__					:      Union[str, Any]  			=						ElectraModelTester(self )
           snake_case__					:      List[Any]  			=						ConfigTester(self    ,       config_class=__lowerCamelCase    ,       hidden_size=37 )





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





     def  _lowerCAmelCase			(    self    :				str ):
           snake_case__					:      Tuple  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_model(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				List[str] ):
           snake_case__					:      Union[str, Any]  			=						self.model_tester.prepare_config_and_inputs_for_decoder()
           self.model_tester.create_and_check_electra_model_as_decoder(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Dict ):
           snake_case__					:      Tuple  			=						self.model_tester.prepare_config_and_inputs()
           for type in ["absolute", "relative_key", "relative_key_query"]:
                 snake_case__					:      List[str]  			=						type
                 self.model_tester.create_and_check_electra_model(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Optional[Any] ):
           snake_case__					:      Optional[int]  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_masked_lm(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Optional[Any] ):
           snake_case__					:      Dict  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_token_classification(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Optional[Any] ):
           snake_case__					:      Optional[int]  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_pretraining(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Any ):
           snake_case__					:      List[str]  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_sequence_classification(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				List[Any] ):
           snake_case__					:      int  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_question_answering(*__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				List[str] ):
           snake_case__					:      str  			=						self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_electra_for_multiple_choice(*__lowerCamelCase )





     @slow
     def  _lowerCAmelCase			(    self    :				Any ):
           for model_name in ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                 snake_case__					:      str  			=						ElectraModel.from_pretrained(__lowerCamelCase )
                 self.assertIsNotNone(__lowerCamelCase )





     def  _lowerCAmelCase			(    self    :				Optional[Any] ):
           snake_case__					:      Tuple  			=						self.model_tester.prepare_config_and_inputs_for_decoder()
           self.model_tester.create_and_check_electra_for_causal_lm(*__lowerCamelCase )






@require_torch
class 					lowercase_			(	unittest.TestCase       ):





     @slow
     def  _lowerCAmelCase			(    self    :				Optional[int] ):
           snake_case__					:      Tuple  			=						ElectraModel.from_pretrained('google/electra-small-discriminator' )
           snake_case__					:      Optional[Any]  			=						torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]] )
           snake_case__					:      int  			=						torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] )
           snake_case__					:      Optional[Any]  			=						model(__lowerCamelCase    ,       attention_mask=__lowerCamelCase )[0]
           snake_case__					:      Optional[Any]  			=						torch.Size((1, 11, 256) )
           self.assertEqual(output.shape    ,       __lowerCamelCase )
           snake_case__					:      List[str]  			=						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]    ,       __lowerCamelCase    ,       atol=1E-4 ) )






'''simple docstring'''






class 					lowercase_			:





     def __init__(    self    :				Any ):
           snake_case__					:      List[str]  			=						[0]
           snake_case__					:      Optional[Any]  			=						0





     def  _lowerCAmelCase			(    self    :				List[str]    ,       __lowerCamelCase    :				int ):
           snake_case__					:      Optional[int]  			=						self.__heap[i]
           while i // 2 > 0:
                 if self.__heap[i] > self.__heap[i // 2]:
                       snake_case__					:      Union[str, Any]  			=						self.__heap[i // 2]
                       snake_case__					:      Union[str, Any]  			=						temporary
                 i //= 2





     def  _lowerCAmelCase			(    self    :				int    ,       __lowerCamelCase    :				int ):
           self.__heap.append(__lowerCamelCase )
           self.__size += 1
           self.__swap_up(self.__size )





     def  _lowerCAmelCase			(    self    :				Dict    ,       __lowerCamelCase    :				int ):
           while self.__size >= 2 * i:
                 if 2 * i + 1 > self.__size:
                       snake_case__					:      List[str]  			=						2 * i
                 else:
                       if self.__heap[2 * i] > self.__heap[2 * i + 1]:
                             snake_case__					:      Any  			=						2 * i
                       else:
                             snake_case__					:      Tuple  			=						2 * i + 1
                 snake_case__					:      int  			=						self.__heap[i]
                 if self.__heap[i] < self.__heap[bigger_child]:
                       snake_case__					:      Tuple  			=						self.__heap[bigger_child]
                       snake_case__					:      int  			=						temporary
                 snake_case__					:      int  			=						bigger_child





     def  _lowerCAmelCase			(    self    :				Union[str, Any] ):
           snake_case__					:      Any  			=						self.__heap[1]
           snake_case__					:      List[str]  			=						self.__heap[self.__size]
           self.__size -= 1
           self.__heap.pop()
           self.__swap_down(1 )
           return max_value





     @property
     def  _lowerCAmelCase			(    self    :				Union[str, Any] ):
           return self.__heap[1:]





     def __len__(    self    :				int ):
           return self.__size


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      # create an instance of BinaryHeap
      A_ 			=		BinaryHeap()
      binary_heap.insert(6)
      binary_heap.insert(10)
      binary_heap.insert(15)
      binary_heap.insert(12)
      # pop root(max-values because it is max heap)
      print(binary_heap.pop())  # 15
      print(binary_heap.pop())  # 12
      # get the list and size after operations
      print(binary_heap.get_list)
      print(len(binary_heap))
