


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



					'''simple docstring'''







					def A      (				self						)   ->			Optional[Any]:







								'''simple docstring'''

								__lowercase 					=   torch.nn.Linear(1_0 ,       1_0						)
								__lowercase 					=   torch.optim.SGD(model.parameters() ,       0.1						)
								__lowercase 					=   Accelerator()
								__lowercase 					=   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()






from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

a : Optional[int]		=				typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
a : Union[str, Any]		=				typing.Union[np.floataa, int, float]  # noqa: UP007


def 		lowercase_  (     _UpperCamelCase       ,			_UpperCamelCase  ):


			'''simple docstring'''







			return np.sqrt(np.sum((np.asarray(_UpperCamelCase  ) - np.asarray(_UpperCamelCase  )) ** 2  )  )


def 		lowercase_  (     _UpperCamelCase       ,			_UpperCamelCase  ):


			'''simple docstring'''







			return sum((va - va) ** 2 for va, va in zip(_UpperCamelCase       ,			_UpperCamelCase  )  ) ** (1 / 2)


if __name__ == "__main__":


	def 		lowercase_  (     ):


				'''simple docstring'''







				from timeit import timeit

				print('''Without Numpy'''  )
				print(
				    timeit(
				        '''euclidean_distance_no_np([1, 2, 3], [4, 5, 6])'''       ,			number=1_00_00       ,			globals=globals()       ,			)  )
				print('''With Numpy'''  )
				print(
				    timeit(
				        '''euclidean_distance([1, 2, 3], [4, 5, 6])'''       ,			number=1_00_00       ,			globals=globals()       ,			)  )





	benchmark()


