


"""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  ):







    """simple docstring"""




    def __init__( self    :   str    ,			*__UpperCAmelCase    :   int    ,			__UpperCAmelCase    :   Tuple=None    ,			__UpperCAmelCase    :   Union[str, Any]=None    ,			**__UpperCAmelCase    :   List[Any]):
      super().__init__(*__UpperCAmelCase    ,			**__UpperCAmelCase)
      a						:		Dict											=      eval_examples
      a						:		int											=      post_process_function






    def      __snake_case							( self    :   Optional[int]    ,			__UpperCAmelCase    :   Optional[int]=None    ,			__UpperCAmelCase    :   int=None    ,			__UpperCAmelCase    :   Dict=None    ,			__UpperCAmelCase    :   str = "eval"):
      a						:		Optional[Any]											=      self.eval_dataset if eval_dataset is None else eval_dataset
      a						:		Dict											=      self.get_eval_dataloader(__UpperCAmelCase)
      a						:		int											=      self.eval_examples if eval_examples is None else eval_examples

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

        # 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(__UpperCAmelCase)
        metrics.update(output.metrics)
      else:
        a						:		List[str]											=      output.metrics

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

      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						:		Optional[Any]											=      self.callback_handler.on_evaluate(self.args    ,			self.state    ,			self.control    ,			__UpperCAmelCase)
      return metrics






    def      __snake_case							( self    :   Union[str, Any]    ,			__UpperCAmelCase    :   Union[str, Any]    ,			__UpperCAmelCase    :   Optional[Any]    ,			__UpperCAmelCase    :   Optional[int]=None    ,			__UpperCAmelCase    :   str = "test"):
      a						:		int											=      self.get_test_dataloader(__UpperCAmelCase)

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

      # 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(__UpperCAmelCase)
      metrics.update(output.metrics)
      return PredictionOutput(predictions=predictions.predictions    ,			label_ids=predictions.label_ids    ,			metrics=__UpperCAmelCase)










"""simple docstring"""







import sys
import turtle


def 					lowercase      (    A_  ,       A_	)->				tuple[float, float]:
  '''simple docstring'''







  return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2


def 					lowercase      (    A_  ,       A_  ,       A_  ,       A_  ,       )->				None:
  '''simple docstring'''







  my_pen.up()
  my_pen.goto(vertexa[0]  ,       vertexa[1]	)
  my_pen.down()
  my_pen.goto(vertexa[0]  ,       vertexa[1]	)
  my_pen.goto(vertexa[0]  ,       vertexa[1]	)
  my_pen.goto(vertexa[0]  ,       vertexa[1]	)

  if depth == 0:
    return

  triangle(A_  ,       get_mid(A_  ,       A_	)  ,       get_mid(A_  ,       A_	)  ,       depth - 1	)
  triangle(A_  ,       get_mid(A_  ,       A_	)  ,       get_mid(A_  ,       A_	)  ,       depth - 1	)
  triangle(A_  ,       get_mid(A_  ,       A_	)  ,       get_mid(A_  ,       A_	)  ,       depth - 1	)


if __name__ == "__main__":
 if len(sys.argv) != 2:
  raise ValueError(
      """Correct format for using this script: """
      """python fractals.py <int:depth_for_fractal>"""
  )
 __lowercase    =				turtle.Turtle()
 my_pen.ht()
 my_pen.speed(5)
 my_pen.pencolor("""red""")

 __lowercase    =				[(-175, -125), (0, 175), (175, -125)]  # vertices of triangle
 triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))






