






import os
import tempfile
import unittest

from transformers import DistilBertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

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


if is_torch_available():
	import torch

	from transformers import (
	    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
	    DistilBertForMaskedLM,
	    DistilBertForMultipleChoice,
	    DistilBertForQuestionAnswering,
	    DistilBertForSequenceClassification,
	    DistilBertForTokenClassification,
	    DistilBertModel,
	)



class 							SCREAMING_SNAKE_CASE__		(       UpperCamelCase_		):





					"""simple docstring"""






					def __init__(      self  :						Optional[Any]							,	__A  :						List[str]							,	__A  :						Dict=1_3							,	__A  :						str=7							,	__A  :						int=True							,	__A  :						Union[str, Any]=True							,	__A  :						Union[str, Any]=False							,	__A  :						Tuple=True							,	__A  :						Any=9_9							,	__A  :						Any=3_2							,	__A  :						Dict=5							,	__A  :						Optional[int]=4							,	__A  :						Tuple=3_7							,	__A  :						Dict="gelu"							,	__A  :						Dict=0.1							,	__A  :						Any=0.1							,	__A  :						List[Any]=5_1_2							,	__A  :						Union[str, Any]=1_6							,	__A  :						Any=2							,	__A  :						List[str]=0.0_2							,	__A  :						Optional[Any]=3							,	__A  :						Union[str, Any]=4							,	__A  :						Tuple=None							,	):
						snake_case__				:   Tuple     =						parent
						snake_case__				:   Optional[Any]     =						batch_size
						snake_case__				:   Optional[Any]     =						seq_length
						snake_case__				:   str     =						is_training
						snake_case__				:   Any     =						use_input_mask
						snake_case__				:   Tuple     =						use_token_type_ids
						snake_case__				:   Optional[int]     =						use_labels
						snake_case__				:   Optional[int]     =						vocab_size
						snake_case__				:   Any     =						hidden_size
						snake_case__				:   List[str]     =						num_hidden_layers
						snake_case__				:   Optional[Any]     =						num_attention_heads
						snake_case__				:   Dict     =						intermediate_size
						snake_case__				:   Dict     =						hidden_act
						snake_case__				:   List[str]     =						hidden_dropout_prob
						snake_case__				:   int     =						attention_probs_dropout_prob
						snake_case__				:   Optional[int]     =						max_position_embeddings
						snake_case__				:   int     =						type_vocab_size
						snake_case__				:   int     =						type_sequence_label_size
						snake_case__				:   Dict     =						initializer_range
						snake_case__				:   List[Any]     =						num_labels
						snake_case__				:   str     =						num_choices
						snake_case__				:   Tuple     =						scope



					def  _lowercase  (      self  :						Union[str, Any] ):
						snake_case__				:   int     =						ids_tensor([self.batch_size, self.seq_length]							,	self.vocab_size )

						snake_case__				:   Dict     =						None
						if self.use_input_mask:
							snake_case__				:   Optional[int]     =						random_attention_mask([self.batch_size, self.seq_length] )

						snake_case__				:   Union[str, Any]     =						None
						snake_case__				:   Tuple     =						None
						snake_case__				:   Union[str, Any]     =						None
						if self.use_labels:
							snake_case__				:   Union[str, 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__				:   Optional[int]     =						ids_tensor([self.batch_size]							,	self.num_choices )

						snake_case__				:   Optional[int]     =						self.get_config()

						return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels



					def  _lowercase  (      self  :						Optional[Any] ):
						return DistilBertConfig(
						    vocab_size=self.vocab_size							,	dim=self.hidden_size							,	n_layers=self.num_hidden_layers							,	n_heads=self.num_attention_heads							,	hidden_dim=self.intermediate_size							,	hidden_act=self.hidden_act							,	dropout=self.hidden_dropout_prob							,	attention_dropout=self.attention_probs_dropout_prob							,	max_position_embeddings=self.max_position_embeddings							,	initializer_range=self.initializer_range							,	)



					def  _lowercase  (      self  :						Any							,	__A  :						Optional[int]							,	__A  :						str							,	__A  :						List[str]							,	__A  :						Tuple							,	__A  :						Union[str, Any]							,	__A  :						Any ):
						snake_case__				:   List[Any]     =						DistilBertModel(config=__A )
						model.to(__A )
						model.eval()
						snake_case__				:   str     =						model(__A							,	__A )
						snake_case__				:   Tuple     =						model(__A )
						self.parent.assertEqual(result.last_hidden_state.shape							,	(self.batch_size, self.seq_length, self.hidden_size) )



					def  _lowercase  (      self  :						Optional[Any]							,	__A  :						List[str]							,	__A  :						int							,	__A  :						List[Any]							,	__A  :						str							,	__A  :						int							,	__A  :						int ):
						snake_case__				:   str     =						DistilBertForMaskedLM(config=__A )
						model.to(__A )
						model.eval()
						snake_case__				:   List[Any]     =						model(__A							,	attention_mask=__A							,	labels=__A )
						self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.seq_length, self.vocab_size) )



					def  _lowercase  (      self  :						List[str]							,	__A  :						Tuple							,	__A  :						Optional[int]							,	__A  :						Optional[int]							,	__A  :						Tuple							,	__A  :						Dict							,	__A  :						Any ):
						snake_case__				:   str     =						DistilBertForQuestionAnswering(config=__A )
						model.to(__A )
						model.eval()
						snake_case__				:   Dict     =						model(
						    __A							,	attention_mask=__A							,	start_positions=__A							,	end_positions=__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  _lowercase  (      self  :						int							,	__A  :						str							,	__A  :						Optional[Any]							,	__A  :						Optional[Any]							,	__A  :						Optional[int]							,	__A  :						List[Any]							,	__A  :						Dict ):
						snake_case__				:   Optional[Any]     =						self.num_labels
						snake_case__				:   Dict     =						DistilBertForSequenceClassification(__A )
						model.to(__A )
						model.eval()
						snake_case__				:   List[str]     =						model(__A							,	attention_mask=__A							,	labels=__A )
						self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.num_labels) )



					def  _lowercase  (      self  :						Tuple							,	__A  :						Dict							,	__A  :						Optional[Any]							,	__A  :						int							,	__A  :						List[str]							,	__A  :						Tuple							,	__A  :						Any ):
						snake_case__				:   Optional[Any]     =						self.num_labels
						snake_case__				:   Tuple     =						DistilBertForTokenClassification(config=__A )
						model.to(__A )
						model.eval()

						snake_case__				:   Tuple     =						model(__A							,	attention_mask=__A							,	labels=__A )
						self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.seq_length, self.num_labels) )



					def  _lowercase  (      self  :						List[Any]							,	__A  :						str							,	__A  :						str							,	__A  :						Dict							,	__A  :						Optional[Any]							,	__A  :						Any							,	__A  :						Tuple ):
						snake_case__				:   Union[str, Any]     =						self.num_choices
						snake_case__				:   List[Any]     =						DistilBertForMultipleChoice(config=__A )
						model.to(__A )
						model.eval()
						snake_case__				:   str     =						input_ids.unsqueeze(1 ).expand(-1							,	self.num_choices							,	-1 ).contiguous()
						snake_case__				:   Optional[int]     =						input_mask.unsqueeze(1 ).expand(-1							,	self.num_choices							,	-1 ).contiguous()
						snake_case__				:   List[Any]     =						model(
						    __A							,	attention_mask=__A							,	labels=__A							,	)
						self.parent.assertEqual(result.logits.shape							,	(self.batch_size, self.num_choices) )






					def  _lowercase  (      self  :						str ):
						snake_case__				:   List[str]     =						self.prepare_config_and_inputs()
						((snake_case__),		(snake_case__),		(snake_case__),		(snake_case__),		(snake_case__),		(snake_case__))				:   Optional[Any]     =						config_and_inputs
						snake_case__				:   List[str]     =						{"input_ids": input_ids, "attention_mask": input_mask}
						return config, inputs_dict



@require_torch
class 							SCREAMING_SNAKE_CASE__		(       UpperCamelCase_				,     UpperCamelCase_				,     unittest.TestCase		):





					"""simple docstring"""






					a_			=	(
					    (
					        DistilBertModel,
					        DistilBertForMaskedLM,
					        DistilBertForMultipleChoice,
					        DistilBertForQuestionAnswering,
					        DistilBertForSequenceClassification,
					        DistilBertForTokenClassification,
					    )
					    if is_torch_available()
					    else None
					)
					a_			=	(
					    {
					        "feature-extraction": DistilBertModel,
					        "fill-mask": DistilBertForMaskedLM,
					        "question-answering": DistilBertForQuestionAnswering,
					        "text-classification": DistilBertForSequenceClassification,
					        "token-classification": DistilBertForTokenClassification,
					        "zero-shot": DistilBertForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)
					a_			=	True
					a_			=	True
					a_			=	True
					a_			=	True



					def  _lowercase  (      self  :						Tuple ):
						snake_case__				:   List[Any]     =						DistilBertModelTester(self )
						snake_case__				:   str     =						ConfigTester(self							,	config_class=__A							,	dim=3_7 )



					def  _lowercase  (      self  :						Optional[Any] ):
						self.config_tester.run_common_tests()



					def  _lowercase  (      self  :						Any ):
						snake_case__				:   Tuple     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_model(*__A )



					def  _lowercase  (      self  :						int ):
						snake_case__				:   Union[str, Any]     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_masked_lm(*__A )



					def  _lowercase  (      self  :						List[str] ):
						snake_case__				:   List[Any]     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_question_answering(*__A )



					def  _lowercase  (      self  :						str ):
						snake_case__				:   Any     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_sequence_classification(*__A )



					def  _lowercase  (      self  :						Union[str, Any] ):
						snake_case__				:   Union[str, Any]     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_token_classification(*__A )



					def  _lowercase  (      self  :						str ):
						snake_case__				:   Tuple     =						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_distilbert_for_multiple_choice(*__A )



					@slow
					def  _lowercase  (      self  :						List[Any] ):
						for model_name in DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							snake_case__				:   List[str]     =						DistilBertModel.from_pretrained(__A )
							self.assertIsNotNone(__A )






					@slow
					@require_torch_gpu
					def  _lowercase  (      self  :						Dict ):
						snake_case__,		snake_case__				:   int     =						self.model_tester.prepare_config_and_inputs_for_common()
						for model_class in self.all_model_classes:
							# BertForMultipleChoice behaves incorrectly in JIT environments.
							if model_class == DistilBertForMultipleChoice:
								return

							snake_case__				:   Any     =						True
							snake_case__				:   int     =						model_class(config=__A )

							snake_case__				:   Tuple     =						self._prepare_for_class(__A							,	__A )
							snake_case__				:   Any     =						torch.jit.trace(
							    __A							,	(inputs_dict["input_ids"].to("cpu" ), inputs_dict["attention_mask"].to("cpu" )) )

							with tempfile.TemporaryDirectory() as tmp:
								torch.jit.save(__A							,	os.path.join(__A							,	"traced_model.pt" ) )
								snake_case__				:   int     =						torch.jit.load(os.path.join(__A							,	"traced_model.pt" )							,	map_location=__A )
								loaded(inputs_dict["input_ids"].to(__A )							,	inputs_dict["attention_mask"].to(__A ) )



@require_torch
class 							SCREAMING_SNAKE_CASE__		(       unittest.TestCase		):





					"""simple docstring"""






					@slow
					def  _lowercase  (      self  :						Optional[Any] ):
						snake_case__				:   List[Any]     =						DistilBertModel.from_pretrained("distilbert-base-uncased" )
						snake_case__				:   int     =						torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]] )
						snake_case__				:   Optional[int]     =						torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] )
						with torch.no_grad():
							snake_case__				:   Optional[Any]     =						model(__A							,	attention_mask=__A )[0]
						snake_case__				:   Any     =						torch.Size((1, 1_1, 7_6_8) )
						self.assertEqual(output.shape							,	__A )
						snake_case__				:   Union[str, Any]     =						torch.tensor(
						    [[[-0.1_6_3_9, 0.3_2_9_9, 0.1_6_4_8], [-0.1_7_4_6, 0.3_2_8_9, 0.1_7_1_0], [-0.1_8_8_4, 0.3_3_5_7, 0.1_8_1_0]]] )

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











def   SCREAMING_SNAKE_CASE       (				snake_case_      :							list     ):
	if len(snake_case_     ) <= 1:
		return lst

	snake_case__				:   List[Any]     =						1

	while i < len(snake_case_     ):
		if lst[i - 1] <= lst[i]:
			i += 1
		else:
			snake_case__,		snake_case__				:   Tuple     =						lst[i], lst[i - 1]
			i -= 1
			if i == 0:
				snake_case__				:   Union[str, Any]     =						1

	return lst


if __name__ == "__main__":
	__lowerCamelCase      :    Dict   		=   input("""Enter numbers separated by a comma:\n""").strip()
	__lowerCamelCase      :    Tuple   		=   [int(item) for item in user_input.split(""",""")]
	print(gnome_sort(unsorted))



