
import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment


@require_huggingface_suite
class 						__lowerCAmelCase	(	unittest.TestCase      ):



      """simple docstring"""







      def 		snake_case_			(      self		:       Union[str, Any]				):
          __lowercase		:			Any	    =       inspect.getfile(accelerate.test_utils				)
          __lowercase		:			str	    =       os.path.sep.join(
              mod_file.split(os.path.sep				)[:-1] + ['''scripts''', '''external_deps''', '''test_metrics.py''']				)

          from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

          __lowercase		:			Dict	    =       test_metrics




      @require_cpu
      def 		snake_case_			(      self		:       int				):
          debug_launcher(self.test_metrics.main				,       num_processes=1				)




      @require_cpu
      def 		snake_case_			(      self		:       str				):
          debug_launcher(self.test_metrics.main				)




      @require_single_gpu
      def 		snake_case_			(      self		:       Union[str, Any]				):
          self.test_metrics.main()




      @require_multi_gpu
      def 		snake_case_			(      self		:       List[str]				):
          print(F'Found {torch.cuda.device_count()} devices.'				)
          __lowercase		:			Dict	    =       ['''torchrun''', F'--nproc_per_node={torch.cuda.device_count()}', self.test_file_path]
          with patch_environment(omp_num_threads=1				):
              execute_subprocess_async(_snake_case				,       env=os.environ.copy()				)




from math import factorial

__lowerCAmelCase					:			Dict			      =		{str(d): factorial(d) for d in range(10)}


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						int:
    return sum(DIGIT_FACTORIAL[d] for d in str(__lowerCAmelCase	)	)


def     UpperCAmelCase_  (						) ->						int:
    __lowercase		:			int	    =       7 * factorial(9	) + 1
    return sum(i for i in range(3	,					__lowerCAmelCase	) if sum_of_digit_factorial(__lowerCAmelCase	) == i	)


if __name__ == "__main__":
 print(F'{solution() = }')


