






from __future__ import annotations

import unittest

from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available
from transformers.testing_utils import require_tf, require_tokenizers, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
							import tensorflow as tf

							from transformers import TFAutoModelForSeqaSeqLM, TFBlenderbotSmallForConditionalGeneration, TFBlenderbotSmallModel

@require_tf
class        lowerCAmelCase_				:







				"""simple docstring"""




				_snake_case				:   List[Any]        =			BlenderbotSmallConfig
				_snake_case				:   Tuple        =			{}
				_snake_case				:   str        =			"""gelu"""







				def __init__( self     :Union[str, Any]  ,     lowerCamelCase__     :Dict  ,     lowerCamelCase__     :int=13  ,     lowerCamelCase__     :str=7  ,     lowerCamelCase__     :Tuple=True  ,     lowerCamelCase__     :int=False  ,     lowerCamelCase__     :Optional[int]=99  ,     lowerCamelCase__     :List[str]=32  ,     lowerCamelCase__     :List[Any]=2  ,     lowerCamelCase__     :Dict=4  ,     lowerCamelCase__     :str=37  ,     lowerCamelCase__     :Optional[int]=0.1  ,     lowerCamelCase__     :str=0.1  ,     lowerCamelCase__     :List[Any]=20  ,     lowerCamelCase__     :List[Any]=2  ,     lowerCamelCase__     :Tuple=1  ,     lowerCamelCase__     :Tuple=0  ,     ):
					UpperCamelCase__ :Optional[int]						=      parent
					UpperCamelCase__ :List[str]						=      batch_size
					UpperCamelCase__ :int						=      seq_length
					UpperCamelCase__ :Any						=      is_training
					UpperCamelCase__ :Union[str, Any]						=      use_labels
					UpperCamelCase__ :str						=      vocab_size
					UpperCamelCase__ :List[str]						=      hidden_size
					UpperCamelCase__ :int						=      num_hidden_layers
					UpperCamelCase__ :Union[str, Any]						=      num_attention_heads
					UpperCamelCase__ :List[Any]						=      intermediate_size

					UpperCamelCase__ :Union[str, Any]						=      hidden_dropout_prob
					UpperCamelCase__ :Union[str, Any]						=      attention_probs_dropout_prob
					UpperCamelCase__ :Optional[Any]						=      max_position_embeddings
					UpperCamelCase__ :Optional[int]						=      eos_token_id
					UpperCamelCase__ :Optional[int]						=      pad_token_id
					UpperCamelCase__ :Optional[Any]						=      bos_token_id







				def 				__a   ( self     :List[str]     ):
					UpperCamelCase__ :Tuple						=      ids_tensor([self.batch_size, self.seq_length - 1]  ,     self.vocab_size     )
					UpperCamelCase__ :Optional[Any]						=      tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size     )  ,     1     )
					UpperCamelCase__ :Optional[int]						=      tf.concat([input_ids, eos_tensor]  ,     axis=1     )

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

					UpperCamelCase__ :List[Any]						=      self.config_cls(
					    vocab_size=self.vocab_size  ,     d_model=self.hidden_size  ,     encoder_layers=self.num_hidden_layers  ,     decoder_layers=self.num_hidden_layers  ,     encoder_attention_heads=self.num_attention_heads  ,     decoder_attention_heads=self.num_attention_heads  ,     encoder_ffn_dim=self.intermediate_size  ,     decoder_ffn_dim=self.intermediate_size  ,     dropout=self.hidden_dropout_prob  ,     attention_dropout=self.attention_probs_dropout_prob  ,     max_position_embeddings=self.max_position_embeddings  ,     eos_token_ids=[2]  ,     bos_token_id=self.bos_token_id  ,     pad_token_id=self.pad_token_id  ,     decoder_start_token_id=self.pad_token_id  ,     **self.config_updates  ,     )
					UpperCamelCase__ :Dict						=      prepare_blenderbot_small_inputs_dict(__lowercase  ,     __lowercase  ,     __lowercase     )
					return config, inputs_dict







				def 				__a   ( self     :Optional[Any]  ,     lowerCamelCase__     :List[str]  ,     lowerCamelCase__     :List[str]     ):
					UpperCamelCase__ :Optional[int]						=      TFBlenderbotSmallModel(config=__lowercase     ).get_decoder()
					UpperCamelCase__ :Tuple						=      inputs_dict["""input_ids"""]

					UpperCamelCase__ :str						=      input_ids[:1, :]
					UpperCamelCase__ :Union[str, Any]						=      inputs_dict["""attention_mask"""][:1, :]
					UpperCamelCase__ :Union[str, Any]						=      inputs_dict["""head_mask"""]
					UpperCamelCase__ :str						=      1

					# first forward pass
					UpperCamelCase__ :str						=      model(__lowercase  ,     attention_mask=__lowercase  ,     head_mask=__lowercase  ,     use_cache=__lowercase     )

					UpperCamelCase__				,		UpperCamelCase__ :Optional[Any]						=      outputs.to_tuple()

					# create hypothetical next token and extent to next_input_ids
					UpperCamelCase__ :Dict						=      ids_tensor((self.batch_size, 3)  ,     config.vocab_size     )
					UpperCamelCase__ :Dict						=      tf.cast(ids_tensor((self.batch_size, 3)  ,     2     )  ,     tf.inta     )

					# append to next input_ids and
					UpperCamelCase__ :int						=      tf.concat([input_ids, next_tokens]  ,     axis=-1     )
					UpperCamelCase__ :Any						=      tf.concat([attention_mask, next_attn_mask]  ,     axis=-1     )

					UpperCamelCase__ :Tuple						=      model(__lowercase  ,     attention_mask=__lowercase     )[0]
					UpperCamelCase__ :Any						=      model(__lowercase  ,     attention_mask=__lowercase  ,     past_key_values=__lowercase     )[0]

					self.parent.assertEqual(next_tokens.shape[1]  ,     output_from_past.shape[1]     )

					# select random slice
					UpperCamelCase__ :List[str]						=      int(ids_tensor((1,)  ,     output_from_past.shape[-1]     )     )
					UpperCamelCase__ :List[str]						=      output_from_no_past[:, -3:, random_slice_idx]
					UpperCamelCase__ :Union[str, Any]						=      output_from_past[:, :, random_slice_idx]

					# test that outputs are equal for slice
					tf.debugging.assert_near(__lowercase  ,     __lowercase  ,     rtol=1e-3     )




def 				A		(					lowercase__  :  Any ,		lowercase__  :  List[str] ,		lowercase__  :  int ,		lowercase__  :  Optional[Any]=None ,		lowercase__  :  List[str]=None ,		lowercase__  :  List[str]=None ,		lowercase__  :  Optional[int]=None ,		lowercase__  :  Tuple=None ,		)		-> int:





	if attention_mask is None:
		UpperCamelCase__ :Dict						=      tf.cast(tf.math.not_equal(_A ,		config.pad_token_id  ) ,		tf.inta  )
	if decoder_attention_mask is None:
		UpperCamelCase__ :Optional[int]						=      tf.concat(
		    [
		        tf.ones(decoder_input_ids[:, :1].shape ,		dtype=tf.inta  ),
		        tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:] ,		config.pad_token_id  ) ,		tf.inta  ),
		    ] ,		axis=-1 ,		)
	if head_mask is None:
		UpperCamelCase__ :str						=      tf.ones((config.encoder_layers, config.encoder_attention_heads)  )
	if decoder_head_mask is None:
		UpperCamelCase__ :List[str]						=      tf.ones((config.decoder_layers, config.decoder_attention_heads)  )
	if cross_attn_head_mask is None:
		UpperCamelCase__ :Tuple						=      tf.ones((config.decoder_layers, config.decoder_attention_heads)  )
	return {
	    "input_ids": input_ids,
	    "decoder_input_ids": decoder_input_ids,
	    "attention_mask": attention_mask,
	    "decoder_attention_mask": decoder_attention_mask,
	    "head_mask": head_mask,
	    "decoder_head_mask": decoder_head_mask,
	    "cross_attn_head_mask": cross_attn_head_mask,
	}

@require_tf
class        lowerCAmelCase_				(      UpperCAmelCase__						,      UpperCAmelCase__						,      unittest.TestCase	):







				"""simple docstring"""




				_snake_case				:   Tuple        =			(
				    (TFBlenderbotSmallForConditionalGeneration, TFBlenderbotSmallModel) if is_tf_available() else ()
				)
				_snake_case				:   Dict        =			(TFBlenderbotSmallForConditionalGeneration,) if is_tf_available() else ()
				_snake_case				:   Optional[int]        =			(
				    {
				        """conversational""": TFBlenderbotSmallForConditionalGeneration,
				        """feature-extraction""": TFBlenderbotSmallModel,
				        """summarization""": TFBlenderbotSmallForConditionalGeneration,
				        """text2text-generation""": TFBlenderbotSmallForConditionalGeneration,
				        """translation""": TFBlenderbotSmallForConditionalGeneration,
				    }
				    if is_tf_available()
				    else {}
				)
				_snake_case				:   Union[str, Any]        =			True
				_snake_case				:   Tuple        =			False
				_snake_case				:   Optional[int]        =			False







				def 				__a   ( self     :Optional[int]     ):
					UpperCamelCase__ :str						=      TFBlenderbotSmallModelTester(self     )
					UpperCamelCase__ :List[Any]						=      ConfigTester(self  ,     config_class=__lowercase     )







				def 				__a   ( self     :Tuple     ):
					self.config_tester.run_common_tests()







				def 				__a   ( self     :List[str]     ):
					UpperCamelCase__ :Tuple						=      self.model_tester.prepare_config_and_inputs_for_common()
					self.model_tester.check_decoder_model_past_large_inputs(*__lowercase     )

@require_tokenizers
@require_tf
class        lowerCAmelCase_				(      unittest.TestCase	):







				"""simple docstring"""




				_snake_case				:   Optional[int]        =			[
				    """Social anxiety\nWow, I am never shy. Do you have anxiety?\nYes. I end up sweating and blushing and feel like """
				    """  i\'m going to throw up.\nand why is that?"""
				]
				_snake_case				:   Union[str, Any]        =			"""facebook/blenderbot_small-90M"""







				@cached_property
				def 				__a   ( self     :Union[str, Any]     ):
					return BlenderbotSmallTokenizer.from_pretrained("""facebook/blenderbot-90M"""     )







				@cached_property
				def 				__a   ( self     :Optional[int]     ):
					UpperCamelCase__ :Optional[int]						=      TFAutoModelForSeqaSeqLM.from_pretrained(self.model_name     )
					return model







				@slow
				def 				__a   ( self     :Tuple     ):
					UpperCamelCase__ :int						=      self.tokenizer(self.src_text  ,     return_tensors="""tf"""     )
					UpperCamelCase__ :List[str]						=      self.model.generate(
					    model_inputs.input_ids  ,     attention_mask=model_inputs.attention_mask  ,     num_beams=2  ,     use_cache=__lowercase  ,     )
					UpperCamelCase__ :int						=      self.tokenizer.batch_decode(generated_ids.numpy()  ,     skip_special_tokens=__lowercase     )[0]
					assert generated_words in (
					    "i don't know. i just feel like i'm going to throw up. it's not fun.",
					    "i'm not sure. i just feel like i've been feeling like i have to be in a certain place",
					    "i'm not sure. i just feel like i've been in a bad situation.",
					)





def 		lowerCamelCase__       (						_A				):







	'''simple docstring'''





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


def 		lowerCamelCase__       (						_A				):







	'''simple docstring'''





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


def 		lowerCamelCase__       (						_A = 100				):







	'''simple docstring'''





	snake_case_						       =	factorial(_A				)
	snake_case_						       =	split_and_add(_A				)
	return result


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