






'''simple docstring'''






import gc
import unittest

from transformers import CTRLConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
          CTRLForSequenceClassification,
          CTRLLMHeadModel,
          CTRLModel,
      )




class a_    :







   def __init__(self					,   __a					,   __a=1_4					,   __a=7					,   __a=True					,   __a=True					,   __a=True					,   __a=True					,   __a=True					,   __a=9_9					,   __a=3_2					,   __a=5					,   __a=4					,   __a=3_7					,   __a="gelu"					,   __a=0.1					,   __a=0.1					,   __a=5_1_2					,   __a=1_6					,   __a=2					,   __a=0.02					,   __a=3					,   __a=4					,   __a=None					,   )			->      List[Any]:
      """simple docstring"""






      __snake_case				:      int     							= parent
      __snake_case				:      str     							= batch_size
      __snake_case				:      Dict     							= seq_length
      __snake_case				:      Dict     							= is_training
      __snake_case				:      List[str]     							= use_token_type_ids
      __snake_case				:      Dict     							= use_input_mask
      __snake_case				:      Tuple     							= use_labels
      __snake_case				:      int     							= use_mc_token_ids
      __snake_case				:      List[Any]     							= vocab_size
      __snake_case				:      List[Any]     							= hidden_size
      __snake_case				:      Any     							= num_hidden_layers
      __snake_case				:      str     							= num_attention_heads
      __snake_case				:      str     							= intermediate_size
      __snake_case				:      Optional[int]     							= hidden_act
      __snake_case				:      int     							= hidden_dropout_prob
      __snake_case				:      Optional[int]     							= attention_probs_dropout_prob
      __snake_case				:      List[Any]     							= max_position_embeddings
      __snake_case				:      Any     							= type_vocab_size
      __snake_case				:      Optional[Any]     							= type_sequence_label_size
      __snake_case				:      int     							= initializer_range
      __snake_case				:      Union[str, Any]     							= num_labels
      __snake_case				:      Dict     							= num_choices
      __snake_case				:      int     							= scope
      __snake_case				:      str     							= self.vocab_size - 1







   def     SCREAMING_SNAKE_CASE__					(self)			->      int:
      """simple docstring"""






      __snake_case				:      int     							= ids_tensor([self.batch_size, self.seq_length]					,   self.vocab_size)

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

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

      __snake_case				:      Optional[Any]     							= None
      if self.use_mc_token_ids:
         __snake_case				:      Optional[int]     							= ids_tensor([self.batch_size, self.num_choices]					,   self.seq_length)

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

      __snake_case				:      List[Any]     							= self.get_config()

      __snake_case				:      List[Any]     							= ids_tensor([self.num_hidden_layers, self.num_attention_heads]					,   2)

      return (
          config,
          input_ids,
          input_mask,
          head_mask,
          token_type_ids,
          mc_token_ids,
          sequence_labels,
          token_labels,
          choice_labels,
      )







   def     SCREAMING_SNAKE_CASE__					(self)			->      Tuple:
      """simple docstring"""






      return CTRLConfig(
          vocab_size=self.vocab_size					,   n_embd=self.hidden_size					,   n_layer=self.num_hidden_layers					,   n_head=self.num_attention_heads					,   n_positions=self.max_position_embeddings					,   pad_token_id=self.pad_token_id					,   )







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a					,   __a					,   __a					,   __a					,   *__a)			->      Union[str, Any]:
      """simple docstring"""






      __snake_case				:      int     							= CTRLModel(config=_lowercase)
      model.to(_lowercase)
      model.eval()

      model(_lowercase					,   token_type_ids=_lowercase					,   head_mask=_lowercase)
      model(_lowercase					,   token_type_ids=_lowercase)
      __snake_case				:      List[Any]     							= model(_lowercase)
      self.parent.assertEqual(result.last_hidden_state.shape					,   (self.batch_size, self.seq_length, self.hidden_size))
      self.parent.assertEqual(len(result.past_key_values)					,   config.n_layer)







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a					,   __a					,   __a					,   __a					,   *__a)			->      int:
      """simple docstring"""






      __snake_case				:      Tuple     							= CTRLLMHeadModel(_lowercase)
      model.to(_lowercase)
      model.eval()

      __snake_case				:      Optional[int]     							= model(_lowercase					,   token_type_ids=_lowercase					,   labels=_lowercase)
      self.parent.assertEqual(result.loss.shape					,   ())
      self.parent.assertEqual(result.logits.shape					,   (self.batch_size, self.seq_length, self.vocab_size))







   def     SCREAMING_SNAKE_CASE__					(self)			->      List[str]:
      """simple docstring"""






      __snake_case				:      Union[str, Any]     							= self.prepare_config_and_inputs()

      (
          __snake_case		
      )				:      List[Any]     							= config_and_inputs

      __snake_case				:      List[str]     							= {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """head_mask""": head_mask}

      return config, inputs_dict







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a					,   __a					,   __a					,   *__a)			->      Optional[Any]:
      """simple docstring"""






      __snake_case				:      str     							= self.num_labels
      __snake_case				:      str     							= CTRLForSequenceClassification(_lowercase)
      model.to(_lowercase)
      model.eval()
      __snake_case				:      Dict     							= ids_tensor([self.batch_size]					,   self.type_sequence_label_size)
      __snake_case				:      List[str]     							= model(_lowercase					,   token_type_ids=_lowercase					,   labels=_lowercase)
      self.parent.assertEqual(result.logits.shape					,   (self.batch_size, self.num_labels))




@require_torch
class a_    (    SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      SCREAMING_SNAKE_CASE__		,      unittest.TestCase							):
   _snake_case        =							(CTRLModel, CTRLLMHeadModel, CTRLForSequenceClassification) if is_torch_available() else ()
   _snake_case        =							(CTRLLMHeadModel,) if is_torch_available() else ()
   _snake_case        =							(
       {
           """feature-extraction""": CTRLModel,
           """text-classification""": CTRLForSequenceClassification,
           """text-generation""": CTRLLMHeadModel,
           """zero-shot""": CTRLForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   _snake_case        =							True
   _snake_case        =							False
   _snake_case        =							False







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a					,   __a					,   __a					,   __a)			->      List[str]:
      """simple docstring"""






      if pipeline_test_casse_name == "ZeroShotClassificationPipelineTests":
         # Get `tokenizer does not have a padding token` error for both fast/slow tokenizers.
         # `CTRLConfig` was never used in pipeline tests, either because of a missing checkpoint or because a tiny
         # config could not be created.
         return True

      return False







   def     SCREAMING_SNAKE_CASE__					(self)			->      Optional[int]:
      """simple docstring"""






      __snake_case				:      Tuple     							= CTRLModelTester(self)
      __snake_case				:      Dict     							= ConfigTester(self					,   config_class=_lowercase					,   n_embd=3_7)







   def     SCREAMING_SNAKE_CASE__					(self)			->      Any:
      """simple docstring"""






      super().tearDown()
      # clean-up as much as possible GPU memory occupied by PyTorch
      gc.collect()
      torch.cuda.empty_cache()







   def     SCREAMING_SNAKE_CASE__					(self)			->      Union[str, Any]:
      """simple docstring"""






      self.config_tester.run_common_tests()







   def     SCREAMING_SNAKE_CASE__					(self)			->      Union[str, Any]:
      """simple docstring"""






      __snake_case				:      Union[str, Any]     							= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_ctrl_model(*_lowercase)







   def     SCREAMING_SNAKE_CASE__					(self)			->      List[Any]:
      """simple docstring"""






      __snake_case				:      Dict     							= self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_lm_head_model(*_lowercase)







   @unittest.skip('Will be fixed soon by reducing the size of the model used for common tests.')
   def     SCREAMING_SNAKE_CASE__					(self)			->      List[Any]:
      """simple docstring"""






      pass







   @slow
   def     SCREAMING_SNAKE_CASE__					(self)			->      str:
      """simple docstring"""






      for model_name in CTRL_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         __snake_case				:      List[str]     							= CTRLModel.from_pretrained(_lowercase)
         self.assertIsNotNone(_lowercase)







   @unittest.skip('The model doesn\'t support left padding')  # and it's not used enough to be worth fixing :)
   def     SCREAMING_SNAKE_CASE__					(self)			->      int:
      """simple docstring"""






      pass




@require_torch
class a_    (    unittest.TestCase							):







   def     SCREAMING_SNAKE_CASE__					(self)			->      List[Any]:
      """simple docstring"""






      super().tearDown()
      # clean-up as much as possible GPU memory occupied by PyTorch
      gc.collect()
      torch.cuda.empty_cache()







   @slow
   def     SCREAMING_SNAKE_CASE__					(self)			->      Union[str, Any]:
      """simple docstring"""






      __snake_case				:      Optional[Any]     							= CTRLLMHeadModel.from_pretrained('ctrl')
      model.to(_lowercase)
      __snake_case				:      List[str]     							= torch.tensor(
          [[1_1_8_5_9, 0, 1_6_1_1, 8]]					,   dtype=torch.long					,   device=_lowercase)  # Legal the president is
      __snake_case				:      Union[str, Any]     							= [
          1_1_8_5_9,
          0,
          1_6_1_1,
          8,
          5,
          1_5_0,
          2_6_4_4_9,
          2,
          1_9,
          3_4_8,
          4_6_9,
          3,
          2_5_9_5,
          4_8,
          2_0_7_4_0,
          2_4_6_5_3_3,
          2_4_6_5_3_3,
          1_9,
          3_0,
          5,
      ]  # Legal the president is a good guy and I don't want to lose my job. \n \n I have a

      __snake_case				:      Optional[Any]     							= model.generate(_lowercase					,   do_sample=_lowercase)
      self.assertListEqual(output_ids[0].tolist()					,   _lowercase)







'''simple docstring'''






def        _SCREAMING_SNAKE_CASE  (				A  :       int  )    -> int:







   """simple docstring"""
   __snake_case				:      str     							= 1
   for i in range(1  ,		num + 1  ):
      fact *= i
   return fact




def        _SCREAMING_SNAKE_CASE  (				A  :       int  )    -> int:







   """simple docstring"""
   __snake_case				:      Union[str, Any]     							= 0
   while number > 0:
      __snake_case				:      Dict     							= number % 10
      sum_of_digits += last_digit
      __snake_case				:      Union[str, Any]     							= number // 10  # Removing the last_digit from the given number
   return sum_of_digits




def        _SCREAMING_SNAKE_CASE  (				A  :       int = 1_00  )    -> int:







   """simple docstring"""
   __snake_case				:      List[Any]     							= factorial(A  )
   __snake_case				:      Dict     							= split_and_add(A  )
   return result


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