





'''simple docstring'''


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





     def 							lowercase__				(			self		: Optional[Any]						):





        """simple docstring"""




        lowercase_      :Union[str, Any]         =			torch.nn.Linear(10     ,				10						)
        lowercase_      :Tuple         =			torch.optim.SGD(model.parameters()     ,				0.1						)
        lowercase_      :int         =			Accelerator()
        lowercase_      :Optional[int]         =			accelerator.prepare(_SCREAMING_SNAKE_CASE						)
        try:
           pickle.loads(pickle.dumps(_SCREAMING_SNAKE_CASE						)						)
        except Exception as e:
           self.fail(F'Accelerated optimizer pickling failed with {e}'						)
        AcceleratorState._reset_state()









'''simple docstring'''


import numpy as np
def 							UpperCAmelCase_  (						__lowerCamelCase : str     ,__lowerCamelCase : Optional[Any]     ,__lowerCamelCase : int     ,__lowerCamelCase : List[str]     ,__lowerCamelCase : List[Any]			):
   lowercase_      :Dict         =			int(np.ceil((x_end - xa) / h			)			)
   lowercase_      :Optional[int]         =			np.zeros((n + 1,)			)
   lowercase_      :Tuple         =			ya
   lowercase_      :List[str]         =			xa

   for k in range(__lowerCamelCase			):
      lowercase_      :Any         =			f(__lowerCamelCase     ,y[k]			)
      lowercase_      :Optional[Any]         =			f(x + 0.5 * h     ,y[k] + 0.5 * h * ka			)
      lowercase_      :Optional[Any]         =			f(x + 0.5 * h     ,y[k] + 0.5 * h * ka			)
      lowercase_      :Any         =			f(x + h     ,y[k] + h * ka			)
      lowercase_      :Tuple         =			y[k] + (1 / 6) * h * (ka + 2 * ka + 2 * ka + ka)
      x += h

   return y


if __name__ == "__main__":
 import doctest

 doctest.testmod()


