


'''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 		a__    (							a__  ):







							def __init__(		self ,   *lowerCamelCase_ ,   lowerCamelCase_=None ,   lowerCamelCase_=None ,   **lowerCamelCase_       )	->							int:
														super().__init__(*lowerCamelCase_ ,   **lowerCamelCase_       )
														lowerCAmelCase__	       =     eval_examples
														lowerCAmelCase__	       =     post_process_function







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_=None ,   lowerCamelCase_=None ,   lowerCamelCase_=None ,   lowerCamelCase_ = "eval"       )	->							str:
														lowerCAmelCase__	       =     self.eval_dataset if eval_dataset is None else eval_dataset
														lowerCAmelCase__	       =     self.get_eval_dataloader(lowerCamelCase_       )
														lowerCAmelCase__	       =     self.eval_examples if eval_examples is None else eval_examples

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

														lowerCAmelCase__	       =     self.callback_handler.on_evaluate(self.args ,   self.state ,   self.control ,   lowerCamelCase_       )
														return metrics







							def   __SCREAMING_SNAKE_CASE							(		self ,   lowerCamelCase_ ,   lowerCamelCase_ ,   lowerCamelCase_=None ,   lowerCamelCase_ = "test"       )	->							Any:
														lowerCAmelCase__	       =     self.get_test_dataloader(lowerCamelCase_       )

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

														lowerCAmelCase__	       =     self.post_process_function(lowerCamelCase_ ,   lowerCamelCase_ ,   output.predictions ,   '''predict'''       )
														lowerCAmelCase__	       =     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}_"""       ):
																												lowerCAmelCase__	       =     metrics.pop(lowerCamelCase_       )
														metrics.update(output.metrics       )
														return PredictionOutput(predictions=predictions.predictions ,   label_ids=predictions.label_ids ,   metrics=lowerCamelCase_       )



'''simple docstring'''






def  _snake_case       (					A = 10			,   A = 22	)						->   int:
							lowerCAmelCase__	       =     range(1			,   A	)
							lowerCAmelCase__	       =     range(1			,   A	)
							return sum(
							    1 for power in powers for base in bases if len(str(base**power	)	) == power	)


if __name__ == "__main__":
		print(f"""{solution(10, 22) = }""")