



"""simple docstring"""




import re
from typing import Callable, List, Optional, Union

import tensorflow as tf


try:
     from tensorflow.keras.optimizers.legacy import Adam
except ImportError:
     from tensorflow.keras.optimizers import Adam


class      a__						(  tf.keras.optimizers.schedules.LearningRateSchedule   ):


   def __init__(							self					:							int,   lowerCAmelCase					:							Tuple,   lowerCAmelCase					:							int,   lowerCAmelCase					:							List[Any],   lowerCAmelCase					:							Dict = 1.0,   lowerCAmelCase					:							Dict = None,   )			->				Tuple:
         super().__init__()
         lowercase     :					Dict 		=      initial_learning_rate
         lowercase     :					Optional[int] 		=      warmup_steps
         lowercase     :					str 		=      power
         lowercase     :					Dict 		=      decay_schedule_fn
         lowercase     :					List[Any] 		=      name


   def __call__(							self					:							Optional[int],   lowerCAmelCase					:							List[str]	)			->				Dict:


         with tf.name_scope(self.name or 'WarmUp'	) as name:
               # Implements polynomial warmup. i.e., if global_step < warmup_steps, the
               # learning rate will be `global_step/num_warmup_steps * init_lr`.
               lowercase     :					int 		=      tf.cast(UpperCamelCase_,   tf.floataa	)
               lowercase     :					int 		=      tf.cast(self.warmup_steps,   tf.floataa	)
               lowercase     :					Any 		=      global_step_float / warmup_steps_float
               lowercase     :					Union[str, Any] 		=      self.initial_learning_rate * tf.math.pow(UpperCamelCase_,   self.power	)
               return tf.cond(
                   global_step_float < warmup_steps_float,   lambda: warmup_learning_rate,   lambda: self.decay_schedule_fn(step - self.warmup_steps	),   name=UpperCamelCase_,   )






   def 				lowercase (							self					:							int	)			->				Tuple:
         return {
             "initial_learning_rate": self.initial_learning_rate,
             "decay_schedule_fn": self.decay_schedule_fn,
             "warmup_steps": self.warmup_steps,
             "power": self.power,
             "name": self.name,
         }




def      lowercase__   (	_UpperCAmelCase		,					_UpperCAmelCase		,					_UpperCAmelCase		,					_UpperCAmelCase = 0.0		,					_UpperCAmelCase = 0.9		,					_UpperCAmelCase = 0.9_9_9		,					_UpperCAmelCase = 1e-8		,					_UpperCAmelCase = None		,					_UpperCAmelCase = None		,					_UpperCAmelCase = 0.0		,					_UpperCAmelCase = 1.0		,					_UpperCAmelCase = None		,					)   ->	Optional[Any]:






      '''simple docstring'''


      lowercase     :					Union[str, Any] 		=      tf.keras.optimizers.schedules.PolynomialDecay(
          initial_learning_rate=__a		,					decay_steps=num_train_steps - num_warmup_steps		,					end_learning_rate=init_lr * min_lr_ratio		,					power=__a		,					)
      if num_warmup_steps:
            lowercase     :					int 		=      WarmUp(
                initial_learning_rate=__a		,					decay_schedule_fn=__a		,					warmup_steps=__a		,					)
      if weight_decay_rate > 0.0:
            lowercase     :					int 		=      AdamWeightDecay(
                learning_rate=__a		,					weight_decay_rate=__a		,					beta_a=__a		,					beta_a=__a		,					epsilon=__a		,					clipnorm=__a		,					global_clipnorm=__a		,					exclude_from_weight_decay=['LayerNorm', 'layer_norm', 'bias']		,					include_in_weight_decay=__a		,					)
      else:
            lowercase     :					Optional[int] 		=      tf.keras.optimizers.Adam(
                learning_rate=__a		,					beta_a=__a		,					beta_a=__a		,					epsilon=__a		,					clipnorm=__a		,					global_clipnorm=__a		,					)
      # We return the optimizer and the LR scheduler in order to better track the
      # evolution of the LR independently of the optimizer.
      return optimizer, lr_schedule


class      a__						(  A__   ):


   def __init__(							self					:							List[Any],   lowerCAmelCase					:							Dict = 0.001,   lowerCAmelCase					:							Optional[Any] = 0.9,   lowerCAmelCase					:							int = 0.999,   lowerCAmelCase					:							Optional[int] = 1e-7,   lowerCAmelCase					:							Optional[int] = False,   lowerCAmelCase					:							Dict = 0.0,   lowerCAmelCase					:							str = None,   lowerCAmelCase					:							List[str] = None,   lowerCAmelCase					:							Union[str, Any] = "AdamWeightDecay",   **lowerCAmelCase					:							List[Any],   )			->				str:
         super().__init__(UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_,   **UpperCamelCase_	)
         lowercase     :					Any 		=      weight_decay_rate
         lowercase     :					Union[str, Any] 		=      include_in_weight_decay
         lowercase     :					Optional[int] 		=      exclude_from_weight_decay


   @classmethod
   def 				lowercase (							cls					:							Any,   lowerCAmelCase					:							Union[str, Any]	)			->				List[Any]:
         lowercase     :					Tuple 		=      {'''WarmUp''': WarmUp}
         return super(UpperCamelCase_,   cls	).from_config(UpperCamelCase_,   custom_objects=UpperCamelCase_	)


   def 				lowercase (							self					:							Optional[int],   lowerCAmelCase					:							str,   lowerCAmelCase					:							str,   lowerCAmelCase					:							str	)			->				Tuple:
         super(UpperCamelCase_,   self	)._prepare_local(UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_	)
         lowercase     :					List[str] 		=      tf.constant(
             self.weight_decay_rate,   name='adam_weight_decay_rate'	)


   def 				lowercase (							self					:							str,   lowerCAmelCase					:							Union[str, Any],   lowerCAmelCase					:							int,   lowerCAmelCase					:							Optional[Any]	)			->				List[str]:
         lowercase     :					Optional[int] 		=      self._do_use_weight_decay(var.name	)
         if do_decay:
               return var.assign_sub(
                   learning_rate * var * apply_state[(var.device, var.dtype.base_dtype)]['weight_decay_rate'],   use_locking=self._use_locking,   )
         return tf.no_op()


   def 				lowercase (							self					:							Dict,   lowerCAmelCase					:							List[Any],   lowerCAmelCase					:							str=None,   **lowerCAmelCase					:							Any	)			->				Optional[Any]:
         lowercase     :					List[str] 		=      list(zip(*UpperCamelCase_	)	)
         return super(UpperCamelCase_,   self	).apply_gradients(zip(UpperCamelCase_,   UpperCamelCase_	),   name=UpperCamelCase_,   **UpperCamelCase_	)


   def 				lowercase (							self					:							str,   lowerCAmelCase					:							Union[str, Any],   lowerCAmelCase					:							Union[str, Any],   lowerCAmelCase					:							List[str]	)			->				int:


         if apply_state is None:
               return self._decayed_lr_t[var_dtype], {}

         lowercase     :					Dict 		=      apply_state or {}
         lowercase     :					str 		=      apply_state.get((var_device, var_dtype)	)
         if coefficients is None:
               lowercase     :					List[str] 		=      self._fallback_apply_state(UpperCamelCase_,   UpperCamelCase_	)
               lowercase     :					List[Any] 		=      coefficients

         return coefficients["lr_t"], {"apply_state": apply_state}


   def 				lowercase (							self					:							Union[str, Any],   lowerCAmelCase					:							Any,   lowerCAmelCase					:							int,   lowerCAmelCase					:							List[str]=None	)			->				Any:
         lowercase     :					Union[str, Any] 		=      self._get_lr(var.device,   var.dtype.base_dtype,   UpperCamelCase_	)
         lowercase     :					Dict 		=      self._decay_weights_op(UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_	)
         with tf.control_dependencies([decay]	):
               return super(UpperCamelCase_,   self	)._resource_apply_dense(UpperCamelCase_,   UpperCamelCase_,   **UpperCamelCase_	)


   def 				lowercase (							self					:							List[Any],   lowerCAmelCase					:							List[Any],   lowerCAmelCase					:							Any,   lowerCAmelCase					:							List[str],   lowerCAmelCase					:							Union[str, Any]=None	)			->				int:
         lowercase     :					Union[str, Any] 		=      self._get_lr(var.device,   var.dtype.base_dtype,   UpperCamelCase_	)
         lowercase     :					Dict 		=      self._decay_weights_op(UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_	)
         with tf.control_dependencies([decay]	):
               return super(UpperCamelCase_,   self	)._resource_apply_sparse(UpperCamelCase_,   UpperCamelCase_,   UpperCamelCase_,   **UpperCamelCase_	)


   def 				lowercase (							self					:							str	)			->				str:
         lowercase     :					Any 		=      super().get_config()
         config.update({'weight_decay_rate': self.weight_decay_rate}	)
         return config






   def 				lowercase (							self					:							Union[str, Any],   lowerCAmelCase					:							str	)			->				Optional[Any]:


         if self.weight_decay_rate == 0:
               return False

         if self._include_in_weight_decay:
               for r in self._include_in_weight_decay:
                     if re.search(UpperCamelCase_,   UpperCamelCase_	) is not None:
                           return True

         if self._exclude_from_weight_decay:
               for r in self._exclude_from_weight_decay:
                     if re.search(UpperCamelCase_,   UpperCamelCase_	) is not None:
                           return False
         return True




class      a__						(  A__   ):


   def __init__(							self					:							str	)			->				List[Any]:
         lowercase     :					Union[str, Any] 		=      []
         lowercase     :					Tuple 		=      None


   @property
   def 				lowercase (							self					:							Optional[int]	)			->				str:


         if self._accum_steps is None:
               lowercase     :					List[str] 		=      tf.Variable(
                   tf.constant(0,   dtype=tf.intaa	),   trainable=UpperCamelCase_,   synchronization=tf.VariableSynchronization.ON_READ,   aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA,   )

         return self._accum_steps.value()


   @property
   def 				lowercase (							self					:							str	)			->				Optional[int]:


         if not self._gradients:
               raise ValueError('The accumulator should be called first to initialize the gradients'	)
         return [gradient.value() if gradient is not None else gradient for gradient in self._gradients]


   def __call__(							self					:							Optional[int],   lowerCAmelCase					:							List[Any]	)			->				Optional[Any]:


         if not self._gradients:
               lowercase     :					Tuple 		=      self.step  # Create the step variable.
               self._gradients.extend(
                   [
                       tf.Variable(
                           tf.zeros_like(UpperCamelCase_	),   trainable=UpperCamelCase_,   synchronization=tf.VariableSynchronization.ON_READ,   aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA,   )
                       if gradient is not None
                       else gradient
                       for gradient in gradients
                   ]	)
         if len(UpperCamelCase_	) != len(self._gradients	):
               raise ValueError(f'''Expected {len(self._gradients	)} gradients, but got {len(UpperCamelCase_	)}'''	)

         for accum_gradient, gradient in zip(self._gradients,   UpperCamelCase_	):
               if accum_gradient is not None and gradient is not None:
                     accum_gradient.assign_add(UpperCamelCase_	)

         self._accum_steps.assign_add(1	)






   def 				lowercase (							self					:							Union[str, Any]	)			->				str:


         if not self._gradients:
               return
         self._accum_steps.assign(0	)
         for gradient in self._gradients:
               if gradient is not None:
                     gradient.assign(tf.zeros_like(UpperCamelCase_	)	)




'''simple docstring'''
def 			a      (			)  ->	Union[str, Any]:



					'''simple docstring'''






					UpperCamelCase__   :Optional[int]												= []
					UpperCamelCase__   :int												= 1

					while len(__a   ) < 1e6:
										constant.append(str(__a   )   )
										i += 1

					UpperCamelCase__   :Union[str, Any]												= ''''''.join(__a   )

					return (
					    int(constant[0]   )
					    * int(constant[9]   )
					    * int(constant[99]   )
					    * int(constant[999]   )
					    * int(constant[9999]   )
					    * int(constant[99999]   )
					    * int(constant[999999]   )
					)


if __name__ == "__main__":
		print(solution())