
'''simple docstring'''







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 						__UpperCAmelCase      (					_lowerCamelCase						):


							def __init__(       self    ,   *lowerCAmelCase_    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_=None    ,   **lowerCAmelCase_  ):





								"""simple docstring"""






								super().__init__(*lowerCAmelCase_    ,   **lowerCAmelCase_  )
								_snake_case   						=		eval_examples
								_snake_case   						=		post_process_function


							def  lowerCamelCase				(       self    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_ = "eval"  ):





								"""simple docstring"""






								_snake_case   						=		self.eval_dataset if eval_dataset is None else eval_dataset
								_snake_case   						=		self.get_eval_dataloader(lowerCAmelCase_  )
								_snake_case   						=		self.eval_examples if eval_examples is None else eval_examples

								# Temporarily disable metric computation, we will do it in the loop here.
								_snake_case   						=		self.compute_metrics
								_snake_case   						=		None
								_snake_case   						=		self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
								_snake_case   						=		time.time()
								try:
									_snake_case   						=		eval_loop(
									    lowerCAmelCase_    ,   description='Evaluation'    ,   prediction_loss_only=True if compute_metrics is None else None    ,   ignore_keys=lowerCAmelCase_    ,   metric_key_prefix=lowerCAmelCase_    ,   )
								finally:
									_snake_case   						=		compute_metrics
								_snake_case   						=		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(
								        lowerCAmelCase_    ,   lowerCAmelCase_    ,   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
									_snake_case   						=		self.post_process_function(lowerCAmelCase_    ,   lowerCAmelCase_    ,   output.predictions  )
									_snake_case   						=		self.compute_metrics(lowerCAmelCase_  )

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

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

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

								_snake_case   						=		self.callback_handler.on_evaluate(self.args    ,   self.state    ,   self.control    ,   lowerCAmelCase_  )
								return metrics




							def  lowerCamelCase				(       self    ,   lowerCAmelCase_    ,   lowerCAmelCase_    ,   lowerCAmelCase_=None    ,   lowerCAmelCase_ = "test"  ):





								"""simple docstring"""






								_snake_case   						=		self.get_test_dataloader(lowerCAmelCase_  )

								# Temporarily disable metric computation, we will do it in the loop here.
								_snake_case   						=		self.compute_metrics
								_snake_case   						=		None
								_snake_case   						=		self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
								_snake_case   						=		time.time()
								try:
									_snake_case   						=		eval_loop(
									    lowerCAmelCase_    ,   description='Prediction'    ,   prediction_loss_only=True if compute_metrics is None else None    ,   ignore_keys=lowerCAmelCase_    ,   metric_key_prefix=lowerCAmelCase_    ,   )
								finally:
									_snake_case   						=		compute_metrics
								_snake_case   						=		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(
								        lowerCAmelCase_    ,   lowerCAmelCase_    ,   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

								_snake_case   						=		self.post_process_function(lowerCAmelCase_    ,   lowerCAmelCase_    ,   output.predictions    ,   'predict'  )
								_snake_case   						=		self.compute_metrics(lowerCAmelCase_  )

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



'''simple docstring'''







def 				SCREAMING_SNAKE_CASE__	(   __A = 100	)       ->	int:
	_snake_case   						=		n * (n + 1) * (2 * n + 1) / 6
	_snake_case   						=		(n * (n + 1) / 2) ** 2
	return int(square_of_sum - sum_of_squares	)


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

