





from math import factorial

UpperCAmelCase_							=				{str(digit): factorial(digit) for digit in range(10)}





def  __magic_name__  (				lowercase				)				-> Any:

							"""simple docstring"""



							if not isinstance(lowercase				,       lowercase				):
														raise TypeError("""Parameter number must be int"""				)

							if number < 0:
														raise ValueError("""Parameter number must be greater than or equal to 0"""				)

							# Converts number in string to iterate on its digits and adds its factorial.
							return sum(DIGIT_FACTORIAL[digit] for digit in str(lowercase				)				)





def  __magic_name__  (				lowercase = 60				,       lowercase = 1000000				)				-> List[Any]:

							"""simple docstring"""



							if not isinstance(lowercase				,       lowercase				) or not isinstance(lowercase				,       lowercase				):
														raise TypeError("""Parameters chain_length and number_limit must be int"""				)

							if chain_length <= 0 or number_limit <= 0:
														raise ValueError(
														    """Parameters chain_length and number_limit must be greater than 0"""				)

							# the counter for the chains with the exact desired length
							lowercase_	:   str  				=     0
							# the cached sizes of the previous chains
							lowercase_	:   Dict  				=     {}

							for start_chain_element in range(1				,       lowercase				):
														# The temporary set will contain the elements of the chain
														lowercase_	:   Tuple  				=     set()
														lowercase_	:   Tuple  				=     0

														# Stop computing the chain when you find a cached size, a repeating item or the
														# length is greater then the desired one.
														lowercase_	:   Any  				=     start_chain_element
														while (
														    chain_element not in chain_sets_lengths
														    and chain_element not in chain_set
														    and chain_set_length <= chain_length
														):
																					chain_set.add(lowercase				)
																					chain_set_length += 1
																					lowercase_	:   Optional[int]  				=     digit_factorial_sum(lowercase				)

														if chain_element in chain_sets_lengths:
																					chain_set_length += chain_sets_lengths[chain_element]

														lowercase_	:   List[Any]  				=     chain_set_length

														# If chain contains the exact amount of elements increase the counter
														if chain_set_length == chain_length:
																					chains_counter += 1

							return chains_counter


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(F'''{solution()}''')
"""simple docstring"""



import os

import pytest
from attr import dataclass


SCREAMING_SNAKE_CASE__:List[str]									=			"""us-east-1"""  # defaults region






@dataclass
class  snake_case__      :
 _snake_case       :					str
 _snake_case       :					Optional[Any]							  =						"""arn:aws:iam::558105141721:role/sagemaker_execution_role"""
 _snake_case       :					Optional[Any]							  =						{
     """task_name""": """mnli""",
     """per_device_train_batch_size""": 16,
     """per_device_eval_batch_size""": 16,
     """do_train""": True,
     """do_eval""": True,
     """do_predict""": True,
     """output_dir""": """/opt/ml/model""",
     """overwrite_output_dir""": True,
     """max_steps""": 500,
     """save_steps""": 5_500,
 }
 _snake_case       :					List[str]							  =						{**hyperparameters, """max_steps""": 1_000}


 @property
 def 						a__   ( self						):
        if self.framework == "pytorch":
               return [
                   {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
                   {"Name": "eval_accuracy", "Regex": r"eval_accuracy.*=\D*(.*?)$"},
                   {"Name": "eval_loss", "Regex": r"eval_loss.*=\D*(.*?)$"},
               ]
        else:
               return [
                   {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
                   {"Name": "eval_accuracy", "Regex": r"loss.*=\D*(.*?)]?$"},
                   {"Name": "eval_loss", "Regex": r"sparse_categorical_accuracy.*=\D*(.*?)]?$"},
               ]


 @property
 def 						a__   ( self						):
        return F"{self.framework}-transfromers-test"


 @property
 def 						a__   ( self						):
        return F"./tests/sagemaker/scripts/{self.framework}"






 @property
 def 						a__   ( self						):
        if self.framework == "pytorch":
               return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-training:1.7.1-transformers4.6.1-gpu-py36-cu110-ubuntu18.04"
        else:
               return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-tensorflow-training:2.4.1-transformers4.6.1-gpu-py37-cu110-ubuntu18.04"



@pytest.fixture(scope="class"				)
def 	_lowerCamelCase(	a				):
       __a       =    SageMakerTestEnvironment(framework=request.cls.framework				)
