




'''simple docstring'''





import argparse
from copy import deepcopy

import numpy as np
from datasets import ClassLabel, DatasetDict, load_dataset
from evaluate import load

from transformers import (
    AutoModelForSequenceClassification,
    AutoTokenizer,
    DataCollatorWithPadding,
    Trainer,
    TrainerCallback,
    TrainingArguments,
    set_seed,
)





def       __a      (  )		->					List[Any]:

     """simple docstring"""




     _snake_case				= argparse.ArgumentParser()
     parser.add_argument("--model_ckpt"   ,		type=_UpperCamelCase   ,		default="microsoft/unixcoder-base-nine"       )
     parser.add_argument("--num_epochs"   ,		type=_UpperCamelCase   ,		default=5       )
     parser.add_argument("--batch_size"   ,		type=_UpperCamelCase   ,		default=6       )
     parser.add_argument("--gradient_accumulation_steps"   ,		type=_UpperCamelCase   ,		default=1       )
     parser.add_argument("--freeze"   ,		type=_UpperCamelCase   ,		default=_UpperCamelCase       )
     parser.add_argument("--learning_rate"   ,		type=_UpperCamelCase   ,		default=5E-4       )
     parser.add_argument("--seed"   ,		type=_UpperCamelCase   ,		default=0       )
     parser.add_argument("--lr_scheduler_type"   ,		type=_UpperCamelCase   ,		default="cosine"       )
     parser.add_argument("--num_warmup_steps"   ,		type=_UpperCamelCase   ,		default=10       )
     parser.add_argument("--weight_decay"   ,		type=_UpperCamelCase   ,		default=0.01       )
     parser.add_argument("--output_dir"   ,		type=_UpperCamelCase   ,		default="./results"       )
     return parser.parse_args()


UpperCamelCase_		:     Optional[int]          =		load('''accuracy''')





def       __a      (  _UpperCamelCase:       Optional[int]       )		->					Tuple:

     """simple docstring"""




     _snake_case				,   _snake_case				= eval_pred
     _snake_case				= np.argmax(_UpperCamelCase   ,		axis=1       )
     return metric.compute(predictions=_UpperCamelCase   ,		references=_UpperCamelCase       )

class   _a							(		__lowerCAmelCase				):






     def __init__(					self   ,_SCREAMING_SNAKE_CASE       )				->     None:
          super().__init__()
          _snake_case				= trainer






     def 							_lowercase      (					self   ,_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE   ,_SCREAMING_SNAKE_CASE   ,**_SCREAMING_SNAKE_CASE       )				->     List[str]:
          if control.should_evaluate:
               _snake_case				= deepcopy(_SCREAMING_SNAKE_CASE       )
               self._trainer.evaluate(eval_dataset=self._trainer.train_dataset   ,metric_key_prefix="train"       )
               return control_copy







def       __a      (  )		->					Optional[Any]:

     """simple docstring"""




     _snake_case				= get_args()
     set_seed(args.seed       )

     _snake_case				= load_dataset("codeparrot/codecomplex"   ,		split="train"       )
     _snake_case				= dataset.train_test_split(test_size=0.2       )
     _snake_case				= train_test["test"].train_test_split(test_size=0.5       )
     _snake_case				= DatasetDict(
         {
             "train": train_test["train"],
             "test": test_validation["train"],
             "valid": test_validation["test"],
         }       )

     print("Loading tokenizer and model"       )
     _snake_case				= AutoTokenizer.from_pretrained(args.model_ckpt       )
     _snake_case				= tokenizer.eos_token
     _snake_case				= AutoModelForSequenceClassification.from_pretrained(args.model_ckpt   ,		num_labels=7       )
     _snake_case				= model.config.eos_token_id

     if args.freeze:
          for param in model.roberta.parameters():
               _snake_case				= False

     _snake_case				= ClassLabel(num_classes=7   ,		names=list(set(train_test_validation["train"]["complexity"]       )       )       )

     def tokenize(_UpperCamelCase:       List[str]       ):
          _snake_case				= tokenizer(example["src"]   ,		truncation=_UpperCamelCase   ,		max_length=1_024       )
          _snake_case				= labels.straint(example["complexity"]       )
          return {
              "input_ids": inputs["input_ids"],
              "attention_mask": inputs["attention_mask"],
              "label": label,
          }

     _snake_case				= train_test_validation.map(
         _UpperCamelCase   ,		batched=_UpperCamelCase   ,		remove_columns=train_test_validation["train"].column_names   ,		)
     _snake_case				= DataCollatorWithPadding(tokenizer=_UpperCamelCase       )

     _snake_case				= TrainingArguments(
         output_dir=args.output_dir   ,		learning_rate=args.learning_rate   ,		lr_scheduler_type=args.lr_scheduler_type   ,		evaluation_strategy="epoch"   ,		save_strategy="epoch"   ,		logging_strategy="epoch"   ,		per_device_train_batch_size=args.batch_size   ,		per_device_eval_batch_size=args.batch_size   ,		num_train_epochs=args.num_epochs   ,		gradient_accumulation_steps=args.gradient_accumulation_steps   ,		weight_decay=0.01   ,		metric_for_best_model="accuracy"   ,		run_name="complexity-java"   ,		report_to="wandb"   ,		)

     _snake_case				= Trainer(
         model=_UpperCamelCase   ,		args=_UpperCamelCase   ,		train_dataset=tokenized_datasets["train"]   ,		eval_dataset=tokenized_datasets["valid"]   ,		tokenizer=_UpperCamelCase   ,		data_collator=_UpperCamelCase   ,		compute_metrics=_UpperCamelCase   ,		)

     print("Training..."       )
     trainer.add_callback(CustomCallback(_UpperCamelCase       )       )
     trainer.train()


if __name__ == "__main__":
   main()








'''simple docstring'''





from math import factorial





def       __a      (  _UpperCamelCase:       int = 100       )		->					int:

     """simple docstring"""




     return sum(map(_UpperCamelCase   ,		str(factorial(_UpperCamelCase       )       )       )       )


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


