
import unittest

from transformers import FunnelConfig, FunnelTokenizer, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

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


if is_torch_available():
     import torch

     from transformers import (
         MODEL_FOR_PRETRAINING_MAPPING,
         FunnelBaseModel,
         FunnelForMaskedLM,
         FunnelForMultipleChoice,
         FunnelForPreTraining,
         FunnelForQuestionAnswering,
         FunnelForSequenceClassification,
         FunnelForTokenClassification,
         FunnelModel,
     )




class    _SCREAMING_SNAKE_CASE					:
      def __init__(     self						,		lowerCamelCase						,		lowerCamelCase=13						,		lowerCamelCase=7						,		lowerCamelCase=True						,		lowerCamelCase=True						,		lowerCamelCase=True						,		lowerCamelCase=True						,		lowerCamelCase=99						,		lowerCamelCase=[1, 1, 2]						,		lowerCamelCase=1						,		lowerCamelCase=32						,		lowerCamelCase=4						,		lowerCamelCase=8						,		lowerCamelCase=37						,		lowerCamelCase="gelu_new"						,		lowerCamelCase=0.1						,		lowerCamelCase=0.1						,		lowerCamelCase=0.0						,		lowerCamelCase=5_12						,		lowerCamelCase=3						,		lowerCamelCase=0.0_2						,		lowerCamelCase=3						,		lowerCamelCase=4						,		lowerCamelCase=None						,		lowerCamelCase=False						,		):
          snake_case__  =			parent
          snake_case__  =			batch_size
          snake_case__  =			seq_length
          snake_case__  =			is_training
          snake_case__  =			use_input_mask
          snake_case__  =			use_token_type_ids
          snake_case__  =			use_labels
          snake_case__  =			vocab_size
          snake_case__  =			block_sizes
          snake_case__  =			num_decoder_layers
          snake_case__  =			d_model
          snake_case__  =			n_head
          snake_case__  =			d_head
          snake_case__  =			d_inner
          snake_case__  =			hidden_act
          snake_case__  =			hidden_dropout
          snake_case__  =			attention_dropout
          snake_case__  =			activation_dropout
          snake_case__  =			max_position_embeddings
          snake_case__  =			type_vocab_size
          snake_case__  =			2
          snake_case__  =			num_labels
          snake_case__  =			num_choices
          snake_case__  =			scope
          snake_case__  =			initializer_std

          # Used in the tests to check the size of the first attention layer
          snake_case__  =			n_head
          # Used in the tests to check the size of the first hidden state
          snake_case__  =			self.d_model
          # Used in the tests to check the number of output hidden states/attentions
          snake_case__  =			sum(self.block_sizes	) + (0 if base else self.num_decoder_layers)
          # FunnelModel adds two hidden layers: input embeddings and the sum of the upsampled encoder hidden state with
          # the last hidden state of the first block (which is the first hidden state of the decoder).
          if not base:
              snake_case__  =			self.num_hidden_layers + 2
      def A_     (     self	):
          snake_case__  =			ids_tensor([self.batch_size, self.seq_length]						,		self.vocab_size	)

          snake_case__  =			None
          if self.use_input_mask:
              snake_case__  =			ids_tensor([self.batch_size, self.seq_length]						,		vocab_size=2	)

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

          snake_case__  =			None
          snake_case__  =			None
          snake_case__  =			None
          if self.use_labels:
              snake_case__  =			ids_tensor([self.batch_size]						,		self.type_sequence_label_size	)
              snake_case__  =			ids_tensor([self.batch_size, self.seq_length]						,		self.num_labels	)
              snake_case__  =			ids_tensor([self.batch_size]						,		self.num_choices	)
              snake_case__  =			ids_tensor([self.batch_size, self.seq_length]						,		1	)

          snake_case__  =			self.get_config()

          return (
              config,
              input_ids,
              token_type_ids,
              input_mask,
              sequence_labels,
              token_labels,
              choice_labels,
              fake_token_labels,
          )
      def A_     (     self	):
          return FunnelConfig(
              vocab_size=self.vocab_size						,		block_sizes=self.block_sizes						,		num_decoder_layers=self.num_decoder_layers						,		d_model=self.d_model						,		n_head=self.n_head						,		d_head=self.d_head						,		d_inner=self.d_inner						,		hidden_act=self.hidden_act						,		hidden_dropout=self.hidden_dropout						,		attention_dropout=self.attention_dropout						,		activation_dropout=self.activation_dropout						,		max_position_embeddings=self.max_position_embeddings						,		type_vocab_size=self.type_vocab_size						,		initializer_std=self.initializer_std						,		)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			FunnelModel(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			model(lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase	)
          snake_case__  =			model(lowerCamelCase						,		token_type_ids=lowerCamelCase	)
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, self.seq_length, self.d_model)	)

          snake_case__  =			False
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, self.seq_length, self.d_model)	)

          snake_case__  =			False
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, self.seq_length, self.d_model)	)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			FunnelBaseModel(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			model(lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase	)
          snake_case__  =			model(lowerCamelCase						,		token_type_ids=lowerCamelCase	)
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, 2, self.d_model)	)

          snake_case__  =			False
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, 3, self.d_model)	)

          snake_case__  =			False
          snake_case__  =			model(lowerCamelCase	)
          self.parent.assertEqual(result.last_hidden_state.shape						,		(self.batch_size, 2, self.d_model)	)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			self.num_labels
          snake_case__  =			FunnelForPreTraining(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			model(lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase						,		labels=lowerCamelCase	)
          self.parent.assertEqual(result.logits.shape						,		(self.batch_size, self.seq_length)	)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			FunnelForMaskedLM(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			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 A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			self.num_labels
          snake_case__  =			FunnelForSequenceClassification(lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			model(lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase						,		labels=lowerCamelCase	)
          self.parent.assertEqual(result.logits.shape						,		(self.batch_size, self.num_labels)	)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			self.num_choices
          snake_case__  =			FunnelForMultipleChoice(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			input_ids.unsqueeze(1	).expand(-1						,		self.num_choices						,		-1	).contiguous()
          snake_case__  =			token_type_ids.unsqueeze(1	).expand(-1						,		self.num_choices						,		-1	).contiguous()
          snake_case__  =			input_mask.unsqueeze(1	).expand(-1						,		self.num_choices						,		-1	).contiguous()
          snake_case__  =			model(
              lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase						,		labels=lowerCamelCase						,		)
          self.parent.assertEqual(result.logits.shape						,		(self.batch_size, self.num_choices)	)
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			self.num_labels
          snake_case__  =			FunnelForTokenClassification(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			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 A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase						,		):
          snake_case__  =			FunnelForQuestionAnswering(config=lowerCamelCase	)
          model.to(lowerCamelCase	)
          model.eval()
          snake_case__  =			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 A_     (     self	):
          snake_case__  =			self.prepare_config_and_inputs()
          (
              (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   (
              snake_case__
          )  ,   
          )  =			config_and_inputs
          snake_case__  =			{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
          return config, inputs_dict





@require_torch
class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase    ,   __UpperCamelCase    ,   unittest.TestCase	):
      _A  :						List[Any]      		=       False
      _A  :						Any      		=       False
      _A  :						Optional[int]      		=       (
          (
              FunnelModel,
              FunnelForMaskedLM,
              FunnelForPreTraining,
              FunnelForQuestionAnswering,
              FunnelForTokenClassification,
          )
          if is_torch_available()
          else ()
      )
      _A  :						Any      		=       (
          {
              'feature-extraction': (FunnelBaseModel, FunnelModel),
              'fill-mask': FunnelForMaskedLM,
              'question-answering': FunnelForQuestionAnswering,
              'text-classification': FunnelForSequenceClassification,
              'token-classification': FunnelForTokenClassification,
              'zero-shot': FunnelForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
      def A_     (     self						,		lowerCamelCase						,		lowerCamelCase						,		lowerCamelCase=False	):
          snake_case__  =			super()._prepare_for_class(lowerCamelCase						,		lowerCamelCase						,		return_labels=lowerCamelCase	)

          if return_labels:
              if model_class in get_values(lowerCamelCase	):
                  snake_case__  =			torch.zeros(
                      (self.model_tester.batch_size, self.model_tester.seq_length)						,		dtype=torch.long						,		device=lowerCamelCase	)
          return inputs_dict
      def A_     (     self	):
          snake_case__  =			FunnelModelTester(self	)
          snake_case__  =			ConfigTester(self						,		config_class=lowerCamelCase	)
      def A_     (     self	):
          self.config_tester.run_common_tests()
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_pretraining(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_masked_lm(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_token_classification(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_question_answering(*lowerCamelCase	)



      def A_     (     self						,		lowerCamelCase	):
          if hasattr(lowerCamelCase						,		"weight"	) and module.weight is not None:
              module.weight.data.fill_(3	)
          if hasattr(lowerCamelCase						,		"bias"	) and module.bias is not None:
              module.bias.data.fill_(3	)

          for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
              if hasattr(lowerCamelCase						,		lowerCamelCase	) and getattr(lowerCamelCase						,		lowerCamelCase	) is not None:
                  snake_case__  =			getattr(lowerCamelCase						,		lowerCamelCase	)
                  weight.data.fill_(3	)





@require_torch
class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase    ,   unittest.TestCase	):
      _A  :						int      		=       False
      _A  :						Optional[Any]      		=       False
      _A  :						Optional[int]      		=       (
          (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
      )
      def A_     (     self	):
          snake_case__  =			FunnelModelTester(self						,		base=lowerCamelCase	)
          snake_case__  =			ConfigTester(self						,		config_class=lowerCamelCase	)
      def A_     (     self	):
          self.config_tester.run_common_tests()
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_base_model(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_sequence_classification(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_multiple_choice(*lowerCamelCase	)
      def A_     (     self	):
          snake_case__  ,   snake_case__  =			self.model_tester.prepare_config_and_inputs_for_common()
          snake_case__  =			True

          for model_class in self.all_model_classes:
              if model_class.__name__ == "FunnelBaseModel":
                  continue
              snake_case__  =			model_class(lowerCamelCase	)
              model.to(lowerCamelCase	)
              model.train()
              snake_case__  =			self._prepare_for_class(lowerCamelCase						,		lowerCamelCase						,		return_labels=lowerCamelCase	)
              snake_case__  =			model(**lowerCamelCase	).loss
              loss.backward()



      def A_     (     self						,		lowerCamelCase	):
          if hasattr(lowerCamelCase						,		"weight"	) and module.weight is not None:
              module.weight.data.fill_(3	)
          if hasattr(lowerCamelCase						,		"bias"	) and module.bias is not None:
              module.bias.data.fill_(3	)

          for param in ["r_w_bias", "r_r_bias", "r_kernel", "r_s_bias", "seg_embed"]:
              if hasattr(lowerCamelCase						,		lowerCamelCase	) and getattr(lowerCamelCase						,		lowerCamelCase	) is not None:
                  snake_case__  =			getattr(lowerCamelCase						,		lowerCamelCase	)
                  weight.data.fill_(3	)





@require_torch
@require_sentencepiece
@require_tokenizers
class    _SCREAMING_SNAKE_CASE					( unittest.TestCase	):
      def A_     (     self	):
          snake_case__  =			13
          snake_case__  =			7
          snake_case__  =			torch.arange(0						,		batch_size * sequence_length	).long().reshape(lowerCamelCase						,		lowerCamelCase	)
          snake_case__  =			[0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
          snake_case__  =			torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]	)

          snake_case__  =			FunnelModel.from_pretrained("sgugger/funnel-random-tiny"	)
          snake_case__  =			model(lowerCamelCase						,		token_type_ids=lowerCamelCase	)[0].abs()

          snake_case__  =			torch.tensor(2_3_4_4.8_3_5_2	)
          snake_case__  =			torch.tensor(0.8_0_5_2	)
          self.assertTrue(torch.allclose(output.sum()						,		lowerCamelCase						,		atol=1e-4	)	)
          self.assertTrue(torch.allclose(output.mean()						,		lowerCamelCase						,		atol=1e-4	)	)

          snake_case__  =			torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]	)
          snake_case__  =			model(lowerCamelCase						,		attention_mask=lowerCamelCase						,		token_type_ids=lowerCamelCase	)[0].abs()

          snake_case__  =			torch.tensor(2_3_4_3.8_4_2_5	)
          snake_case__  =			torch.tensor(0.8_0_4_9	)
          self.assertTrue(torch.allclose(output.sum()						,		lowerCamelCase						,		atol=1e-4	)	)
          self.assertTrue(torch.allclose(output.mean()						,		lowerCamelCase						,		atol=1e-4	)	)



      @slow
      def A_     (     self	):
          snake_case__  =			FunnelTokenizer.from_pretrained("huggingface/funnel-small"	)
          snake_case__  =			FunnelModel.from_pretrained("huggingface/funnel-small"	)
          snake_case__  =			tokenizer("Hello! I am the Funnel Transformer model."						,		return_tensors="pt"	)
          snake_case__  =			model(**lowerCamelCase	)[0]

          snake_case__  =			torch.tensor(2_3_5.7_2_4_6	)
          snake_case__  =			torch.tensor(0.0_2_5_6	)
          self.assertTrue(torch.allclose(output.sum()						,		lowerCamelCase						,		atol=1e-4	)	)
          self.assertTrue(torch.allclose(output.mean()						,		lowerCamelCase						,		atol=1e-4	)	)





from __future__ import annotations

from abc import abstractmethod
from collections.abc import Iterable
from typing import Generic, Protocol, TypeVar




class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      @abstractmethod
      def __lt__(     self						,		lowerCamelCase	):
          pass
      @abstractmethod
      def __gt__(     self						,		lowerCamelCase	):
          pass



      @abstractmethod
      def __eq__(     self						,		lowerCamelCase	):
          pass





__magic_name__           =					TypeVar('''T''', bound=Comparable)




class    _SCREAMING_SNAKE_CASE					( Generic[T]	):
      def __init__(     self	):
          snake_case__  =			[]
          snake_case__  =			0
      def __repr__(     self	):
          return str(self.h	)
      def A_     (     self						,		lowerCamelCase	):
          if child_idx > 0:
              return (child_idx - 1) // 2
          return None
      def A_     (     self						,		lowerCamelCase	):
          snake_case__  =			2 * parent_idx + 1
          if left_child_index < self.heap_size:
              return left_child_index
          return None
      def A_     (     self						,		lowerCamelCase	):
          snake_case__  =			2 * parent_idx + 2
          if right_child_index < self.heap_size:
              return right_child_index
          return None
      def A_     (     self						,		lowerCamelCase	):
          if index < self.heap_size:
              snake_case__  =			index
              snake_case__  =			self.left_child_idx(lowerCamelCase	)
              snake_case__  =			self.right_child_idx(lowerCamelCase	)
              # check which child is larger than its parent
              if left_child is not None and self.h[left_child] > self.h[violation]:
                  snake_case__  =			left_child
              if right_child is not None and self.h[right_child] > self.h[violation]:
                  snake_case__  =			right_child
              # if violation indeed exists
              if violation != index:
                  # swap to fix the violation
                  snake_case__  ,   snake_case__  =			self.h[index], self.h[violation]
                  # fix the subsequent violation recursively if any
                  self.max_heapify(lowerCamelCase	)
      def A_     (     self						,		lowerCamelCase	):
          snake_case__  =			list(lowerCamelCase	)
          snake_case__  =			len(self.h	)
          if self.heap_size > 1:
              # max_heapify from right to left but exclude leaves (last level)
              for i in range(self.heap_size // 2 - 1						,		-1						,		-1	):
                  self.max_heapify(lowerCamelCase	)
      def A_     (     self	):
          if self.heap_size >= 2:
              snake_case__  =			self.h[0]
              snake_case__  =			self.h.pop(-1	)
              self.heap_size -= 1
              self.max_heapify(0	)
              return me
          elif self.heap_size == 1:
              self.heap_size -= 1
              return self.h.pop(-1	)
          else:
              raise Exception("Empty heap"	)
      def A_     (     self						,		lowerCamelCase	):
          self.h.append(lowerCamelCase	)
          snake_case__  =			(self.heap_size - 1) // 2
          self.heap_size += 1
          while idx >= 0:
              self.max_heapify(lowerCamelCase	)
              snake_case__  =			(idx - 1) // 2



      def A_     (     self	):
          snake_case__  =			self.heap_size
          for j in range(size - 1						,		0						,		-1	):
              snake_case__  ,   snake_case__  =			self.h[j], self.h[0]
              self.heap_size -= 1
              self.max_heapify(0	)
          snake_case__  =			size


if __name__ == "__main__":
     import doctest

     # run doc test
     doctest.testmod()

     # demo
     for unsorted in [
         [0],
         [2],
         [3, 5],
         [5, 3],
         [5, 5],
         [0, 0, 0, 0],
         [1, 1, 1, 1],
         [2, 2, 3, 5],
         [0, 2, 2, 3, 5],
         [2, 5, 3, 0, 2, 3, 0, 3],
         [6, 1, 2, 7, 9, 3, 4, 5, 10, 8],
         [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5],
         [-45, -2, -5],
     ]:
          print(F'''unsorted array: {unsorted}''')

          __magic_name__           =					Heap()
          heap.build_max_heap(unsorted)
          print(F'''after build heap: {heap}''')

          print(F'''max value: {heap.extract_max()}''')
          print(F'''after max value removed: {heap}''')

          heap.insert(100)
          print(F'''after new value 100 inserted: {heap}''')

          heap.heap_sort()
          print(F'''heap-sorted array: {heap}\n''')



