





import math
import time

from transformers import Trainer, is_torch_tpu_available
from transformers.trainer_utils import PredictionOutput, speed_metrics


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





class    lowerCAmelCase				(  lowercase_   ):







  def __init__(     self    :List[Any]       ,				*_lowercase    :str       ,				_lowercase    :Dict=None       ,				_lowercase    :List[Any]=None       ,				**_lowercase    :Union[str, Any]   ):






     '''simple docstring'''





     super().__init__(*_lowercase       ,				**_lowercase   )
     lowercase__					  =    eval_examples
     lowercase__					  =    post_process_function







  def     UpperCAmelCase	(     self    :str       ,				_lowercase    :Tuple=None       ,				_lowercase    :List[str]=None       ,				_lowercase    :List[Any]=None       ,				_lowercase    :Union[str, Any] = "eval"   ):






     '''simple docstring'''





     lowercase__					  =    self.eval_dataset if eval_dataset is None else eval_dataset
     lowercase__					  =    self.get_eval_dataloader(_lowercase   )
     lowercase__					  =    self.eval_examples if eval_examples is None else eval_examples

     # Temporarily disable metric computation, we will do it in the loop here.
     lowercase__					  =    self.compute_metrics
     lowercase__					  =    None
     lowercase__					  =    self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
     lowercase__					  =    time.time()
     try:
        lowercase__					  =    eval_loop(
            _lowercase       ,				description="Evaluation"       ,				prediction_loss_only=True if compute_metrics is None else None       ,				ignore_keys=_lowercase       ,				metric_key_prefix=_lowercase       ,				)
     finally:
        lowercase__					  =    compute_metrics
     lowercase__					  =    self.args.eval_batch_size * self.args.world_size
     if f'''{metric_key_prefix}_jit_compilation_time''' in output.metrics:
        start_time += output.metrics[f'''{metric_key_prefix}_jit_compilation_time''']
     output.metrics.update(
         speed_metrics(
             _lowercase       ,				_lowercase       ,				num_samples=output.num_samples       ,				num_steps=math.ceil(output.num_samples / total_batch_size   )       ,				)   )
     if self.post_process_function is not None and self.compute_metrics is not None and self.args.should_save:
        # Only the main node write the results by default
        lowercase__					  =    self.post_process_function(_lowercase       ,				_lowercase       ,				output.predictions   )
        lowercase__					  =    self.compute_metrics(_lowercase   )

        # Prefix all keys with metric_key_prefix + '_'
        for key in list(metrics.keys()   ):
           if not key.startswith(f'''{metric_key_prefix}_'''   ):
              lowercase__					  =    metrics.pop(_lowercase   )
        metrics.update(output.metrics   )
     else:
        lowercase__					  =    output.metrics

     if self.args.should_log:
        # Only the main node log the results by default
        self.log(_lowercase   )

     if self.args.tpu_metrics_debug or self.args.debug:
        # tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)
        xm.master_print(met.metrics_report()   )

     lowercase__					  =    self.callback_handler.on_evaluate(self.args       ,				self.state       ,				self.control       ,				_lowercase   )
     return metrics







  def     UpperCAmelCase	(     self    :Optional[Any]       ,				_lowercase    :List[Any]       ,				_lowercase    :List[Any]       ,				_lowercase    :int=None       ,				_lowercase    :int = "test"   ):






     '''simple docstring'''





     lowercase__					  =    self.get_test_dataloader(_lowercase   )

     # Temporarily disable metric computation, we will do it in the loop here.
     lowercase__					  =    self.compute_metrics
     lowercase__					  =    None
     lowercase__					  =    self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
     lowercase__					  =    time.time()
     try:
        lowercase__					  =    eval_loop(
            _lowercase       ,				description="Prediction"       ,				prediction_loss_only=True if compute_metrics is None else None       ,				ignore_keys=_lowercase       ,				metric_key_prefix=_lowercase       ,				)
     finally:
        lowercase__					  =    compute_metrics
     lowercase__					  =    self.args.eval_batch_size * self.args.world_size
     if f'''{metric_key_prefix}_jit_compilation_time''' in output.metrics:
        start_time += output.metrics[f'''{metric_key_prefix}_jit_compilation_time''']
     output.metrics.update(
         speed_metrics(
             _lowercase       ,				_lowercase       ,				num_samples=output.num_samples       ,				num_steps=math.ceil(output.num_samples / total_batch_size   )       ,				)   )

     if self.post_process_function is None or self.compute_metrics is None:
        return output

     lowercase__					  =    self.post_process_function(_lowercase       ,				_lowercase       ,				output.predictions       ,				"predict"   )
     lowercase__					  =    self.compute_metrics(_lowercase   )

     # Prefix all keys with metric_key_prefix + '_'
     for key in list(metrics.keys()   ):
        if not key.startswith(f'''{metric_key_prefix}_'''   ):
           lowercase__					  =    metrics.pop(_lowercase   )
     metrics.update(output.metrics   )
     return PredictionOutput(predictions=predictions.predictions       ,				label_ids=predictions.label_ids       ,				metrics=_lowercase   )










'''simple docstring'''


def 		_lowercase (SCREAMING_SNAKE_CASE							):




     '''simple docstring'''





     __A	:       List[str]      =							1
     __A	:       Union[str, Any]      =							2
     while i * i <= n:
          __A	:       List[Any]      =							0
          while n % i == 0:
               n //= i
               multiplicity += 1
          n_divisors *= multiplicity + 1
          i += 1
     if n > 1:
          n_divisors *= 2
     return n_divisors


def 		_lowercase ():




     '''simple docstring'''





     __A	:       Optional[Any]      =							1
     __A	:       Dict      =							1

     while True:
          i += 1
          t_num += i

          if count_divisors(SCREAMING_SNAKE_CASE							) > 500:
               break

     return t_num


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

