





from decimal import Decimal, getcontext
from math import ceil, factorial
def        UpperCamelCase__				(		lowerCAmelCase  ):





      """simple docstring"""


      if not isinstance(lowercase__							,     lowercase__  ):
            raise TypeError("""Undefined for non-integers"""  )
      elif precision < 1:
            raise ValueError("""Undefined for non-natural numbers"""  )

      _lowerCAmelCase												=							precision
      _lowerCAmelCase												=							ceil(precision / 14  )
      _lowerCAmelCase												=							42_68_80 * Decimal(1_00_05  ).sqrt()
      _lowerCAmelCase												=							1
      _lowerCAmelCase												=							13_59_14_09
      _lowerCAmelCase												=							Decimal(lowercase__  )
      for k in range(1							,     lowercase__  ):
            _lowerCAmelCase												=							factorial(6 * k  ) // (factorial(3 * k  ) * factorial(lowercase__  ) ** 3)
            linear_term += 5_45_14_01_34
            exponential_term *= -26_25_37_41_26_40_76_80_00
            partial_sum += Decimal(multinomial_term * linear_term  ) / exponential_term
      return str(constant_term / partial_sum  )[:-1]


if __name__ == "__main__":
      A__    :       Optional[Any]              =50
      print(F"""The first {n} digits of pi is: {pi(n)}""")













'''simple docstring'''






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 			UpperCAmelCase					(      unittest.TestCase       ):




      def     lowercase__   (      self      :			int  )    ->				Union[str, Any]:
            _lowerCAmelCase												=							inspect.getfile(accelerate.test_utils  )
            _lowerCAmelCase												=							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

            _lowerCAmelCase												=							test_metrics




      @require_cpu
      def     lowercase__   (      self      :			Optional[Any]  )    ->				Optional[Any]:
            debug_launcher(self.test_metrics.main      ,      num_processes=1  )




      @require_cpu
      def     lowercase__   (      self      :			Tuple  )    ->				Tuple:
            debug_launcher(self.test_metrics.main  )




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




      @require_multi_gpu
      def     lowercase__   (      self      :			str  )    ->				List[str]:
            print(f"Found {torch.cuda.device_count()} devices."  )
            _lowerCAmelCase												=							["""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()  )






