


"""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   _a      :
    def __init__( self							:					str							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Tuple=13							,					SCREAMING_SNAKE_CASE__							:					int=7							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]=True							,					SCREAMING_SNAKE_CASE__							:					int=True							,					SCREAMING_SNAKE_CASE__							:					Optional[int]=True							,					SCREAMING_SNAKE_CASE__							:					Tuple=True							,					SCREAMING_SNAKE_CASE__							:					Optional[int]=99							,					SCREAMING_SNAKE_CASE__							:					Any=32							,					SCREAMING_SNAKE_CASE__							:					Any=2							,					SCREAMING_SNAKE_CASE__							:					str=4							,					SCREAMING_SNAKE_CASE__							:					Dict=37							,					SCREAMING_SNAKE_CASE__							:					Tuple="gelu"							,					SCREAMING_SNAKE_CASE__							:					int=0.1							,					SCREAMING_SNAKE_CASE__							:					Optional[int]=0.1							,					SCREAMING_SNAKE_CASE__							:					Dict=5_12							,					SCREAMING_SNAKE_CASE__							:					int=16							,					SCREAMING_SNAKE_CASE__							:					Tuple=2							,					SCREAMING_SNAKE_CASE__							:					Any=0.02							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]=3							,					SCREAMING_SNAKE_CASE__							:					Optional[int]=4							,					SCREAMING_SNAKE_CASE__							:					List[Any]=None							,					):
          lowerCamelCase__           =		parent
          lowerCamelCase__           =		13
          lowerCamelCase__           =		7
          lowerCamelCase__           =		True
          lowerCamelCase__           =		True
          lowerCamelCase__           =		True
          lowerCamelCase__           =		True
          lowerCamelCase__           =		99
          lowerCamelCase__           =		3_84
          lowerCamelCase__           =		2
          lowerCamelCase__           =		4
          lowerCamelCase__           =		37
          lowerCamelCase__           =		'gelu'
          lowerCamelCase__           =		0.1
          lowerCamelCase__           =		0.1
          lowerCamelCase__           =		5_12
          lowerCamelCase__           =		16
          lowerCamelCase__           =		2
          lowerCamelCase__           =		0.02
          lowerCamelCase__           =		3
          lowerCamelCase__           =		4
          lowerCamelCase__           =		1_28
          lowerCamelCase__           =		2
          lowerCamelCase__           =		9
          lowerCamelCase__           =		1
          lowerCamelCase__           =		None
    def      _UpperCamelCase       ( self							:					List[Any]				):
          lowerCamelCase__           =		ids_tensor([self.batch_size, self.seq_length]							,					self.vocab_size				)

          lowerCamelCase__           =		None
          if self.use_input_mask:
                lowerCamelCase__           =		random_attention_mask([self.batch_size, self.seq_length]				)

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

          lowerCamelCase__           =		None
          lowerCamelCase__           =		None
          lowerCamelCase__           =		None
          if self.use_labels:
                lowerCamelCase__           =		ids_tensor([self.batch_size]							,					self.type_sequence_label_size				)
                lowerCamelCase__           =		ids_tensor([self.batch_size, self.seq_length]							,					self.num_labels				)
                lowerCamelCase__           =		ids_tensor([self.batch_size]							,					self.num_choices				)

          lowerCamelCase__           =		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=SCREAMING_SNAKE_CASE__							,					)

          return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
    def      _UpperCamelCase       ( self							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Optional[int]							,					SCREAMING_SNAKE_CASE__							:					int							,					SCREAMING_SNAKE_CASE__							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					List[str]				):
          lowerCamelCase__           =		TFConvBertModel(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		{'input_ids': input_ids, 'attention_mask': input_mask, 'token_type_ids': token_type_ids}

          lowerCamelCase__           =		[input_ids, input_mask]
          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)

          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)

          self.parent.assertEqual(result.last_hidden_state.shape							,					(self.batch_size, self.seq_length, self.hidden_size)				)
    def      _UpperCamelCase       ( self							:					int							,					SCREAMING_SNAKE_CASE__							:					int							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]							,					SCREAMING_SNAKE_CASE__							:					Dict							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Any				):
          lowerCamelCase__           =		TFConvBertForMaskedLM(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		{
              'input_ids': input_ids,
              'attention_mask': input_mask,
              'token_type_ids': token_type_ids,
          }
          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)
          self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length, self.vocab_size)				)
    def      _UpperCamelCase       ( self							:					int							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Dict							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]				):
          lowerCamelCase__           =		self.num_labels
          lowerCamelCase__           =		TFConvBertForSequenceClassification(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		{
              'input_ids': input_ids,
              'attention_mask': input_mask,
              'token_type_ids': token_type_ids,
          }

          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)
          self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.num_labels)				)
    def      _UpperCamelCase       ( self							:					str							,					SCREAMING_SNAKE_CASE__							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					str							,					SCREAMING_SNAKE_CASE__							:					str							,					SCREAMING_SNAKE_CASE__							:					List[str]							,					SCREAMING_SNAKE_CASE__							:					Optional[int]							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Any				):
          lowerCamelCase__           =		self.num_choices
          lowerCamelCase__           =		TFConvBertForMultipleChoice(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					1				)							,					(1, self.num_choices, 1)				)
          lowerCamelCase__           =		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					1				)							,					(1, self.num_choices, 1)				)
          lowerCamelCase__           =		tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE__							,					1				)							,					(1, self.num_choices, 1)				)
          lowerCamelCase__           =		{
              'input_ids': multiple_choice_inputs_ids,
              'attention_mask': multiple_choice_input_mask,
              'token_type_ids': multiple_choice_token_type_ids,
          }
          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)
          self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.num_choices)				)
    def      _UpperCamelCase       ( self							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Union[str, Any]							,					SCREAMING_SNAKE_CASE__							:					Tuple							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					Any				):
          lowerCamelCase__           =		self.num_labels
          lowerCamelCase__           =		TFConvBertForTokenClassification(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		{
              'input_ids': input_ids,
              'attention_mask': input_mask,
              'token_type_ids': token_type_ids,
          }
          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)
          self.parent.assertEqual(result.logits.shape							,					(self.batch_size, self.seq_length, self.num_labels)				)
    def      _UpperCamelCase       ( self							:					Any							,					SCREAMING_SNAKE_CASE__							:					Any							,					SCREAMING_SNAKE_CASE__							:					Dict							,					SCREAMING_SNAKE_CASE__							:					List[Any]							,					SCREAMING_SNAKE_CASE__							:					str							,					SCREAMING_SNAKE_CASE__							:					Optional[Any]							,					SCREAMING_SNAKE_CASE__							:					int							,					SCREAMING_SNAKE_CASE__							:					List[str]				):
          lowerCamelCase__           =		TFConvBertForQuestionAnswering(config=SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		{
              'input_ids': input_ids,
              'attention_mask': input_mask,
              'token_type_ids': token_type_ids,
          }

          lowerCamelCase__           =		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      _UpperCamelCase       ( self							:					Union[str, Any]				):
          lowerCamelCase__           =		self.prepare_config_and_inputs()
          (
              (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,  (
              lowerCamelCase__  
          )    ,    
          )           =		config_and_inputs
          lowerCamelCase__           =		{'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
          return config, inputs_dict





@require_tf
class   _a      (      SCREAMING_SNAKE_CASE_		,		SCREAMING_SNAKE_CASE_		,		unittest.TestCase ):
    a_    :				Optional[int]             =    (
        (
            TFConvBertModel,
            TFConvBertForMaskedLM,
            TFConvBertForQuestionAnswering,
            TFConvBertForSequenceClassification,
            TFConvBertForTokenClassification,
            TFConvBertForMultipleChoice,
        )
        if is_tf_available()
        else ()
    )
    a_    :				Tuple             =    (
        {
            'feature-extraction': TFConvBertModel,
            'fill-mask': TFConvBertForMaskedLM,
            'question-answering': TFConvBertForQuestionAnswering,
            'text-classification': TFConvBertForSequenceClassification,
            'token-classification': TFConvBertForTokenClassification,
            'zero-shot': TFConvBertForSequenceClassification,
        }
        if is_tf_available()
        else {}
    )
    a_    :				Union[str, Any]             =    False
    a_    :				Dict             =    False
    a_    :				str             =    False
    def      _UpperCamelCase       ( self							:					Optional[int]				):
          lowerCamelCase__           =		TFConvBertModelTester(self				)
          lowerCamelCase__           =		ConfigTester(self							,					config_class=SCREAMING_SNAKE_CASE__							,					hidden_size=37				)
    def      _UpperCamelCase       ( self							:					int				):
          self.config_tester.run_common_tests()
    def      _UpperCamelCase       ( self							:					Any				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__				)
    def      _UpperCamelCase       ( self							:					Optional[Any]				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__				)
    def      _UpperCamelCase       ( self							:					str				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE__				)
    def      _UpperCamelCase       ( self							:					List[str]				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__				)
    def      _UpperCamelCase       ( self							:					List[str]				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__				)
    def      _UpperCamelCase       ( self							:					str				):
          lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__				)
    @slow
    def      _UpperCamelCase       ( self							:					List[str]				):
          lowerCamelCase__    ,  lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs_for_common()
          lowerCamelCase__           =		True
          lowerCamelCase__           =		True

          if hasattr(SCREAMING_SNAKE_CASE__							,					'use_cache'				):
                lowerCamelCase__           =		True

          lowerCamelCase__           =		getattr(self.model_tester							,					'encoder_seq_length'							,					self.model_tester.seq_length				)
          lowerCamelCase__           =		getattr(self.model_tester							,					'key_length'							,					SCREAMING_SNAKE_CASE__				)

          for model_class in self.all_model_classes:
                lowerCamelCase__           =		self._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__				)
                lowerCamelCase__           =		model_class(SCREAMING_SNAKE_CASE__				)
                lowerCamelCase__           =		len(model(SCREAMING_SNAKE_CASE__				)				)

                with tempfile.TemporaryDirectory() as tmpdirname:
                      model.save_pretrained(SCREAMING_SNAKE_CASE__							,					saved_model=SCREAMING_SNAKE_CASE__				)
                      lowerCamelCase__           =		os.path.join(SCREAMING_SNAKE_CASE__							,					'saved_model'							,					'1'				)
                      lowerCamelCase__           =		tf.keras.models.load_model(SCREAMING_SNAKE_CASE__				)
                      lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)

                      if self.is_encoder_decoder:
                            lowerCamelCase__           =		outputs['encoder_hidden_states']
                            lowerCamelCase__           =		outputs['encoder_attentions']
                      else:
                            lowerCamelCase__           =		outputs['hidden_states']
                            lowerCamelCase__           =		outputs['attentions']

                      self.assertEqual(len(SCREAMING_SNAKE_CASE__				)							,					SCREAMING_SNAKE_CASE__				)

                      lowerCamelCase__           =		getattr(
                          self.model_tester							,					'expected_num_hidden_layers'							,					self.model_tester.num_hidden_layers + 1				)

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

                      self.assertEqual(len(SCREAMING_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]				):
          lowerCamelCase__           =		TFConvBertModel.from_pretrained('YituTech/conv-bert-base'				)
          self.assertIsNotNone(SCREAMING_SNAKE_CASE__				)


    def      _UpperCamelCase       ( self							:					List[Any]				):
          lowerCamelCase__    ,  lowerCamelCase__           =		self.model_tester.prepare_config_and_inputs_for_common()
          lowerCamelCase__           =		True
          lowerCamelCase__           =		getattr(self.model_tester							,					'decoder_seq_length'							,					self.model_tester.seq_length				)
          lowerCamelCase__           =		getattr(self.model_tester							,					'encoder_seq_length'							,					self.model_tester.seq_length				)
          lowerCamelCase__           =		getattr(self.model_tester							,					'key_length'							,					SCREAMING_SNAKE_CASE__				)
          lowerCamelCase__           =		getattr(self.model_tester							,					'key_length'							,					SCREAMING_SNAKE_CASE__				)

          def check_decoder_attentions_output(SCREAMING_SNAKE_CASE__							:					str				):
                lowerCamelCase__           =		len(SCREAMING_SNAKE_CASE__				)
                self.assertEqual(out_len % 2							,					0				)
                lowerCamelCase__           =		outputs.decoder_attentions
                self.assertEqual(len(SCREAMING_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(SCREAMING_SNAKE_CASE__							:					Any				):
                lowerCamelCase__           =		[
                    t.numpy() for t in (outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions)
                ]
                self.assertEqual(len(SCREAMING_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:
                lowerCamelCase__           =		True
                lowerCamelCase__           =		False
                lowerCamelCase__           =		model_class(SCREAMING_SNAKE_CASE__				)
                lowerCamelCase__           =		model(self._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__				)				)
                lowerCamelCase__           =		len(SCREAMING_SNAKE_CASE__				)
                self.assertEqual(config.output_hidden_states							,					SCREAMING_SNAKE_CASE__				)
                check_encoder_attentions_output(SCREAMING_SNAKE_CASE__				)

                if self.is_encoder_decoder:
                      lowerCamelCase__           =		model_class(SCREAMING_SNAKE_CASE__				)
                      lowerCamelCase__           =		model(self._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__				)				)
                      self.assertEqual(config.output_hidden_states							,					SCREAMING_SNAKE_CASE__				)
                      check_decoder_attentions_output(SCREAMING_SNAKE_CASE__				)

                # Check that output attentions can also be changed via the config
                del inputs_dict["output_attentions"]
                lowerCamelCase__           =		True
                lowerCamelCase__           =		model_class(SCREAMING_SNAKE_CASE__				)
                lowerCamelCase__           =		model(self._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__				)				)
                self.assertEqual(config.output_hidden_states							,					SCREAMING_SNAKE_CASE__				)
                check_encoder_attentions_output(SCREAMING_SNAKE_CASE__				)

                # Check attention is always last and order is fine
                lowerCamelCase__           =		True
                lowerCamelCase__           =		True
                lowerCamelCase__           =		model_class(SCREAMING_SNAKE_CASE__				)
                lowerCamelCase__           =		model(self._prepare_for_class(SCREAMING_SNAKE_CASE__							,					SCREAMING_SNAKE_CASE__				)				)

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





@require_tf
class   _a      (      unittest.TestCase ):
    @slow
    def      _UpperCamelCase       ( self							:					Any				):
          lowerCamelCase__           =		TFConvBertModel.from_pretrained('YituTech/conv-bert-base'				)
          lowerCamelCase__           =		tf.constant([[0, 1, 2, 3, 4, 5]]				)
          lowerCamelCase__           =		model(SCREAMING_SNAKE_CASE__				)[0]

          lowerCamelCase__           =		[1, 6, 7_68]
          self.assertEqual(output.shape							,					SCREAMING_SNAKE_CASE__				)

          lowerCamelCase__           =		tf.constant(
              [
                  [
                      [-0.03_47_54_93, -0.4_68_60_34, -0.30_63_88_32],
                      [0.22_63_72_48, -0.26_98_86_46, -0.7_42_34_24],
                      [0.10_32_48_68, -0.45_01_35_08, -0.58_28_07_84],
                  ]
              ]				)
          tf.debugging.assert_near(output[:, :3, :3]							,					SCREAMING_SNAKE_CASE__							,					atol=1e-4				)







"""simple docstring"""


def   snake_case						(				_a:     int							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		1
      for i in range(1		,   num + 1							):
            fact *= i
      return fact



def   snake_case						(				_a:     int							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		0
      while number > 0:
            lowerCamelCase__           =		number % 10
            sum_of_digits += last_digit
            lowerCamelCase__           =		number // 10  # Removing the last_digit from the given number
      return sum_of_digits



def   snake_case						(				_a:     int = 100							)->		int:
      '''simple docstring'''


      lowerCamelCase__           =		factorial(_a							)
      lowerCamelCase__           =		split_and_add(_a							)
      return result


if __name__ == "__main__":
   print(solution(int(input("Enter the Number: ").strip())))



