




import warnings

from .state import AcceleratorState, GradientState


warnings.filterwarnings("""ignore""", category=UserWarning, module="""torch.optim.lr_scheduler""")
class 			a__    :






						def __init__(   self		,			_A		,			_A		,			_A = True		,			_A = False			):




											"""simple docstring"""



											__lowerCAmelCase				   =       scheduler
											__lowerCAmelCase				   =       optimizers if isinstance(__lowerCAmelCase		,			(list, tuple)			) else [optimizers]
											__lowerCAmelCase				   =       split_batches
											__lowerCAmelCase				   =       step_with_optimizer
											__lowerCAmelCase				   =       GradientState()






						def 				__SCREAMING_SNAKE_CASE(   self		,			*_A		,			**_A			):




											"""simple docstring"""



											if not self.step_with_optimizer:
																# No link between scheduler and optimizer -> just step
																self.scheduler.step(*__lowerCAmelCase		,			**__lowerCAmelCase			)
																return

											# Otherwise, first make sure the optimizer was stepped.
											if not self.gradient_state.sync_gradients:
																if self.gradient_state.adjust_scheduler:
																					self.scheduler._step_count += 1
																return

											for opt in self.optimizers:
																if opt.step_was_skipped:
																					return
											if self.split_batches:
																# Split batches -> the training dataloader batch size is not changed so one step per training step
																self.scheduler.step(*__lowerCAmelCase		,			**__lowerCAmelCase			)
											else:
																# Otherwise the training dataloader batch size was multiplied by `num_processes`, so we need to do
																# num_processes steps per training step
																__lowerCAmelCase				   =       AcceleratorState().num_processes
																for _ in range(__lowerCAmelCase			):
																					# Special case when using OneCycle and `drop_last` was not used
																					if hasattr(self.scheduler		,			"total_steps"			):
																										if self.scheduler._step_count <= self.scheduler.total_steps:
																															self.scheduler.step(*__lowerCAmelCase		,			**__lowerCAmelCase			)
																					else:
																										self.scheduler.step(*__lowerCAmelCase		,			**__lowerCAmelCase			)






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



											return self.scheduler.get_last_lr()






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



											return self.scheduler.state_dict()






						def 				__SCREAMING_SNAKE_CASE(   self		,			_A			):




											"""simple docstring"""



											self.scheduler.load_state_dict(__lowerCAmelCase			)






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



											return self.scheduler.get_lr()






						def 				__SCREAMING_SNAKE_CASE(   self		,			*_A		,			**_A			):




											"""simple docstring"""



											return self.scheduler.print_lr(*__lowerCAmelCase		,			**__lowerCAmelCase			)





'''simple docstring'''

def 			__UpperCamelCase       (   UpperCAmelCase     ):
 lowercase__				:    List[str]  =					0
 while num > 0:
  digit_sum += num % 10
  num //= 10
 return digit_sum
def 			__UpperCamelCase       (   UpperCAmelCase = 100     ):
 lowercase__				:    Dict  =					1
 lowercase__				:    Optional[int]  =					2

 for i in range(2		,     max_n + 1     ):
  lowercase__				:    List[str]  =					pre_numerator
  lowercase__				:    Optional[Any]  =					2 * i // 3 if i % 3 == 0 else 1
  lowercase__				:    Union[str, Any]  =					cur_numerator
  lowercase__				:    int  =					e_cont * pre_numerator + temp

 return sum_digits(UpperCAmelCase     )


if __name__ == "__main__":
  print(F'{solution() = }')

