






import torch

from accelerate import Accelerator, DistributedType







class 				lowerCamelCase_     :
       def __enter__(						self		:					Dict					):





        '''simple docstring'''



        if self.enabled:
         a		=			self.model.no_sync()
         self.model_sync_obj.__enter__()

        return self
       def __exit__(						self		:					Union[str, Any]							,__lowerCamelCase		:					Optional[Any]							,__lowerCamelCase		:					List[str]							,__lowerCamelCase		:					List[Any]					):





        '''simple docstring'''



        if self.enabled:
         # Average all models on exit
         self._sync_and_avg_model_params()
         self.model_sync_obj.__exit__(__UpperCamelCase							,__UpperCamelCase							,__UpperCamelCase					)
       def __init__(						self		:					Optional[Any]							,__lowerCamelCase		:					List[Any]							,__lowerCamelCase		:					Dict							,__lowerCamelCase		:					Union[str, Any]							,__lowerCamelCase		:					List[str] = True					):





        '''simple docstring'''



        if accelerator.distributed_type not in [
            DistributedType.NO,
            DistributedType.MULTI_CPU,
            DistributedType.MULTI_GPU,
        ]:
         raise NotImplementedError('''LocalSGD is supported only for CPUs and GPUs (no DeepSpeed or MegatronLM)'''					)
        a		=			enabled and accelerator.distributed_type != DistributedType.NO
        a		=			0
        if self.enabled:
         a		=			accelerator
         a		=			model
         a		=			local_sgd_steps
       def  SCREAMING_SNAKE_CASE_ (						self		:					Any					):





        '''simple docstring'''



        self.num_steps += 1
        if not self.enabled:
         return

        if self.num_steps % self.local_sgd_steps == 0:
         self._sync_and_avg_model_params()




       def  SCREAMING_SNAKE_CASE_ (						self		:					str					):





        '''simple docstring'''



        self.accelerator.wait_for_everyone()
        with self.accelerator.autocast():
         for param in self.model.parameters():
          a		=			self.accelerator.reduce(param.data							,reduction='''mean'''					)













def   SCREAMING_SNAKE_CASE__						(   snake_case_  )   ->  int:


	"""simple docstring"""



	return n * (2 * n - 1)





def   SCREAMING_SNAKE_CASE__						(   snake_case_  )   ->  bool:


	"""simple docstring"""



	a		=			(1 + 2_4 * n) ** 0.5
	return ((1 + root) / 6) % 1 == 0





def   SCREAMING_SNAKE_CASE__						(   snake_case_ = 1_4_4  )   ->  int:


	"""simple docstring"""



	a		=			start
	a		=			hexagonal_num(snake_case_  )
	while not is_pentagonal(snake_case_  ):
		n += 1
		a		=			hexagonal_num(snake_case_  )
	return num


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





