


'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import DistilBertConfig, is_tf_available
from transformers.testing_utils import require_tf, slow

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.models.distilbert.modeling_tf_distilbert import (
          TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFDistilBertForMaskedLM,
          TFDistilBertForMultipleChoice,
          TFDistilBertForQuestionAnswering,
          TFDistilBertForSequenceClassification,
          TFDistilBertForTokenClassification,
          TFDistilBertModel,
      )



class 			a       :


     """simple docstring"""






     def __init__(       self  :	List[str]							,				snake_case  :	Any							,				)		->							Tuple:
          __UpperCAmelCase			:				str													=    parent
          __UpperCAmelCase			:				Dict													=    13
          __UpperCAmelCase			:				str													=    7
          __UpperCAmelCase			:				Optional[int]													=    True
          __UpperCAmelCase			:				Optional[Any]													=    True
          __UpperCAmelCase			:				Union[str, Any]													=    False
          __UpperCAmelCase			:				Optional[Any]													=    True
          __UpperCAmelCase			:				Dict													=    99
          __UpperCAmelCase			:				Union[str, Any]													=    32
          __UpperCAmelCase			:				str													=    2
          __UpperCAmelCase			:				Tuple													=    4
          __UpperCAmelCase			:				Tuple													=    37
          __UpperCAmelCase			:				List[str]													=    '''gelu'''
          __UpperCAmelCase			:				int													=    0.1
          __UpperCAmelCase			:				int													=    0.1
          __UpperCAmelCase			:				List[Any]													=    512
          __UpperCAmelCase			:				Tuple													=    16
          __UpperCAmelCase			:				Any													=    2
          __UpperCAmelCase			:				Optional[int]													=    0.02
          __UpperCAmelCase			:				int													=    3
          __UpperCAmelCase			:				Dict													=    4
          __UpperCAmelCase			:				Any													=    None

     def 				lowerCamelCase__				(       self  :	List[Any]    )		->							List[Any]:
          __UpperCAmelCase			:				int													=    ids_tensor([self.batch_size, self.seq_length]							,				self.vocab_size    )

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

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

          __UpperCAmelCase			:				Tuple													=    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							,				)

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

     def 				lowerCamelCase__				(       self  :	Union[str, Any]							,				snake_case  :	Optional[int]							,				snake_case  :	str							,				snake_case  :	List[Any]							,				snake_case  :	List[Any]							,				snake_case  :	Union[str, Any]							,				snake_case  :	str    )		->							List[str]:
          __UpperCAmelCase			:				int													=    TFDistilBertModel(config=snake_case    )
          __UpperCAmelCase			:				Dict													=    {'''input_ids''': input_ids, '''attention_mask''': input_mask}

          __UpperCAmelCase			:				Optional[Any]													=    model(snake_case    )

          __UpperCAmelCase			:				int													=    [input_ids, input_mask]

          __UpperCAmelCase			:				int													=    model(snake_case    )

          self.parent.assertEqual(result.last_hidden_state.shape							,				(self.batch_size, self.seq_length, self.hidden_size)    )

     def 				lowerCamelCase__				(       self  :	Any							,				snake_case  :	str							,				snake_case  :	Dict							,				snake_case  :	Optional[Any]							,				snake_case  :	int							,				snake_case  :	int							,				snake_case  :	int    )		->							Any:
          __UpperCAmelCase			:				Dict													=    TFDistilBertForMaskedLM(config=snake_case    )
          __UpperCAmelCase			:				int													=    {'''input_ids''': input_ids, '''attention_mask''': input_mask}
          __UpperCAmelCase			:				Tuple													=    model(snake_case    )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.seq_length, self.vocab_size)    )

     def 				lowerCamelCase__				(       self  :	Tuple							,				snake_case  :	int							,				snake_case  :	Optional[Any]							,				snake_case  :	Union[str, Any]							,				snake_case  :	List[str]							,				snake_case  :	List[str]							,				snake_case  :	Any    )		->							List[Any]:
          __UpperCAmelCase			:				List[str]													=    TFDistilBertForQuestionAnswering(config=snake_case    )
          __UpperCAmelCase			:				Union[str, Any]													=    {
              '''input_ids''': input_ids,
              '''attention_mask''': input_mask,
          }
          __UpperCAmelCase			:				Union[str, Any]													=    model(snake_case    )
          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  :	Any							,				snake_case  :	int							,				snake_case  :	str							,				snake_case  :	str							,				snake_case  :	List[Any]							,				snake_case  :	str							,				snake_case  :	int    )		->							str:
          __UpperCAmelCase			:				int													=    self.num_labels
          __UpperCAmelCase			:				Optional[Any]													=    TFDistilBertForSequenceClassification(snake_case    )
          __UpperCAmelCase			:				int													=    {'''input_ids''': input_ids, '''attention_mask''': input_mask}
          __UpperCAmelCase			:				Tuple													=    model(snake_case    )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.num_labels)    )

     def 				lowerCamelCase__				(       self  :	int							,				snake_case  :	str							,				snake_case  :	Optional[Any]							,				snake_case  :	Optional[int]							,				snake_case  :	Any							,				snake_case  :	int							,				snake_case  :	Union[str, Any]    )		->							List[str]:
          __UpperCAmelCase			:				str													=    self.num_choices
          __UpperCAmelCase			:				List[str]													=    TFDistilBertForMultipleChoice(snake_case    )
          __UpperCAmelCase			:				Any													=    tf.tile(tf.expand_dims(snake_case							,				1    )							,				(1, self.num_choices, 1)    )
          __UpperCAmelCase			:				List[Any]													=    tf.tile(tf.expand_dims(snake_case							,				1    )							,				(1, self.num_choices, 1)    )
          __UpperCAmelCase			:				Optional[int]													=    {
              '''input_ids''': multiple_choice_inputs_ids,
              '''attention_mask''': multiple_choice_input_mask,
          }
          __UpperCAmelCase			:				Optional[Any]													=    model(snake_case    )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.num_choices)    )

     def 				lowerCamelCase__				(       self  :	List[str]							,				snake_case  :	int							,				snake_case  :	Optional[Any]							,				snake_case  :	List[Any]							,				snake_case  :	int							,				snake_case  :	str							,				snake_case  :	List[str]    )		->							List[Any]:
          __UpperCAmelCase			:				int													=    self.num_labels
          __UpperCAmelCase			:				Tuple													=    TFDistilBertForTokenClassification(snake_case    )
          __UpperCAmelCase			:				Dict													=    {'''input_ids''': input_ids, '''attention_mask''': input_mask}
          __UpperCAmelCase			:				Tuple													=    model(snake_case    )
          self.parent.assertEqual(result.logits.shape							,				(self.batch_size, self.seq_length, self.num_labels)    )






     def 				lowerCamelCase__				(       self  :	Dict    )		->							Union[str, Any]:
          __UpperCAmelCase			:				str													=    self.prepare_config_and_inputs()
          ((__UpperCAmelCase)							,     (__UpperCAmelCase)							,     (__UpperCAmelCase)							,     (__UpperCAmelCase)							,     (__UpperCAmelCase)							,     (__UpperCAmelCase))			:				Optional[int]													=    config_and_inputs
          __UpperCAmelCase			:				List[Any]													=    {'''input_ids''': input_ids, '''attention_mask''': input_mask}
          return config, inputs_dict



@require_tf
class 			a       (	UpperCamelCase__			,						UpperCamelCase__			,						unittest.TestCase ):


     """simple docstring"""






     SCREAMING_SNAKE_CASE :				Tuple							     =     (
         (
             TFDistilBertModel,
             TFDistilBertForMaskedLM,
             TFDistilBertForQuestionAnswering,
             TFDistilBertForSequenceClassification,
             TFDistilBertForTokenClassification,
             TFDistilBertForMultipleChoice,
         )
         if is_tf_available()
         else None
     )
     SCREAMING_SNAKE_CASE :				Optional[Any]							     =     (
         {
             """feature-extraction""": TFDistilBertModel,
             """fill-mask""": TFDistilBertForMaskedLM,
             """question-answering""": TFDistilBertForQuestionAnswering,
             """text-classification""": TFDistilBertForSequenceClassification,
             """token-classification""": TFDistilBertForTokenClassification,
             """zero-shot""": TFDistilBertForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     SCREAMING_SNAKE_CASE :				Any							     =     False
     SCREAMING_SNAKE_CASE :				Optional[Any]							     =     False

     def 				lowerCamelCase__				(       self  :	Any    )		->							Tuple:
          __UpperCAmelCase			:				List[Any]													=    TFDistilBertModelTester(self    )
          __UpperCAmelCase			:				List[str]													=    ConfigTester(self							,				config_class=snake_case							,				dim=37    )

     def 				lowerCamelCase__				(       self  :	List[Any]    )		->							int:
          self.config_tester.run_common_tests()

     def 				lowerCamelCase__				(       self  :	List[str]    )		->							Any:
          __UpperCAmelCase			:				Union[str, Any]													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_model(*snake_case    )

     def 				lowerCamelCase__				(       self  :	List[str]    )		->							List[Any]:
          __UpperCAmelCase			:				Any													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_for_masked_lm(*snake_case    )

     def 				lowerCamelCase__				(       self  :	Tuple    )		->							Dict:
          __UpperCAmelCase			:				Optional[int]													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_for_question_answering(*snake_case    )

     def 				lowerCamelCase__				(       self  :	List[str]    )		->							str:
          __UpperCAmelCase			:				List[Any]													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_for_sequence_classification(*snake_case    )

     def 				lowerCamelCase__				(       self  :	List[str]    )		->							Tuple:
          __UpperCAmelCase			:				Tuple													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_for_multiple_choice(*snake_case    )

     def 				lowerCamelCase__				(       self  :	Optional[int]    )		->							Any:
          __UpperCAmelCase			:				Optional[int]													=    self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_distilbert_for_token_classification(*snake_case    )






     @slow
     def 				lowerCamelCase__				(       self  :	List[Any]    )		->							int:
          for model_name in list(TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]    ):
               __UpperCAmelCase			:				Tuple													=    TFDistilBertModel.from_pretrained(snake_case    )
               self.assertIsNotNone(snake_case    )



@require_tf
class 			a       (	unittest.TestCase ):


     """simple docstring"""






     @slow
     def 				lowerCamelCase__				(       self  :	Union[str, Any]    )		->							Union[str, Any]:
          __UpperCAmelCase			:				Any													=    TFDistilBertModel.from_pretrained('''distilbert-base-uncased'''    )
          __UpperCAmelCase			:				Union[str, Any]													=    tf.constant([[0, 1, 2, 3, 4, 5]]    )
          __UpperCAmelCase			:				Dict													=    model(snake_case    )[0]

          __UpperCAmelCase			:				Any													=    [1, 6, 768]
          self.assertEqual(output.shape							,				snake_case    )

          __UpperCAmelCase			:				Optional[int]													=    tf.constant(
              [
                  [
                      [0.19_261_885, -0.13_732_955, 0.4_119_799],
                      [0.22_150_156, -0.07_422_661, 0.39_037_204],
                      [0.22_756_018, -0.0_896_414, 0.3_701_467],
                  ]
              ]    )
          tf.debugging.assert_near(output[:, :3, :3]							,				snake_case							,				atol=1E-4    )



'''simple docstring'''



def 			_a			(		_lowercase      :			List[str]						):





     '''simple docstring'''






     __UpperCAmelCase			:				int													=    len(_lowercase						)
     while cur > 1:
          # Find the maximum number in arr
          __UpperCAmelCase			:				Union[str, Any]													=    arr.index(max(arr[0:cur]						)						)
          # Reverse from 0 to mi
          __UpperCAmelCase			:				Any													=    arr[mi::-1] + arr[mi + 1 : len(_lowercase						)]
          # Reverse whole list
          __UpperCAmelCase			:				List[str]													=    arr[cur - 1 :: -1] + arr[cur : len(_lowercase						)]
          cur -= 1
     return arr


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