
"""simple docstring"""

from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
      import torch

if is_torch_tpu_available(check_device=False):
      import torch_xla.core.xla_model as xm


UpperCamelCase			:       Optional[int]									=				logging.get_logger(__name__)

@dataclass
class __lowerCAmelCase	(   __SCREAMING_SNAKE_CASE    ):
     lowercase		     =		[
         "no_inference",
         "no_cuda",
         "no_tpu",
         "no_speed",
         "no_memory",
         "no_env_print",
         "no_multi_process",
     ]





     def __init__(			self			,  **__UpperCAmelCase   ):

      '''simple docstring'''




      for deprecated_arg in self.deprecated_args:
       if deprecated_arg in kwargs:
        __UpperCamelCase       						= deprecated_arg[3:]
        setattr(self			,  __UpperCAmelCase			,  not kwargs.pop(__UpperCAmelCase   )   )
        logger.warning(
            F'{deprecated_arg} is depreciated. Please use --no_{positive_arg} or'
            F' {positive_arg}={kwargs[positive_arg]}'   )

      __UpperCamelCase       						= kwargs.pop('torchscript'			,  self.torchscript   )
      __UpperCamelCase       						= kwargs.pop('torch_xla_tpu_print_metrics'			,  self.torch_xla_tpu_print_metrics   )
      __UpperCamelCase       						= kwargs.pop('fp16_opt_level'			,  self.fpaa_opt_level   )
      super().__init__(**__UpperCAmelCase   )

     lowercase		     =		field(default=__SCREAMING_SNAKE_CASE    ,						metadata={"help": "Trace the models using torchscript"}    )
     lowercase		     =		field(default=__SCREAMING_SNAKE_CASE    ,						metadata={"help": "Print Xla/PyTorch tpu metrics"}    )
     lowercase		     =		field(
         default="O1"    ,						metadata={
             "help": (
                 "For fp16: Apex AMP optimization level selected in ['O0', 'O1', 'O2', and 'O3']. "
                 "See details at https://nvidia.github.io/apex/amp.html"
             )
         }    ,						)





     @cached_property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      requires_backends(self			,  ['torch']   )
      logger.info('PyTorch: setting up devices'   )
      if not self.cuda:
       __UpperCamelCase       						= torch.device('cpu'   )
       __UpperCamelCase       						= 0
      elif is_torch_tpu_available():
       __UpperCamelCase       						= xm.xla_device()
       __UpperCamelCase       						= 0
      else:
       __UpperCamelCase       						= torch.device('cuda' if torch.cuda.is_available() else 'cpu'   )
       __UpperCamelCase       						= torch.cuda.device_count()
      return device, n_gpu





     @property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      return is_torch_tpu_available() and self.tpu





     @property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      requires_backends(self			,  ['torch']   )
      # TODO(PVP): currently only single GPU is supported
      return torch.cuda.current_device()





     @property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      requires_backends(self			,  ['torch']   )
      return self._setup_devices[0]





     @property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      requires_backends(self			,  ['torch']   )
      return self._setup_devices[1]







     @property
     def 		UpperCAmelCase      (			self   ):

      '''simple docstring'''




      return self.n_gpu > 0





"""simple docstring"""

def 							A		(       snake_case   :int	)   ->			bool:
 return str(snake_case	) == str(snake_case	)[::-1]






def 							A		(       snake_case   :int	)   ->			int:
 return int(snake_case	) + int(str(snake_case	)[::-1]	)






def 							A		(       snake_case   :int = 1_0_0_0_0	)   ->			int:
 __UpperCamelCase       						= []
 for num in range(1       ,      snake_case	):
  __UpperCamelCase       						= 0
  __UpperCamelCase       						= num
  while iterations < 5_0:
   __UpperCamelCase       						= sum_reverse(snake_case	)
   iterations += 1
   if is_palindrome(snake_case	):
    break
  else:
   lychrel_nums.append(snake_case	)
 return len(snake_case	)


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



