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




	'''simple docstring'''


	def 	SCREAMING_SNAKE_CASE__						(       self       ):
		lowercase       =    torch.nn.Linear(10		,    10       )
		lowercase       =    torch.optim.SGD(model.parameters()		,    0.1       )
		lowercase       =    Accelerator()
		lowercase       =    accelerator.prepare(snake_case_       )
		try:
			pickle.loads(pickle.dumps(snake_case_       )       )
		except Exception as e:
			self.fail(F'''Accelerated optimizer pickling failed with {e}'''       )
		AcceleratorState._reset_state()








'''simple docstring'''




import math
def 	UpperCAmelCase_							(					__lowercase							:      int       )		->       bool:


     '''simple docstring'''



     return math.sqrt(__lowercase       ) * math.sqrt(__lowercase       ) == num
def 	UpperCAmelCase_							(					__lowercase							:      int       )		->       bool:


     '''simple docstring'''



     _UpperCAmelCase     							=   0
     _UpperCAmelCase     							=   n
     while left <= right:
          _UpperCAmelCase     							=   (left + right) // 2
          if mid**2 == n:
               return True
          elif mid**2 > n:
               _UpperCAmelCase     							=   mid - 1
          else:
               _UpperCAmelCase     							=   mid + 1
     return False


if __name__ == "__main__":
  import doctest

  doctest.testmod()




