





from manim import *



class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  def 				lowercase		(				self :		Dict     )							->						Optional[int]:
     __lowerCAmelCase								=	Rectangle(height=0.5					,  width=0.5     )
     __lowerCAmelCase								=	Rectangle(height=0.46					,  width=0.46     ).set_stroke(width=0     )

     __lowerCAmelCase								=	[mem.copy() for i in range(6     )]
     __lowerCAmelCase								=	[mem.copy() for i in range(6     )]
     __lowerCAmelCase								=	VGroup(*lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )
     __lowerCAmelCase								=	VGroup(*lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )
     __lowerCAmelCase								=	VGroup(lowerCAmelCase_					,  lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )
     __lowerCAmelCase								=	Text('CPU'					,  font_size=2_4     )
     __lowerCAmelCase								=	Group(lowerCAmelCase_					,  lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0.5					,  aligned_edge=lowerCAmelCase_     )
     cpu.move_to([-2.5, -0.5, 0]     )
     self.add(lowerCAmelCase_     )

     __lowerCAmelCase								=	[mem.copy() for i in range(4     )]
     __lowerCAmelCase								=	VGroup(*lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )
     __lowerCAmelCase								=	Text('GPU'					,  font_size=2_4     )
     __lowerCAmelCase								=	Group(lowerCAmelCase_					,  lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0.5					,  aligned_edge=lowerCAmelCase_     )
     gpu.move_to([-1, -1, 0]     )
     self.add(lowerCAmelCase_     )

     __lowerCAmelCase								=	[mem.copy() for i in range(6     )]
     __lowerCAmelCase								=	VGroup(*lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )

     __lowerCAmelCase								=	Text('Model'					,  font_size=2_4     )
     __lowerCAmelCase								=	Group(lowerCAmelCase_					,  lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0.5					,  aligned_edge=lowerCAmelCase_     )
     model.move_to([3, -1.0, 0]     )
     self.add(lowerCAmelCase_     )

     __lowerCAmelCase								=	[]
     for i, rect in enumerate(lowerCAmelCase_     ):
        rect.set_stroke(lowerCAmelCase_     )
        # target = fill.copy().set_fill(YELLOW, opacity=0.7)
        # target.move_to(rect)
        # self.add(target)

        __lowerCAmelCase								=	Rectangle(height=0.46 / 4					,  width=0.46 / 3     ).set_stroke(width=0.0     ).set_fill(lowerCAmelCase_					,  opacity=0.7     )

        if i == 0:
           cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT     )					,  buff=0.02					,  direction=lowerCAmelCase_     )
           cpu_target.set_x(cpu_target.get_x() + 0.1     )
        elif i == 3:
           cpu_target.next_to(cpu_targs[0]					,  direction=lowerCAmelCase_					,  buff=0.0     )
        else:
           cpu_target.next_to(cpu_targs[i - 1]					,  direction=lowerCAmelCase_					,  buff=0.0     )
        self.add(lowerCAmelCase_     )
        cpu_targs.append(lowerCAmelCase_     )

     __lowerCAmelCase								=	[mem.copy() for i in range(6     )]
     __lowerCAmelCase								=	VGroup(*lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  buff=0     )

     __lowerCAmelCase								=	Text('Loaded Checkpoint'					,  font_size=2_4     )
     __lowerCAmelCase								=	Group(lowerCAmelCase_					,  lowerCAmelCase_     ).arrange(lowerCAmelCase_					,  aligned_edge=lowerCAmelCase_					,  buff=0.4     )
     checkpoint.move_to([3, 0.5, 0]     )

     __lowerCAmelCase								=	Square(side_length=2.2     )
     key.move_to([-5, 2, 0]     )

     __lowerCAmelCase								=	MarkupText(
         f"""<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"""					,  font_size=1_8					,  )

     key_text.move_to([-5, 2.4, 0]     )

     self.add(lowerCAmelCase_					,  lowerCAmelCase_     )

     __lowerCAmelCase								=	MarkupText(
         f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""					,  font_size=1_8					,  )

     blue_text.next_to(lowerCAmelCase_					,  DOWN * 2.4					,  aligned_edge=key_text.get_left()     )

     __lowerCAmelCase								=	MarkupText(
         f"""Next, a <i><span fgcolor=\"{BLUE}\">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor=\"{BLUE}\">single shard</span>."""					,  font_size=2_4					,  )
     step_a.move_to([2, 2, 0]     )
     self.play(Write(lowerCAmelCase_     )					,  Write(lowerCAmelCase_     )     )

     self.play(Write(lowerCAmelCase_					,  run_time=1     )					,  Create(lowerCAmelCase_					,  run_time=1     )     )

     __lowerCAmelCase								=	[]
     __lowerCAmelCase								=	[]
     for i, rect in enumerate(lowerCAmelCase_     ):
        __lowerCAmelCase								=	fill.copy().set_fill(lowerCAmelCase_					,  opacity=0.7     )
        target.move_to(lowerCAmelCase_     )
        first_animations.append(GrowFromCenter(lowerCAmelCase_					,  run_time=1     )     )

        __lowerCAmelCase								=	target.copy()
        cpu_target.generate_target()
        if i < 5:
           cpu_target.target.move_to(cpu_left_col_base[i + 1]     )
        else:
           cpu_target.target.move_to(cpu_right_col_base[i - 5]     )
        second_animations.append(MoveToTarget(lowerCAmelCase_					,  run_time=1.5     )     )

     self.play(*lowerCAmelCase_     )
     self.play(*lowerCAmelCase_     )
     self.wait()








import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


_snake_case  :    Tuple						    =  '\\n@article{hendrycksmath2021,\n  title={Measuring Mathematical Problem Solving With the MATH Dataset},\n  author={Dan Hendrycks\n    and Collin Burns\n    and Saurav Kadavath\n    and Akul Arora\n    and Steven Basart\n    and Eric Tang\n    and Dawn Song\n    and Jacob Steinhardt},\n  journal={arXiv preprint arXiv:2103.03874},\n  year={2021}\n}\n'


_snake_case  :    str						    =  '\\nThis metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.\nIt first canonicalizes the inputs (e.g., converting "1/2" to "\\frac{1}{2}") and then computes accuracy.\n'


_snake_case  :    List[str]						    =  R'\nCalculates accuracy after canonicalizing inputs.\n\nArgs:\n    predictions: list of predictions to score. Each prediction\n        is a string that contains natural language and LaTex.\n    references: list of reference for each prediction. Each\n        reference is a string that contains natural language\n        and LaTex.\nReturns:\n    accuracy: accuracy after canonicalizing inputs\n        (e.g., converting "1/2" to "\\frac{1}{2}")\n\nExamples:\n    >>> metric = datasets.load_metric("competition_math")\n    >>> results = metric.compute(references=["\\frac{1}{2}"], predictions=["1/2"])\n    >>> print(results)\n    {\'accuracy\': 1.0}\n'



@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION		,    _KWARGS_DESCRIPTION    )
class 				_UpperCAmelCase    (    datasets.Metric    ):

  """simple docstring"""


  def 				lowercase		(				self :		str     )							->						int:
     return datasets.MetricInfo(
         description=_DESCRIPTION					,  citation=_CITATION					,  inputs_description=_KWARGS_DESCRIPTION					,  features=datasets.Features(
             {
                 'predictions': datasets.Value('string'     ),
                 'references': datasets.Value('string'     ),
             }     )					,  homepage='https://github.com/hendrycks/math'					,  codebase_urls=['https://github.com/hendrycks/math']					,  )






  def 				lowercase		(				self :		str					,  lowerCAmelCase_ :		Any					,  lowerCAmelCase_ :		Optional[int]     )							->						List[Any]:
     __lowerCAmelCase								=	0.0
     for i, j in zip(lowerCAmelCase_					,  lowerCAmelCase_     ):
        n_correct += 1.0 if math_equivalence.is_equiv(lowerCAmelCase_					,  lowerCAmelCase_     ) else 0.0
     __lowerCAmelCase								=	n_correct / len(lowerCAmelCase_     )
     return {
         "accuracy": accuracy,
     }

