



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





							def 						UpperCamelCase_					(   self		:		Optional[Any]	):

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





def   lowerCAmelCase__						(							_SCREAMING_SNAKE_CASE       :			int = 3				,     _SCREAMING_SNAKE_CASE       :			int = 7				,     _SCREAMING_SNAKE_CASE       :			int = 100_0000    ):
				"""simple docstring"""







				__a       =		0
				__a       =		1

				for current_denominator in range(1				,     limit + 1    ):
								__a       =		current_denominator * numerator // denominator
								if current_denominator % denominator == 0:
												current_numerator -= 1
								if current_numerator * max_denominator > current_denominator * max_numerator:
												__a       =		current_numerator
												__a       =		current_denominator
				return max_numerator


if __name__ == "__main__":
						print(solution(numerator=3, denominator=7, limit=100_0000))
