


def   _UpperCamelCase				(						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_   )						->float:
   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(lowerCAmelCase_  ,						lowerCAmelCase_   ):
      raise Exception("""Years to repay must be an integer > 0"""   )

   # Yearly rate is divided by 12 to get monthly rate
   UpperCAmelCase							=     rate_per_annum / 1_2

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

   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()







import pickle
import unittest

import torch

from accelerate import Accelerator
from accelerate.state import AcceleratorState
from accelerate.test_utils import require_cpu






@require_cpu
class   __lowercase				(  unittest.TestCase  ):





      def        _lowercase				(		self						:					Any       )    ->   Union[str, Any]:






         """simple docstring"""







         UpperCAmelCase							=     torch.nn.Linear(1_0					,       1_0       )
         UpperCAmelCase							=     torch.optim.SGD(model.parameters()					,       0.1       )
         UpperCAmelCase							=     Accelerator()
         UpperCAmelCase							=     accelerator.prepare(__lowerCamelCase       )
         try:
            pickle.loads(pickle.dumps(__lowerCamelCase       )       )
         except Exception as e:
            self.fail(F"""Accelerated optimizer pickling failed with {e}"""       )
         AcceleratorState._reset_state()



