






"""simple docstring"""




from __future__ import annotations

import unittest

from transformers import AlbertConfig, is_tf_available
from transformers.models.auto import get_values
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 import TF_MODEL_FOR_PRETRAINING_MAPPING
  from transformers.models.albert.modeling_tf_albert import (
      TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFAlbertForMaskedLM,
      TFAlbertForMultipleChoice,
      TFAlbertForPreTraining,
      TFAlbertForQuestionAnswering,
      TFAlbertForSequenceClassification,
      TFAlbertForTokenClassification,
      TFAlbertModel,
  )
class 							A_      :






 '''simple docstring'''




 def __init__(		self							,					_A							,					_A=13							,					_A=7							,					_A=True							,					_A=True							,					_A=True							,					_A=True							,					_A=99							,					_A=16							,					_A=32							,					_A=2							,					_A=4							,					_A=37							,					_A="gelu"							,					_A=0.1							,					_A=0.1							,					_A=512							,					_A=16							,					_A=2							,					_A=0.02							,					_A=3							,					_A=4							,					_A=None							,					)	->						List[str]:

     """simple docstring"""



     _UpperCAmelCase			: Tuple     					=			parent
     _UpperCAmelCase			: Dict     					=			13
     _UpperCAmelCase			: List[Any]     					=			7
     _UpperCAmelCase			: str     					=			True
     _UpperCAmelCase			: Dict     					=			True
     _UpperCAmelCase			: Optional[Any]     					=			True
     _UpperCAmelCase			: Union[str, Any]     					=			True
     _UpperCAmelCase			: Any     					=			99
     _UpperCAmelCase			: Any     					=			16
     _UpperCAmelCase			: str     					=			32
     _UpperCAmelCase			: Any     					=			2
     _UpperCAmelCase			: Optional[int]     					=			4
     _UpperCAmelCase			: Optional[int]     					=			37
     _UpperCAmelCase			: Optional[Any]     					=			"gelu"
     _UpperCAmelCase			: int     					=			0.1
     _UpperCAmelCase			: List[str]     					=			0.1
     _UpperCAmelCase			: Optional[int]     					=			512
     _UpperCAmelCase			: Union[str, Any]     					=			16
     _UpperCAmelCase			: Optional[int]     					=			2
     _UpperCAmelCase			: Tuple     					=			0.02
     _UpperCAmelCase			: str     					=			3
     _UpperCAmelCase			: Any     					=			4
     _UpperCAmelCase			: int     					=			None


 def 	snake_case__			(		self)	->						List[str]:

     """simple docstring"""



     _UpperCAmelCase			: Tuple     					=			ids_tensor([self.batch_size, self.seq_length]							,					self.vocab_size)

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

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

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

     _UpperCAmelCase			: Optional[Any]     					=			AlbertConfig(
         vocab_size=self.vocab_size							,					hidden_size=self.hidden_size							,					embedding_size=self.embedding_size							,					num_hidden_layers=self.num_hidden_layers							,					num_attention_heads=self.num_attention_heads							,					intermediate_size=self.intermediate_size							,					hidden_act=self.hidden_act							,					hidden_dropout_prob=self.hidden_dropout_prob							,					attention_probs_dropout_prob=self.attention_probs_dropout_prob							,					max_position_embeddings=self.max_position_embeddings							,					type_vocab_size=self.type_vocab_size							,					initializer_range=self.initializer_range							,					)

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


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						str:

     """simple docstring"""



     _UpperCAmelCase			: Dict     					=			TFAlbertModel(config=SCREAMING_SNAKE_CASE__)
     # inputs = {'input_ids': input_ids,
     #           'attention_mask': input_mask,
     #           'token_type_ids': token_type_ids}
     # sequence_output, pooled_output = model(**inputs)
     _UpperCAmelCase			: int     					=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     _UpperCAmelCase			: str     					=			model(SCREAMING_SNAKE_CASE__)

     _UpperCAmelCase			: Any     					=			[input_ids, input_mask]
     _UpperCAmelCase			: Tuple     					=			model(SCREAMING_SNAKE_CASE__)

     _UpperCAmelCase			: str     					=			model(SCREAMING_SNAKE_CASE__)

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


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						Tuple:

     """simple docstring"""



     _UpperCAmelCase			: Any     					=			self.num_labels
     _UpperCAmelCase			: Union[str, Any]     					=			TFAlbertForPreTraining(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: Dict     					=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     _UpperCAmelCase			: Tuple     					=			model(SCREAMING_SNAKE_CASE__)
     self.parent.assertEqual(result.prediction_logits.shape							,					(self.batch_size, self.seq_length, self.vocab_size))
     self.parent.assertEqual(result.sop_logits.shape							,					(self.batch_size, self.num_labels))


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						Optional[Any]:

     """simple docstring"""



     _UpperCAmelCase			: Dict     					=			TFAlbertForMaskedLM(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: List[str]     					=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     _UpperCAmelCase			: Union[str, Any]     					=			model(SCREAMING_SNAKE_CASE__)
     self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length, self.vocab_size))


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						Any:

     """simple docstring"""



     _UpperCAmelCase			: Optional[int]     					=			self.num_labels
     _UpperCAmelCase			: Optional[int]     					=			TFAlbertForSequenceClassification(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: Union[str, Any]     					=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     _UpperCAmelCase			: int     					=			model(SCREAMING_SNAKE_CASE__)
     self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.num_labels))


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						str:

     """simple docstring"""



     _UpperCAmelCase			: Optional[int]     					=			TFAlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: Union[str, Any]     					=			{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
     _UpperCAmelCase			: List[Any]     					=			model(SCREAMING_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 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						Tuple:

     """simple docstring"""



     _UpperCAmelCase			: Any     					=			self.num_choices
     _UpperCAmelCase			: Dict     					=			TFAlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: Optional[int]     					=			tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					1)							,					(1, self.num_choices, 1))
     _UpperCAmelCase			: int     					=			tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					1)							,					(1, self.num_choices, 1))
     _UpperCAmelCase			: Union[str, Any]     					=			tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					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			: Optional[Any]     					=			model(SCREAMING_SNAKE_CASE__)
     self.parent.assertListEqual(list(result['''logits'''].shape)							,					[self.batch_size, self.num_choices])


 def 	snake_case__			(		self							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A							,					_A)	->						Optional[Any]:

     """simple docstring"""



     _UpperCAmelCase			: List[str]     					=			self.num_labels
     _UpperCAmelCase			: str     					=			TFAlbertForTokenClassification(config=SCREAMING_SNAKE_CASE__)
     _UpperCAmelCase			: Tuple     					=			{
         "input_ids": input_ids,
         "attention_mask": input_mask,
         "token_type_ids": token_type_ids,
     }
     _UpperCAmelCase			: int     					=			model(SCREAMING_SNAKE_CASE__)
     self.parent.assertListEqual(list(result['''logits'''].shape)							,					[self.batch_size, self.seq_length, self.num_labels])


 def 	snake_case__			(		self)	->						List[Any]:

     """simple docstring"""



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



@require_tf
class 							A_      (  _a	,				_a	,				unittest.TestCase     ):






 '''simple docstring'''




 _SCREAMING_SNAKE_CASE							:     Tuple	=   (
     (
         TFAlbertModel,
         TFAlbertForPreTraining,
         TFAlbertForMaskedLM,
         TFAlbertForSequenceClassification,
         TFAlbertForQuestionAnswering,
         TFAlbertForTokenClassification,
         TFAlbertForMultipleChoice,
     )
     if is_tf_available()
     else ()
 )
 _SCREAMING_SNAKE_CASE							:     Optional[Any]	=   (
     {
         '''feature-extraction''': TFAlbertModel,
         '''fill-mask''': TFAlbertForMaskedLM,
         '''question-answering''': TFAlbertForQuestionAnswering,
         '''text-classification''': TFAlbertForSequenceClassification,
         '''token-classification''': TFAlbertForTokenClassification,
         '''zero-shot''': TFAlbertForSequenceClassification,
     }
     if is_tf_available()
     else {}
 )
 _SCREAMING_SNAKE_CASE							:     List[Any]	=   False
 _SCREAMING_SNAKE_CASE							:     str	=   False


 def 	snake_case__			(		self							,					_A							,					_A							,					_A=False)	->						Optional[Any]:

     """simple docstring"""



     _UpperCAmelCase			: Any     					=			super()._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__							,					return_labels=SCREAMING_SNAKE_CASE__)

     if return_labels:
         if model_class in get_values(SCREAMING_SNAKE_CASE__):
             _UpperCAmelCase			: str     					=			tf.zeros(self.model_tester.batch_size							,					dtype=tf.intaa)

     return inputs_dict


 def 	snake_case__			(		self)	->						Optional[int]:

     """simple docstring"""



     _UpperCAmelCase			: int     					=			TFAlbertModelTester(self)
     _UpperCAmelCase			: Dict     					=			ConfigTester(self							,					config_class=SCREAMING_SNAKE_CASE__							,					hidden_size=37)


 def 	snake_case__			(		self)	->						str:

     """simple docstring"""



     self.config_tester.run_common_tests()


 def 	snake_case__			(		self)	->						Dict:

     """simple docstring"""



     _UpperCAmelCase			: int     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_model(*SCREAMING_SNAKE_CASE__)


 def 	snake_case__			(		self)	->						Optional[int]:

     """simple docstring"""



     _UpperCAmelCase			: int     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_for_pretraining(*SCREAMING_SNAKE_CASE__)


 def 	snake_case__			(		self)	->						List[Any]:

     """simple docstring"""



     _UpperCAmelCase			: List[Any]     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_for_masked_lm(*SCREAMING_SNAKE_CASE__)


 def 	snake_case__			(		self)	->						Union[str, Any]:

     """simple docstring"""



     _UpperCAmelCase			: Any     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_for_multiple_choice(*SCREAMING_SNAKE_CASE__)


 def 	snake_case__			(		self)	->						Tuple:

     """simple docstring"""



     _UpperCAmelCase			: str     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_for_sequence_classification(*SCREAMING_SNAKE_CASE__)


 def 	snake_case__			(		self)	->						Any:

     """simple docstring"""



     _UpperCAmelCase			: Optional[int]     					=			self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_albert_for_question_answering(*SCREAMING_SNAKE_CASE__)


 @slow
 def 	snake_case__			(		self)	->						Tuple:

     """simple docstring"""



     for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _UpperCAmelCase			: Tuple     					=			TFAlbertModel.from_pretrained(SCREAMING_SNAKE_CASE__)
         self.assertIsNotNone(SCREAMING_SNAKE_CASE__)



@require_tf
class 							A_      (  unittest.TestCase     ):






 '''simple docstring'''




 @slow
 def 	snake_case__			(		self)	->						Optional[int]:

     """simple docstring"""



     _UpperCAmelCase			: List[str]     					=			TFAlbertForPreTraining.from_pretrained('''albert-base-v2''')
     _UpperCAmelCase			: int     					=			tf.constant([[0, 1, 2, 3, 4, 5]])
     _UpperCAmelCase			: List[str]     					=			model(SCREAMING_SNAKE_CASE__)[0]

     _UpperCAmelCase			: Any     					=			[1, 6, 30000]
     self.assertEqual(output.shape							,					SCREAMING_SNAKE_CASE__)

     _UpperCAmelCase			: Optional[int]     					=			tf.constant(
         [
             [
                 [4.595668, 0.74462754, -1.818147],
                 [4.5954347, 0.7454184, -1.8188258],
                 [4.5954905, 0.7448235, -1.8182316],
             ]
         ])
     tf.debugging.assert_near(output[:, :3, :3]							,					SCREAMING_SNAKE_CASE__							,					atol=1e-4)












def        _lowerCamelCase		(  __A      :							list	) ->   list:
    _UpperCAmelCase			: Dict     					=			1.3
    _UpperCAmelCase			: Any     					=			len(__A	)
    _UpperCAmelCase			: List[Any]     					=			False

    while not completed:
        # Update the gap value for a next comb
        _UpperCAmelCase			: Optional[Any]     					=			int(gap / shrink_factor	)
        if gap <= 1:
            _UpperCAmelCase			: Any     					=			True

        _UpperCAmelCase			: Optional[Any]     					=			0
        while index + gap < len(__A	):
            if data[index] > data[index + gap]:
                # Swap values
                _UpperCAmelCase					,	_UpperCAmelCase			: Union[str, Any]     					=			data[index + gap], data[index]
                _UpperCAmelCase			: Any     					=			False
            index += 1

    return data


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  SCREAMING_SNAKE_CASE								=  input('Enter numbers separated by a comma:\n').strip()
  SCREAMING_SNAKE_CASE								=  [int(item) for item in user_input.split(',')]
  print(comb_sort(unsorted))




