
import argparse
import os

import numpy as np
import tensorflow as tf
import torch

from transformers import BertModel





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase    ,		__lowerCAmelCase    ,		__lowerCAmelCase							):
    snake_case__						=				("dense.weight", "attention.self.query", "attention.self.key", "attention.self.value")

    snake_case__						=				(
        ("layer.", "layer_"),
        ("word_embeddings.weight", "word_embeddings"),
        ("position_embeddings.weight", "position_embeddings"),
        ("token_type_embeddings.weight", "token_type_embeddings"),
        (".", "/"),
        ("LayerNorm/weight", "LayerNorm/gamma"),
        ("LayerNorm/bias", "LayerNorm/beta"),
        ("weight", "kernel"),
    )

    if not os.path.isdir(UpperCamelCase__							):
        os.makedirs(UpperCamelCase__							)

    snake_case__						=				model.state_dict()

    def to_tf_var_name(__lowerCAmelCase							):
        for patt, repl in iter(UpperCamelCase__							):
            snake_case__						=				name.replace(UpperCamelCase__    ,		UpperCamelCase__							)
        return F"""bert/{name}"""

    def create_tf_var(__lowerCAmelCase    ,		__lowerCAmelCase    ,		__lowerCAmelCase							):
        snake_case__						=				tf.dtypes.as_dtype(tensor.dtype							)
        snake_case__						=				tf.get_variable(dtype=UpperCamelCase__    ,		shape=tensor.shape    ,		name=UpperCamelCase__    ,		initializer=tf.zeros_initializer()							)
        session.run(tf.variables_initializer([tf_var]							)							)
        session.run(UpperCamelCase__							)
        return tf_var

    tf.reset_default_graph()
    with tf.Session() as session:
        for var_name in state_dict:
            snake_case__						=				to_tf_var_name(UpperCamelCase__							)
            snake_case__						=				state_dict[var_name].numpy()
            if any(x in var_name for x in tensors_to_transpose							):
                snake_case__						=				torch_tensor.T
            snake_case__						=				create_tf_var(tensor=UpperCamelCase__    ,		name=UpperCamelCase__    ,		session=UpperCamelCase__							)
            tf.keras.backend.set_value(UpperCamelCase__    ,		UpperCamelCase__							)
            snake_case__						=				session.run(UpperCamelCase__							)
            print(F"""Successfully created {tf_name}: {np.allclose(UpperCamelCase__    ,		UpperCamelCase__							)}"""							)

        snake_case__						=				tf.train.Saver(tf.trainable_variables()							)
        saver.save(UpperCamelCase__    ,		os.path.join(UpperCamelCase__    ,		model_name.replace("-"    ,		"_"							) + ".ckpt"							)							)





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase=None							):
    snake_case__						=				argparse.ArgumentParser()
    parser.add_argument("--model_name"    ,		type=UpperCamelCase__    ,		required=UpperCamelCase__    ,		help="model name e.g. bert-base-uncased"							)
    parser.add_argument(
        "--cache_dir"    ,		type=UpperCamelCase__    ,		default=UpperCamelCase__    ,		required=UpperCamelCase__    ,		help="Directory containing pytorch model"							)
    parser.add_argument("--pytorch_model_path"    ,		type=UpperCamelCase__    ,		required=UpperCamelCase__    ,		help="/path/to/<pytorch-model-name>.bin"							)
    parser.add_argument("--tf_cache_dir"    ,		type=UpperCamelCase__    ,		required=UpperCamelCase__    ,		help="Directory in which to save tensorflow model"							)
    snake_case__						=				parser.parse_args(UpperCamelCase__							)

    snake_case__						=				BertModel.from_pretrained(
        pretrained_model_name_or_path=args.model_name    ,		state_dict=torch.load(args.pytorch_model_path							)    ,		cache_dir=args.cache_dir    ,		)

    convert_pytorch_checkpoint_to_tf(model=UpperCamelCase__    ,		ckpt_dir=args.tf_cache_dir    ,		model_name=args.model_name							)


if __name__ == "__main__":
     main()





from math import factorial





def 	SCREAMING_SNAKE_CASE__    (      __lowerCAmelCase = 100							):
    return sum(int(__lowerCAmelCase							) for x in str(factorial(__lowerCAmelCase							)							)							)


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



