






"""simple docstring"""



from __future__ import annotations

import os
import tempfile
import unittest

from transformers import ConvBertConfig, 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 import (
						    TFConvBertForMaskedLM,
						    TFConvBertForMultipleChoice,
						    TFConvBertForQuestionAnswering,
						    TFConvBertForSequenceClassification,
						    TFConvBertForTokenClassification,
						    TFConvBertModel,
						)






class 							__SCREAMING_SNAKE_CASE						:


							def __init__(			self      :						List[Any]			,    snake_case      :						Union[str, Any]			,    snake_case      :						Union[str, Any]=13			,    snake_case      :						int=7			,    snake_case      :						Tuple=True			,    snake_case      :						int=True			,    snake_case      :						Optional[Any]=True			,    snake_case      :						List[str]=True			,    snake_case      :						Optional[int]=99			,    snake_case      :						Any=32			,    snake_case      :						int=2			,    snake_case      :						Tuple=4			,    snake_case      :						Any=37			,    snake_case      :						List[Any]="gelu"			,    snake_case      :						Optional[Any]=0.1			,    snake_case      :						Optional[Any]=0.1			,    snake_case      :						Optional[Any]=512			,    snake_case      :						Optional[Any]=16			,    snake_case      :						List[str]=2			,    snake_case      :						Union[str, Any]=0.02			,    snake_case      :						Optional[Any]=3			,    snake_case      :						Tuple=4			,    snake_case      :						str=None			,    ):
													'''simple docstring'''





													A__						:  List[Any]		  =  parent
													A__						:  List[Any]		  =  13
													A__						:  Any		  =  7
													A__						:  str		  =  True
													A__						:  int		  =  True
													A__						:  Optional[Any]		  =  True
													A__						:  Optional[Any]		  =  True
													A__						:  str		  =  99
													A__						:  str		  =  384
													A__						:  str		  =  2
													A__						:  int		  =  4
													A__						:  Union[str, Any]		  =  37
													A__						:  int		  =  """gelu"""
													A__						:  List[str]		  =  0.1
													A__						:  int		  =  0.1
													A__						:  List[Any]		  =  512
													A__						:  Any		  =  16
													A__						:  Union[str, Any]		  =  2
													A__						:  Optional[Any]		  =  0.02
													A__						:  Optional[int]		  =  3
													A__						:  int		  =  4
													A__						:  Any		  =  128
													A__						:  Optional[Any]		  =  2
													A__						:  Optional[int]		  =  9
													A__						:  Optional[int]		  =  1
													A__						:  Tuple		  =  None


							def 						_UpperCamelCase       (			self      :						Optional[int]							):
													'''simple docstring'''





													A__						:  Optional[Any]		  =  ids_tensor([self.batch_size, self.seq_length]			,    self.vocab_size							)

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

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

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

													A__						:  List[str]		  =  ConvBertConfig(
													    vocab_size=self.vocab_size			,    hidden_size=self.hidden_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_dict=snake_case			,    )

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


							def 						_UpperCamelCase       (			self      :						List[Any]			,    snake_case      :						Union[str, Any]			,    snake_case      :						Optional[Any]			,    snake_case      :						Any			,    snake_case      :						int			,    snake_case      :						str			,    snake_case      :						Union[str, Any]			,    snake_case      :						Any							):
													'''simple docstring'''





													A__						:  Dict		  =  TFConvBertModel(config=snake_case							)
													A__						:  Any		  =  {"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

													A__						:  int		  =  [input_ids, input_mask]
													A__						:  Optional[Any]		  =  model(snake_case							)

													A__						:  Tuple		  =  model(snake_case							)

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


							def 						_UpperCamelCase       (			self      :						Union[str, Any]			,    snake_case      :						str			,    snake_case      :						int			,    snake_case      :						Tuple			,    snake_case      :						Dict			,    snake_case      :						Union[str, Any]			,    snake_case      :						List[Any]			,    snake_case      :						Optional[Any]							):
													'''simple docstring'''





													A__						:  Dict		  =  TFConvBertForMaskedLM(config=snake_case							)
													A__						:  Tuple		  =  {
													    """input_ids""": input_ids,
													    """attention_mask""": input_mask,
													    """token_type_ids""": token_type_ids,
													}
													A__						:  int		  =  model(snake_case							)
													self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.seq_length, self.vocab_size)							)


							def 						_UpperCamelCase       (			self      :						Tuple			,    snake_case      :						int			,    snake_case      :						Any			,    snake_case      :						str			,    snake_case      :						Union[str, Any]			,    snake_case      :						Dict			,    snake_case      :						List[str]			,    snake_case      :						Optional[Any]							):
													'''simple docstring'''





													A__						:  int		  =  self.num_labels
													A__						:  Dict		  =  TFConvBertForSequenceClassification(config=snake_case							)
													A__						:  Dict		  =  {
													    """input_ids""": input_ids,
													    """attention_mask""": input_mask,
													    """token_type_ids""": token_type_ids,
													}

													A__						:  str		  =  model(snake_case							)
													self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.num_labels)							)


							def 						_UpperCamelCase       (			self      :						Any			,    snake_case      :						Tuple			,    snake_case      :						str			,    snake_case      :						Optional[Any]			,    snake_case      :						List[str]			,    snake_case      :						List[Any]			,    snake_case      :						int			,    snake_case      :						Any							):
													'''simple docstring'''





													A__						:  int		  =  self.num_choices
													A__						:  Dict		  =  TFConvBertForMultipleChoice(config=snake_case							)
													A__						:  List[Any]		  =  tf.tile(tf.expand_dims(snake_case			,    1							)			,    (1, self.num_choices, 1)							)
													A__						:  Union[str, Any]		  =  tf.tile(tf.expand_dims(snake_case			,    1							)			,    (1, self.num_choices, 1)							)
													A__						:  Tuple		  =  tf.tile(tf.expand_dims(snake_case			,    1							)			,    (1, self.num_choices, 1)							)
													A__						:  Optional[Any]		  =  {
													    """input_ids""": multiple_choice_inputs_ids,
													    """attention_mask""": multiple_choice_input_mask,
													    """token_type_ids""": multiple_choice_token_type_ids,
													}
													A__						:  int		  =  model(snake_case							)
													self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.num_choices)							)


							def 						_UpperCamelCase       (			self      :						int			,    snake_case      :						Optional[int]			,    snake_case      :						Optional[Any]			,    snake_case      :						List[Any]			,    snake_case      :						List[Any]			,    snake_case      :						Dict			,    snake_case      :						Optional[Any]			,    snake_case      :						int							):
													'''simple docstring'''





													A__						:  Optional[Any]		  =  self.num_labels
													A__						:  str		  =  TFConvBertForTokenClassification(config=snake_case							)
													A__						:  Optional[Any]		  =  {
													    """input_ids""": input_ids,
													    """attention_mask""": input_mask,
													    """token_type_ids""": token_type_ids,
													}
													A__						:  List[Any]		  =  model(snake_case							)
													self.parent.assertEqual(result.logits.shape			,    (self.batch_size, self.seq_length, self.num_labels)							)


							def 						_UpperCamelCase       (			self      :						Optional[int]			,    snake_case      :						int			,    snake_case      :						Any			,    snake_case      :						List[Any]			,    snake_case      :						Union[str, Any]			,    snake_case      :						Any			,    snake_case      :						Any			,    snake_case      :						Optional[Any]							):
													'''simple docstring'''





													A__						:  str		  =  TFConvBertForQuestionAnswering(config=snake_case							)
													A__						:  Dict		  =  {
													    """input_ids""": input_ids,
													    """attention_mask""": input_mask,
													    """token_type_ids""": token_type_ids,
													}

													A__						:  str		  =  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 						_UpperCamelCase       (			self      :						Union[str, Any]							):
													'''simple docstring'''





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






@require_tf
class 							__SCREAMING_SNAKE_CASE						(				UpperCamelCase       ,		UpperCamelCase       ,		unittest.TestCase		):
							snake_case_     =							(
							    (
							        TFConvBertModel,
							        TFConvBertForMaskedLM,
							        TFConvBertForQuestionAnswering,
							        TFConvBertForSequenceClassification,
							        TFConvBertForTokenClassification,
							        TFConvBertForMultipleChoice,
							    )
							    if is_tf_available()
							    else ()
							)
							snake_case_     =							(
							    {
							        'feature-extraction': TFConvBertModel,
							        'fill-mask': TFConvBertForMaskedLM,
							        'question-answering': TFConvBertForQuestionAnswering,
							        'text-classification': TFConvBertForSequenceClassification,
							        'token-classification': TFConvBertForTokenClassification,
							        'zero-shot': TFConvBertForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							snake_case_     =							False
							snake_case_     =							False
							snake_case_     =							False


							def 						_UpperCamelCase       (			self      :						str							):
													'''simple docstring'''





													A__						:  List[str]		  =  TFConvBertModelTester(self							)
													A__						:  Any		  =  ConfigTester(self			,    config_class=snake_case			,    hidden_size=37							)


							def 						_UpperCamelCase       (			self      :						Tuple							):
													'''simple docstring'''





													self.config_tester.run_common_tests()


							def 						_UpperCamelCase       (			self      :						List[Any]							):
													'''simple docstring'''





													A__						:  List[Any]		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_model(*snake_case							)


							def 						_UpperCamelCase       (			self      :						List[Any]							):
													'''simple docstring'''





													A__						:  Union[str, Any]		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_masked_lm(*snake_case							)


							def 						_UpperCamelCase       (			self      :						Optional[Any]							):
													'''simple docstring'''





													A__						:  Dict		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_multiple_choice(*snake_case							)


							def 						_UpperCamelCase       (			self      :						Optional[Any]							):
													'''simple docstring'''





													A__						:  Optional[Any]		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_question_answering(*snake_case							)


							def 						_UpperCamelCase       (			self      :						Any							):
													'''simple docstring'''





													A__						:  List[str]		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_sequence_classification(*snake_case							)


							def 						_UpperCamelCase       (			self      :						int							):
													'''simple docstring'''





													A__						:  str		  =  self.model_tester.prepare_config_and_inputs()
													self.model_tester.create_and_check_for_token_classification(*snake_case							)


							@slow
							def 						_UpperCamelCase       (			self      :						Optional[Any]							):
													'''simple docstring'''





													A__  ,  A__						:  Dict		  =  self.model_tester.prepare_config_and_inputs_for_common()
													A__						:  Optional[int]		  =  True
													A__						:  Union[str, Any]		  =  True

													if hasattr(snake_case			,    """use_cache"""							):
																			A__						:  Any		  =  True

													A__						:  Tuple		  =  getattr(self.model_tester			,    """encoder_seq_length"""			,    self.model_tester.seq_length							)
													A__						:  List[str]		  =  getattr(self.model_tester			,    """key_length"""			,    snake_case							)

													for model_class in self.all_model_classes:
																			A__						:  str		  =  self._prepare_for_class(snake_case			,    snake_case							)
																			A__						:  Optional[Any]		  =  model_class(snake_case							)
																			A__						:  Dict		  =  len(model(snake_case							)							)

																			with tempfile.TemporaryDirectory() as tmpdirname:
																									model.save_pretrained(snake_case			,    saved_model=snake_case							)
																									A__						:  Union[str, Any]		  =  os.path.join(snake_case			,    """saved_model"""			,    """1"""							)
																									A__						:  str		  =  tf.keras.models.load_model(snake_case							)
																									A__						:  str		  =  model(snake_case							)

																									if self.is_encoder_decoder:
																															A__						:  Optional[Any]		  =  outputs["""encoder_hidden_states"""]
																															A__						:  Dict		  =  outputs["""encoder_attentions"""]
																									else:
																															A__						:  Optional[Any]		  =  outputs["""hidden_states"""]
																															A__						:  str		  =  outputs["""attentions"""]

																									self.assertEqual(len(snake_case							)			,    snake_case							)

																									A__						:  List[Any]		  =  getattr(
																									    self.model_tester			,    """expected_num_hidden_layers"""			,    self.model_tester.num_hidden_layers + 1							)

																									self.assertEqual(len(snake_case							)			,    snake_case							)
																									self.assertListEqual(
																									    list(output_hidden_states[0].shape[-2:]							)			,    [self.model_tester.seq_length, self.model_tester.hidden_size]			,    )

																									self.assertEqual(len(snake_case							)			,    self.model_tester.num_hidden_layers							)
																									self.assertListEqual(
																									    list(output_attentions[0].shape[-3:]							)			,    [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]			,    )


							@slow
							def 						_UpperCamelCase       (			self      :						List[Any]							):
													'''simple docstring'''





													A__						:  Optional[int]		  =  TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""							)
													self.assertIsNotNone(snake_case							)


							def 						_UpperCamelCase       (			self      :						str							):
													'''simple docstring'''





													A__  ,  A__						:  Union[str, Any]		  =  self.model_tester.prepare_config_and_inputs_for_common()
													A__						:  Union[str, Any]		  =  True
													A__						:  Any		  =  getattr(self.model_tester			,    """decoder_seq_length"""			,    self.model_tester.seq_length							)
													A__						:  int		  =  getattr(self.model_tester			,    """encoder_seq_length"""			,    self.model_tester.seq_length							)
													A__						:  Optional[int]		  =  getattr(self.model_tester			,    """key_length"""			,    snake_case							)
													A__						:  List[Any]		  =  getattr(self.model_tester			,    """key_length"""			,    snake_case							)

													def check_decoder_attentions_output(snake_case      :						Any							):
																			A__						:  int		  =  len(snake_case							)
																			self.assertEqual(out_len % 2			,    0							)
																			A__						:  Any		  =  outputs.decoder_attentions
																			self.assertEqual(len(snake_case							)			,    self.model_tester.num_hidden_layers							)
																			self.assertListEqual(
																			    list(decoder_attentions[0].shape[-3:]							)			,    [self.model_tester.num_attention_heads / 2, decoder_seq_length, decoder_key_length]			,    )

													def check_encoder_attentions_output(snake_case      :						Union[str, Any]							):
																			A__						:  List[str]		  =  [
																			    t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
																			]
																			self.assertEqual(len(snake_case							)			,    self.model_tester.num_hidden_layers							)
																			self.assertListEqual(
																			    list(attentions[0].shape[-3:]							)			,    [self.model_tester.num_attention_heads / 2, encoder_seq_length, encoder_key_length]			,    )

													for model_class in self.all_model_classes:
																			A__						:  Tuple		  =  True
																			A__						:  Union[str, Any]		  =  False
																			A__						:  Optional[Any]		  =  model_class(snake_case							)
																			A__						:  Any		  =  model(self._prepare_for_class(snake_case			,    snake_case							)							)
																			A__						:  Optional[int]		  =  len(snake_case							)
																			self.assertEqual(config.output_hidden_states			,    snake_case							)
																			check_encoder_attentions_output(snake_case							)

																			if self.is_encoder_decoder:
																									A__						:  Optional[Any]		  =  model_class(snake_case							)
																									A__						:  Union[str, Any]		  =  model(self._prepare_for_class(snake_case			,    snake_case							)							)
																									self.assertEqual(config.output_hidden_states			,    snake_case							)
																									check_decoder_attentions_output(snake_case							)

																			# Check that output attentions can also be changed via the config
																			del inputs_dict["output_attentions"]
																			A__						:  List[str]		  =  True
																			A__						:  Any		  =  model_class(snake_case							)
																			A__						:  Union[str, Any]		  =  model(self._prepare_for_class(snake_case			,    snake_case							)							)
																			self.assertEqual(config.output_hidden_states			,    snake_case							)
																			check_encoder_attentions_output(snake_case							)

																			# Check attention is always last and order is fine
																			A__						:  Optional[Any]		  =  True
																			A__						:  str		  =  True
																			A__						:  int		  =  model_class(snake_case							)
																			A__						:  Any		  =  model(self._prepare_for_class(snake_case			,    snake_case							)							)

																			self.assertEqual(out_len + (2 if self.is_encoder_decoder else 1)			,    len(snake_case							)							)
																			self.assertEqual(model.config.output_hidden_states			,    snake_case							)
																			check_encoder_attentions_output(snake_case							)






@require_tf
class 							__SCREAMING_SNAKE_CASE						(				unittest.TestCase		):


							@slow
							def 						_UpperCamelCase       (			self      :						str							):
													'''simple docstring'''





													A__						:  Tuple		  =  TFConvBertModel.from_pretrained("""YituTech/conv-bert-base"""							)
													A__						:  str		  =  tf.constant([[0, 1, 2, 3, 4, 5]]							)
													A__						:  Dict		  =  model(snake_case							)[0]

													A__						:  Optional[int]		  =  [1, 6, 768]
													self.assertEqual(output.shape			,    snake_case							)

													A__						:  List[str]		  =  tf.constant(
													    [
													        [
													            [-0.03475493, -0.4686034, -0.30638832],
													            [0.22637248, -0.26988646, -0.7423424],
													            [0.10324868, -0.45013508, -0.58280784],
													        ]
													    ]							)
													tf.debugging.assert_near(output[:, :3, :3]			,    snake_case			,    atol=1e-4							)














"""simple docstring"""



def      _lowerCAmelCase		(							UpperCAmelCase__       :					int = 1_0_0_0      )		->int:
						A__						:  Optional[int]		  =  2**power
						A__						:  Dict		  =  0
						while n:
												A__  ,  A__						:  Tuple		  =  r + n % 1_0, n // 1_0
						return r


if __name__ == "__main__":
						print(solution(int(str(input()).strip())))






