






import torch

from accelerate import Accelerator, DistributedType
class    a   :



      """simple docstring"""


      def __enter__(				self :      Optional[Any] )							->				int:
        if self.enabled:
          __UpperCAmelCase							:     List[Any]									=  self.model.no_sync()
          self.model_sync_obj.__enter__()

        return self
      def __exit__(				self :      Optional[int]		,				__lowercase :      Optional[int]		,				__lowercase :      List[Any]		,				__lowercase :      Optional[int] )							->				str:
        if self.enabled:
          # Average all models on exit
          self._sync_and_avg_model_params()
          self.model_sync_obj.__exit__(__lowercase		,				__lowercase		,				__lowercase )
      def __init__(				self :      List[str]		,				__lowercase :      Accelerator		,				__lowercase :      torch.nn.Module		,				__lowercase :      int		,				__lowercase :      bool = True )							->				Any:
        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)""" )
        __UpperCAmelCase							:     Any									=  enabled and accelerator.distributed_type != DistributedType.NO
        __UpperCAmelCase							:     List[str]									=  0
        if self.enabled:
          __UpperCAmelCase							:     Union[str, Any]									=  accelerator
          __UpperCAmelCase							:     Dict									=  model
          __UpperCAmelCase							:     List[Any]									=  local_sgd_steps
      def      UpperCAmelCase				(				self :      Dict )							->				Optional[Any]:
        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      UpperCAmelCase				(				self :      Optional[int] )							->				Tuple:
        self.accelerator.wait_for_everyone()
        with self.accelerator.autocast():
          for param in self.model.parameters():
            __UpperCAmelCase							:     int									=  self.accelerator.reduce(param.data		,				reduction="""mean""" )










def     lowerCamelCase__				(   ):

  for a in range(300		):
    for b in range(a + 1  ,		400		):
      for c in range(b + 1  ,		500		):
        if (a + b + c) == 1000 and (a**2) + (b**2) == (c**2):
          return a * b * c

  return -1






def     lowerCamelCase__				(   ):

  for a in range(300		):
    for b in range(400		):
      __UpperCAmelCase							:     Optional[Any]									=  1000 - a - b
      if a < b < c and (a**2) + (b**2) == (c**2):
        return a * b * c

  return -1






def     lowerCamelCase__				(   ):
  import timeit

  print(
      timeit.timeit("""solution()"""  ,		setup="""from __main__ import solution"""  ,		number=1000		)		)
  print(
      timeit.timeit(
          """solution_fast()"""  ,		setup="""from __main__ import solution_fast"""  ,		number=1000		)		)


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


