



"""simple docstring"""


def  _a	(      _SCREAMING_SNAKE_CASE   :						float					,     _SCREAMING_SNAKE_CASE   :						float					,     _SCREAMING_SNAKE_CASE   :						int				):






				'''simple docstring'''



				if principal <= 0:
								raise Exception('''Principal borrowed must be > 0'''				)
				if rate_per_annum < 0:
								raise Exception('''Rate of interest must be >= 0'''				)
				if years_to_repay <= 0 or not isinstance(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				):
								raise Exception('''Years to repay must be an integer > 0'''				)

				# Yearly rate is divided by 12 to get monthly rate
				_UpperCAmelCase					=    rate_per_annum / 12

				# Years to repay is multiplied by 12 to get number of payments as payment is monthly
				_UpperCAmelCase					=    years_to_repay * 12

				return (
				    principal
				    * rate_per_month
				    * (1 + rate_per_month) ** number_of_payments
				    / ((1 + rate_per_month) ** number_of_payments - 1)
				)


if __name__ == "__main__":
					import doctest

					doctest.testmod()








"""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 			_a (					unittest.TestCase):
			"""simple docstring"""



			def  lowercase__						(		self     :    Tuple   )->int:
							_UpperCAmelCase					=    inspect.getfile(accelerate.test_utils   )
							_UpperCAmelCase					=    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

							_UpperCAmelCase					=    test_metrics



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



			@require_cpu
			def  lowercase__						(		self     :    List[str]   )->List[str]:
							debug_launcher(self.test_metrics.main   )



			@require_single_gpu
			def  lowercase__						(		self     :    List[Any]   )->Dict:
							self.test_metrics.main()



			@require_multi_gpu
			def  lowercase__						(		self     :    str   )->int:
							print(F'Found {torch.cuda.device_count()} devices.'   )
							_UpperCAmelCase					=    ['''torchrun''', F'--nproc_per_node={torch.cuda.device_count()}', self.test_file_path]
							with patch_environment(omp_num_threads=1   ):
											execute_subprocess_async(__UpperCamelCase				,   env=os.environ.copy()   )



