
"""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 			__magic_name__					(self					)      ->	Optional[Any]:



											"""simple docstring"""




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





"""simple docstring"""




import torch

def lowercase_						(     ):
							if torch.cuda.is_available():
														SCREAMING_SNAKE_CASE__		: List[Any]     =     torch.cuda.device_count()
							else:
														SCREAMING_SNAKE_CASE__		: int     =     0
							print(f'''Successfully ran on {num_gpus} GPUs'''		)


if __name__ == "__main__":
					main()




