


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 		_snake_case  (				snake_case_							):




 def __init__(		self ,  *_lowerCamelCase ,  _lowerCamelCase=None ,  _lowerCamelCase=None ,  **_lowerCamelCase   ):
       super().__init__(*_A ,  **_A   )
       a						:Optional[Any]										=	eval_examples
       a						:Tuple										=	post_process_function




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase=None ,  _lowerCamelCase=None ,  _lowerCamelCase=None ,  _lowerCamelCase = "eval"   ):
       a						:Optional[Any]										=	self.eval_dataset if eval_dataset is None else eval_dataset
       a						:Optional[Any]										=	self.get_eval_dataloader(_A   )
       a						:str										=	self.eval_examples if eval_examples is None else eval_examples

       # Temporarily disable metric computation, we will do it in the loop here.
       a						:List[str]										=	self.compute_metrics
       a						:List[str]										=	None
       a						:int										=	self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
       a						:Optional[Any]										=	time.time()
       try:
             a						:Any										=	eval_loop(
                 _A ,  description='''Evaluation''' ,  prediction_loss_only=True if compute_metrics is None else None ,  ignore_keys=_A ,  metric_key_prefix=_A ,  )
       finally:
             a						:int										=	compute_metrics
       a						:Tuple										=	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(
               _A ,  _A ,  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
             a						:Dict										=	self.post_process_function(_A ,  _A ,  output.predictions   )
             a						:Optional[int]										=	self.compute_metrics(_A   )

             # Prefix all keys with metric_key_prefix + '_'
             for key in list(metrics.keys()   ):
                   if not key.startswith(F'''{metric_key_prefix}_'''   ):
                         a						:Any										=	metrics.pop(_A   )
             metrics.update(output.metrics   )
       else:
             a						:List[Any]										=	output.metrics

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

       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()   )

       a						:Dict										=	self.callback_handler.on_evaluate(self.args ,  self.state ,  self.control ,  _A   )
       return metrics




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase=None ,  _lowerCamelCase = "test"   ):
       a						:Any										=	self.get_test_dataloader(_A   )

       # Temporarily disable metric computation, we will do it in the loop here.
       a						:Tuple										=	self.compute_metrics
       a						:List[str]										=	None
       a						:List[str]										=	self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
       a						:Optional[int]										=	time.time()
       try:
             a						:Union[str, Any]										=	eval_loop(
                 _A ,  description='''Prediction''' ,  prediction_loss_only=True if compute_metrics is None else None ,  ignore_keys=_A ,  metric_key_prefix=_A ,  )
       finally:
             a						:Optional[Any]										=	compute_metrics
       a						:Tuple										=	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(
               _A ,  _A ,  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

       a						:Dict										=	self.post_process_function(_A ,  _A ,  output.predictions ,  '''predict'''   )
       a						:Any										=	self.compute_metrics(_A   )

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









def     __lowerCamelCase						(			UpperCAmelCase_						:		str						):




      """simple docstring"""





      if n_term == "":
            return []
      a						:list										=	[]
      for temp in range(int(UpperCAmelCase_						)						):
            series.append(F'''1/{temp + 1}''' if series else '''1'''						)
      return series


if __name__ == "__main__":
     snake_case    :   Tuple	    =					input('''Enter the last number (nth term) of the Harmonic Series''')
     print('''Formula of Harmonic Series => 1+1/2+1/3 ..... 1/n''')
     print(harmonic_series(nth_term))





