


'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import FunnelConfig, is_tf_available
from transformers.testing_utils import require_tf

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
		import tensorflow as tf

		from transformers import (
		    TFFunnelBaseModel,
		    TFFunnelForMaskedLM,
		    TFFunnelForMultipleChoice,
		    TFFunnelForPreTraining,
		    TFFunnelForQuestionAnswering,
		    TFFunnelForSequenceClassification,
		    TFFunnelForTokenClassification,
		    TFFunnelModel,
		)


class 		_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=512				,				_lowerCamelCase=3				,				_lowerCamelCase=0.02				,				_lowerCamelCase=3				,				_lowerCamelCase=4				,				_lowerCamelCase=None				,				_lowerCamelCase=False				,				):
								UpperCAmelCase__	:       Optional[int]   =  parent
								UpperCAmelCase__	:       str   =  batch_size
								UpperCAmelCase__	:       Any   =  seq_length
								UpperCAmelCase__	:       Optional[int]   =  is_training
								UpperCAmelCase__	:       Optional[Any]   =  use_input_mask
								UpperCAmelCase__	:       Optional[int]   =  use_token_type_ids
								UpperCAmelCase__	:       List[str]   =  use_labels
								UpperCAmelCase__	:       Any   =  vocab_size
								UpperCAmelCase__	:       Dict   =  block_sizes
								UpperCAmelCase__	:       Tuple   =  num_decoder_layers
								UpperCAmelCase__	:       Optional[Any]   =  d_model
								UpperCAmelCase__	:       List[str]   =  n_head
								UpperCAmelCase__	:       Optional[Any]   =  d_head
								UpperCAmelCase__	:       Tuple   =  d_inner
								UpperCAmelCase__	:       List[str]   =  hidden_act
								UpperCAmelCase__	:       Tuple   =  hidden_dropout
								UpperCAmelCase__	:       str   =  attention_dropout
								UpperCAmelCase__	:       Tuple   =  activation_dropout
								UpperCAmelCase__	:       Dict   =  max_position_embeddings
								UpperCAmelCase__	:       Optional[Any]   =  type_vocab_size
								UpperCAmelCase__	:       Optional[int]   =  2
								UpperCAmelCase__	:       List[Any]   =  num_labels
								UpperCAmelCase__	:       str   =  num_choices
								UpperCAmelCase__	:       Tuple   =  scope
								UpperCAmelCase__	:       List[Any]   =  initializer_std

								# Used in the tests to check the size of the first attention layer
								UpperCAmelCase__	:       Optional[Any]   =  n_head
								# Used in the tests to check the size of the first hidden state
								UpperCAmelCase__	:       List[str]   =  self.d_model
								# Used in the tests to check the number of output hidden states/attentions
								UpperCAmelCase__	:       Union[str, Any]   =  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:
											UpperCAmelCase__	:       Optional[int]   =  self.num_hidden_layers + 2




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       List[str]   =  ids_tensor([self.batch_size, self.seq_length]				,				self.vocab_size)

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

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

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

								UpperCAmelCase__	:       str   =  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				,				)

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




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Optional[int]   =  TFFunnelModel(config=A_)
								UpperCAmelCase__	:       Union[str, Any]   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       Any   =  model(A_)

								UpperCAmelCase__	:       Tuple   =  [input_ids, input_mask]
								UpperCAmelCase__	:       Dict   =  model(A_)

								UpperCAmelCase__	:       Union[str, Any]   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, self.seq_length, self.d_model))

								UpperCAmelCase__	:       Optional[int]   =  False
								UpperCAmelCase__	:       Union[str, Any]   =  TFFunnelModel(config=A_)
								UpperCAmelCase__	:       Optional[int]   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, self.seq_length, self.d_model))

								UpperCAmelCase__	:       Optional[int]   =  False
								UpperCAmelCase__	:       Any   =  TFFunnelModel(config=A_)
								UpperCAmelCase__	:       str   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, self.seq_length, self.d_model))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Union[str, Any]   =  TFFunnelBaseModel(config=A_)
								UpperCAmelCase__	:       Union[str, Any]   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       Union[str, Any]   =  model(A_)

								UpperCAmelCase__	:       Dict   =  [input_ids, input_mask]
								UpperCAmelCase__	:       Any   =  model(A_)

								UpperCAmelCase__	:       Optional[int]   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, 2, self.d_model))

								UpperCAmelCase__	:       Tuple   =  False
								UpperCAmelCase__	:       Tuple   =  TFFunnelBaseModel(config=A_)
								UpperCAmelCase__	:       Any   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, 3, self.d_model))

								UpperCAmelCase__	:       Dict   =  False
								UpperCAmelCase__	:       Tuple   =  TFFunnelBaseModel(config=A_)
								UpperCAmelCase__	:       Optional[int]   =  model(A_)
								self.parent.assertEqual(result.last_hidden_state.shape				,				(self.batch_size, 2, self.d_model))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Optional[int]   =  TFFunnelForPreTraining(config=A_)
								UpperCAmelCase__	:       Optional[int]   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       List[Any]   =  model(A_)
								self.parent.assertEqual(result.logits.shape				,				(self.batch_size, self.seq_length))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Tuple   =  TFFunnelForMaskedLM(config=A_)
								UpperCAmelCase__	:       Any   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       str   =  model(A_)
								self.parent.assertEqual(result.logits.shape				,				(self.batch_size, self.seq_length, self.vocab_size))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Union[str, Any]   =  self.num_labels
								UpperCAmelCase__	:       Any   =  TFFunnelForSequenceClassification(config=A_)
								UpperCAmelCase__	:       Tuple   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       Optional[int]   =  model(A_)
								self.parent.assertEqual(result.logits.shape				,				(self.batch_size, self.num_labels))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       int   =  self.num_choices
								UpperCAmelCase__	:       Any   =  TFFunnelForMultipleChoice(config=A_)
								UpperCAmelCase__	:       List[Any]   =  tf.tile(tf.expand_dims(A_				,				1)				,				(1, self.num_choices, 1))
								UpperCAmelCase__	:       Union[str, Any]   =  tf.tile(tf.expand_dims(A_				,				1)				,				(1, self.num_choices, 1))
								UpperCAmelCase__	:       Union[str, Any]   =  tf.tile(tf.expand_dims(A_				,				1)				,				(1, self.num_choices, 1))
								UpperCAmelCase__	:       int   =  {
								    '''input_ids''': multiple_choice_inputs_ids,
								    '''attention_mask''': multiple_choice_input_mask,
								    '''token_type_ids''': multiple_choice_token_type_ids,
								}
								UpperCAmelCase__	:       int   =  model(A_)
								self.parent.assertEqual(result.logits.shape				,				(self.batch_size, self.num_choices))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Dict   =  self.num_labels
								UpperCAmelCase__	:       Optional[Any]   =  TFFunnelForTokenClassification(config=A_)
								UpperCAmelCase__	:       Dict   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       Union[str, Any]   =  model(A_)
								self.parent.assertEqual(result.logits.shape				,				(self.batch_size, self.seq_length, self.num_labels))




					def 					snake_case__    (   self				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				_lowerCamelCase				,				):
								UpperCAmelCase__	:       Optional[Any]   =  TFFunnelForQuestionAnswering(config=A_)
								UpperCAmelCase__	:       List[Any]   =  {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
								UpperCAmelCase__	:       List[Any]   =  model(A_)
								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 					snake_case__    (   self):
								UpperCAmelCase__	:       List[str]   =  self.prepare_config_and_inputs()
								(
								    UpperCAmelCase__					
								)	:       str   =  config_and_inputs
								UpperCAmelCase__	:       Optional[Any]   =  {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
								return config, inputs_dict


@require_tf
class 		_snake_case       (  SCREAMING_SNAKE_CASE__							, SCREAMING_SNAKE_CASE__							, unittest.TestCase						):
					lowerCAmelCase   :Any				=       (
					    (
					        TFFunnelModel,
					        TFFunnelForMaskedLM,
					        TFFunnelForPreTraining,
					        TFFunnelForQuestionAnswering,
					        TFFunnelForTokenClassification,
					    )
					    if is_tf_available()
					    else ()
					)
					lowerCAmelCase   :str				=       (
					    {
					        '''feature-extraction''': (TFFunnelBaseModel, TFFunnelModel),
					        '''fill-mask''': TFFunnelForMaskedLM,
					        '''question-answering''': TFFunnelForQuestionAnswering,
					        '''text-classification''': TFFunnelForSequenceClassification,
					        '''token-classification''': TFFunnelForTokenClassification,
					        '''zero-shot''': TFFunnelForSequenceClassification,
					    }
					    if is_tf_available()
					    else {}
					)
					lowerCAmelCase   :Optional[int]				=       False
					lowerCAmelCase   :Tuple				=       False




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Optional[int]   =  TFFunnelModelTester(self)
								UpperCAmelCase__	:       Dict   =  ConfigTester(self				,				config_class=A_)




					def 					snake_case__    (   self):
								self.config_tester.run_common_tests()




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       str   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       str   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_pretraining(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Any   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_lm(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Optional[int]   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Any   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*A_)


@require_tf
class 		_snake_case       (  SCREAMING_SNAKE_CASE__							, unittest.TestCase						):
					lowerCAmelCase   :Optional[Any]				=       (
					    (TFFunnelBaseModel, TFFunnelForMultipleChoice, TFFunnelForSequenceClassification) if is_tf_available() else ()
					)
					lowerCAmelCase   :Optional[Any]				=       False
					lowerCAmelCase   :Dict				=       False




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Optional[Any]   =  TFFunnelModelTester(self				,				base=A_)
								UpperCAmelCase__	:       str   =  ConfigTester(self				,				config_class=A_)




					def 					snake_case__    (   self):
								self.config_tester.run_common_tests()




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Tuple   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_base_model(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Any   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*A_)




					def 					snake_case__    (   self):
								UpperCAmelCase__	:       Optional[Any]   =  self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_multiple_choice(*A_)

"""simple docstring"""




def 			_lowerCAmelCase		(		_UpperCamelCase    ):






  """simple docstring"""



  stooge(_UpperCamelCase			,					0			,					len(_UpperCamelCase    ) - 1    )
  return arr




def 			_lowerCAmelCase		(		_UpperCamelCase			,					_UpperCamelCase			,					_UpperCamelCase    ):






  """simple docstring"""



  if i >= h:
    return

  # If first element is smaller than the last then swap them
  if arr[i] > arr[h]:
    _lowercase			,					_lowercase:      Optional[Any]   			=  arr[h], arr[i]

  # If there are more than 2 elements in the array
  if h - i + 1 > 2:
    _lowercase:      Tuple   			=  (int)((h - i + 1) / 3    )

    # Recursively sort first 2/3 elements
    stooge(_UpperCamelCase			,					_UpperCamelCase			,					(h - t)    )

    # Recursively sort last 2/3 elements
    stooge(_UpperCamelCase			,					i + t			,					(_UpperCamelCase)    )

    # Recursively sort first 2/3 elements
    stooge(_UpperCamelCase			,					_UpperCamelCase			,					(h - t)    )


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