




"""simple docstring"""




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        UpperCAmelCase_  :
		def __init__(		self							,		UpperCamelCase_							,		UpperCamelCase_=13							,		UpperCamelCase_=7							,		UpperCamelCase_=True							,		UpperCamelCase_=True							,		UpperCamelCase_=True							,		UpperCamelCase_=True							,		UpperCamelCase_=99							,		UpperCamelCase_=[1, 1, 2]							,		UpperCamelCase_=1							,		UpperCamelCase_=32							,		UpperCamelCase_=4							,		UpperCamelCase_=8							,		UpperCamelCase_=37							,		UpperCamelCase_="gelu_new"							,		UpperCamelCase_=0.1							,		UpperCamelCase_=0.1							,		UpperCamelCase_=0.0							,		UpperCamelCase_=5_12							,		UpperCamelCase_=3							,		UpperCamelCase_=0.0_2							,		UpperCamelCase_=3							,		UpperCamelCase_=4							,		UpperCamelCase_=None							,		UpperCamelCase_=False							,		)		->   int:
					__lowercase	:       Any				=   parent
					__lowercase	:       List[Any]				=   batch_size
					__lowercase	:       Optional[Any]				=   seq_length
					__lowercase	:       str				=   is_training
					__lowercase	:       str				=   use_input_mask
					__lowercase	:       Optional[int]				=   use_token_type_ids
					__lowercase	:       List[Any]				=   use_labels
					__lowercase	:       Dict				=   vocab_size
					__lowercase	:       List[str]				=   block_sizes
					__lowercase	:       Union[str, Any]				=   num_decoder_layers
					__lowercase	:       Union[str, Any]				=   d_model
					__lowercase	:       Dict				=   n_head
					__lowercase	:       int				=   d_head
					__lowercase	:       List[Any]				=   d_inner
					__lowercase	:       Any				=   hidden_act
					__lowercase	:       Any				=   hidden_dropout
					__lowercase	:       Union[str, Any]				=   attention_dropout
					__lowercase	:       Optional[Any]				=   activation_dropout
					__lowercase	:       Tuple				=   max_position_embeddings
					__lowercase	:       int				=   type_vocab_size
					__lowercase	:       Dict				=   2
					__lowercase	:       Optional[int]				=   num_labels
					__lowercase	:       Union[str, Any]				=   num_choices
					__lowercase	:       Optional[Any]				=   scope
					__lowercase	:       int				=   initializer_std

					# Used in the tests to check the size of the first attention layer
					__lowercase	:       str				=   n_head
					# Used in the tests to check the size of the first hidden state
					__lowercase	:       Dict				=   self.d_model
					# Used in the tests to check the number of output hidden states/attentions
					__lowercase	:       Optional[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:
								__lowercase	:       Union[str, Any]				=   self.num_hidden_layers + 2
		def 					_lowerCamelCase    (		self   )		->   Optional[int]:
					__lowercase	:       Union[str, Any]				=   ids_tensor([self.batch_size, self.seq_length]							,		self.vocab_size   )

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

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

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

					__lowercase	:       List[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   )		->   Optional[int]:
					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 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   str:
					__lowercase	:       Any				=   FunnelModel(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       List[str]				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )
					__lowercase	:       Optional[int]				=   model(__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )
					__lowercase	:       Tuple				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, self.seq_length, self.d_model)   )

					__lowercase	:       int				=   False
					__lowercase	:       Optional[Any]				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, self.seq_length, self.d_model)   )

					__lowercase	:       Any				=   False
					__lowercase	:       Tuple				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, self.seq_length, self.d_model)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   List[str]:
					__lowercase	:       Optional[Any]				=   FunnelBaseModel(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       List[str]				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )
					__lowercase	:       Optional[int]				=   model(__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )
					__lowercase	:       Any				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, 2, self.d_model)   )

					__lowercase	:       List[Any]				=   False
					__lowercase	:       List[Any]				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, 3, self.d_model)   )

					__lowercase	:       List[Any]				=   False
					__lowercase	:       List[Any]				=   model(__UpperCamelCase   )
					self.parent.assertEqual(result.last_hidden_state.shape							,		(self.batch_size, 2, self.d_model)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   Union[str, Any]:
					__lowercase	:       Union[str, Any]				=   self.num_labels
					__lowercase	:       Dict				=   FunnelForPreTraining(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       Tuple				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		labels=__UpperCamelCase   )
					self.parent.assertEqual(result.logits.shape							,		(self.batch_size, self.seq_length)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   int:
					__lowercase	:       List[Any]				=   FunnelForMaskedLM(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       Optional[int]				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		labels=__UpperCamelCase   )
					self.parent.assertEqual(result.logits.shape							,		(self.batch_size, self.seq_length, self.vocab_size)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   List[str]:
					__lowercase	:       int				=   self.num_labels
					__lowercase	:       List[Any]				=   FunnelForSequenceClassification(__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       Any				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		labels=__UpperCamelCase   )
					self.parent.assertEqual(result.logits.shape							,		(self.batch_size, self.num_labels)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   int:
					__lowercase	:       Optional[int]				=   self.num_choices
					__lowercase	:       Tuple				=   FunnelForMultipleChoice(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       Optional[int]				=   input_ids.unsqueeze(1   ).expand(-1							,		self.num_choices							,		-1   ).contiguous()
					__lowercase	:       Any				=   token_type_ids.unsqueeze(1   ).expand(-1							,		self.num_choices							,		-1   ).contiguous()
					__lowercase	:       Optional[int]				=   input_mask.unsqueeze(1   ).expand(-1							,		self.num_choices							,		-1   ).contiguous()
					__lowercase	:       Union[str, Any]				=   model(
					    __UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		labels=__UpperCamelCase							,		)
					self.parent.assertEqual(result.logits.shape							,		(self.batch_size, self.num_choices)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   Dict:
					__lowercase	:       Optional[int]				=   self.num_labels
					__lowercase	:       Union[str, Any]				=   FunnelForTokenClassification(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       List[str]				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		labels=__UpperCamelCase   )
					self.parent.assertEqual(result.logits.shape							,		(self.batch_size, self.seq_length, self.num_labels)   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_							,		)		->   Optional[Any]:
					__lowercase	:       str				=   FunnelForQuestionAnswering(config=__UpperCamelCase   )
					model.to(__UpperCamelCase   )
					model.eval()
					__lowercase	:       Any				=   model(
					    __UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase							,		start_positions=__UpperCamelCase							,		end_positions=__UpperCamelCase							,		)
					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   )		->   Union[str, Any]:
					__lowercase	:       Optional[int]				=   self.prepare_config_and_inputs()
					(
					    (
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,(
					    __lowercase     
					)	,     
					)	:       Tuple				=   config_and_inputs
					__lowercase	:       List[Any]				=   {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
					return config, inputs_dict


@require_torch
class        UpperCAmelCase_  (	lowercase_ ,			lowercase_ ,			unittest.TestCase						):
		UpperCamelCase									=False
		UpperCamelCase									=False
		UpperCamelCase									=(
		    (
		        FunnelModel,
		        FunnelForMaskedLM,
		        FunnelForPreTraining,
		        FunnelForQuestionAnswering,
		        FunnelForTokenClassification,
		    )
		    if is_torch_available()
		    else ()
		)
		UpperCamelCase									=(
		    {
		        "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 					_lowerCamelCase    (		self							,		UpperCamelCase_							,		UpperCamelCase_							,		UpperCamelCase_=False   )		->   Optional[Any]:
					__lowercase	:       List[str]				=   super()._prepare_for_class(__UpperCamelCase							,		__UpperCamelCase							,		return_labels=__UpperCamelCase   )

					if return_labels:
								if model_class in get_values(__UpperCamelCase   ):
											__lowercase	:       str				=   torch.zeros(
											    (self.model_tester.batch_size, self.model_tester.seq_length)							,		dtype=torch.long							,		device=__UpperCamelCase   )
					return inputs_dict
		def 					_lowerCamelCase    (		self   )		->   int:
					__lowercase	:       Optional[Any]				=   FunnelModelTester(self   )
					__lowercase	:       Union[str, Any]				=   ConfigTester(self							,		config_class=__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   Optional[Any]:
					self.config_tester.run_common_tests()
		def 					_lowerCamelCase    (		self   )		->   Any:
					__lowercase	:       str				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   Dict:
					__lowercase	:       int				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_pretraining(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   Any:
					__lowercase	:       Optional[int]				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_masked_lm(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   List[str]:
					__lowercase	:       List[str]				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_token_classification(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   Dict:
					__lowercase	:       Optional[int]				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_question_answering(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_   )		->   str:
					if hasattr(__UpperCamelCase							,		'''weight'''   ) and module.weight is not None:
								module.weight.data.fill_(3   )
					if hasattr(__UpperCamelCase							,		'''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(__UpperCamelCase							,		__UpperCamelCase   ) and getattr(__UpperCamelCase							,		__UpperCamelCase   ) is not None:
											__lowercase	:       List[str]				=   getattr(__UpperCamelCase							,		__UpperCamelCase   )
											weight.data.fill_(3   )


@require_torch
class        UpperCAmelCase_  (	lowercase_ ,			unittest.TestCase						):
		UpperCamelCase									=False
		UpperCamelCase									=False
		UpperCamelCase									=(
		    (FunnelBaseModel, FunnelForMultipleChoice, FunnelForSequenceClassification) if is_torch_available() else ()
		)
		def 					_lowerCamelCase    (		self   )		->   Optional[Any]:
					__lowercase	:       str				=   FunnelModelTester(self							,		base=__UpperCamelCase   )
					__lowercase	:       Dict				=   ConfigTester(self							,		config_class=__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   Any:
					self.config_tester.run_common_tests()
		def 					_lowerCamelCase    (		self   )		->   Any:
					__lowercase	:       Any				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_base_model(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   int:
					__lowercase	:       Tuple				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_sequence_classification(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   str:
					__lowercase	:       int				=   self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_multiple_choice(*__UpperCamelCase   )
		def 					_lowerCamelCase    (		self   )		->   str:
					__lowercase	,__lowercase	:       List[str]				=   self.model_tester.prepare_config_and_inputs_for_common()
					__lowercase	:       Union[str, Any]				=   True

					for model_class in self.all_model_classes:
								if model_class.__name__ == "FunnelBaseModel":
											continue
								__lowercase	:       Dict				=   model_class(__UpperCamelCase   )
								model.to(__UpperCamelCase   )
								model.train()
								__lowercase	:       Union[str, Any]				=   self._prepare_for_class(__UpperCamelCase							,		__UpperCamelCase							,		return_labels=__UpperCamelCase   )
								__lowercase	:       int				=   model(**__UpperCamelCase   ).loss
								loss.backward()
		def 					_lowerCamelCase    (		self							,		UpperCamelCase_   )		->   Optional[int]:
					if hasattr(__UpperCamelCase							,		'''weight'''   ) and module.weight is not None:
								module.weight.data.fill_(3   )
					if hasattr(__UpperCamelCase							,		'''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(__UpperCamelCase							,		__UpperCamelCase   ) and getattr(__UpperCamelCase							,		__UpperCamelCase   ) is not None:
											__lowercase	:       Optional[Any]				=   getattr(__UpperCamelCase							,		__UpperCamelCase   )
											weight.data.fill_(3   )


@require_torch
@require_sentencepiece
@require_tokenizers
class        UpperCAmelCase_  (	unittest.TestCase						):
		def 					_lowerCamelCase    (		self   )		->   Optional[int]:
					__lowercase	:       int				=   13
					__lowercase	:       List[Any]				=   7
					__lowercase	:       Optional[Any]				=   torch.arange(0							,		batch_size * sequence_length   ).long().reshape(__UpperCamelCase							,		__UpperCamelCase   )
					__lowercase	:       Tuple				=   [0, 1, 2, 3, 4, 5, 6, 4, 1, 3, 5, 0, 1]
					__lowercase	:       Tuple				=   torch.tensor([[2] + [0] * a + [1] * (sequence_length - a - 1) for a in lengths]   )

					__lowercase	:       List[Any]				=   FunnelModel.from_pretrained('''sgugger/funnel-random-tiny'''   )
					__lowercase	:       List[Any]				=   model(__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )[0].abs()

					__lowercase	:       Tuple				=   torch.tensor(23_44.83_52   )
					__lowercase	:       str				=   torch.tensor(0.8_0_5_2   )
					self.assertTrue(torch.allclose(output.sum()							,		__UpperCamelCase							,		atol=1E-4   )   )
					self.assertTrue(torch.allclose(output.mean()							,		__UpperCamelCase							,		atol=1E-4   )   )

					__lowercase	:       Optional[Any]				=   torch.tensor([[1] * 7, [1] * 4 + [0] * 3] * 6 + [[0, 1, 1, 0, 0, 1, 1]]   )
					__lowercase	:       int				=   model(__UpperCamelCase							,		attention_mask=__UpperCamelCase							,		token_type_ids=__UpperCamelCase   )[0].abs()

					__lowercase	:       Optional[int]				=   torch.tensor(23_43.84_25   )
					__lowercase	:       Any				=   torch.tensor(0.8_0_4_9   )
					self.assertTrue(torch.allclose(output.sum()							,		__UpperCamelCase							,		atol=1E-4   )   )
					self.assertTrue(torch.allclose(output.mean()							,		__UpperCamelCase							,		atol=1E-4   )   )
		@slow
		def 					_lowerCamelCase    (		self   )		->   List[str]:
					__lowercase	:       str				=   FunnelTokenizer.from_pretrained('''huggingface/funnel-small'''   )
					__lowercase	:       Dict				=   FunnelModel.from_pretrained('''huggingface/funnel-small'''   )
					__lowercase	:       Optional[int]				=   tokenizer('''Hello! I am the Funnel Transformer model.'''							,		return_tensors='''pt'''   )
					__lowercase	:       Any				=   model(**__UpperCamelCase   )[0]

					__lowercase	:       Union[str, Any]				=   torch.tensor(2_3_5.7_2_4_6   )
					__lowercase	:       Tuple				=   torch.tensor(0.0_2_5_6   )
					self.assertTrue(torch.allclose(output.sum()							,		__UpperCamelCase							,		atol=1E-4   )   )
					self.assertTrue(torch.allclose(output.mean()							,		__UpperCamelCase							,		atol=1E-4   )   )






"""simple docstring"""




def       __UpperCAmelCase      (				__UpperCamelCase					):
			if len(__UpperCamelCase					) <= 1:
						return data
			else:
						return [
						    *quick_sort([e for e in data[1:] if e <= data[0]]					),
						    data[0],
						    *quick_sort([e for e in data[1:] if e > data[0]]					),
						]


if __name__ == "__main__":
			import doctest

			doctest.testmod()



