
"""simple docstring"""






import datasets

from .evaluate import evaluate


__SCREAMING_SNAKE_CASE							=     '\\n@inproceedings{Rajpurkar2016SQuAD10,\n  title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n  author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n  booktitle={EMNLP},\n  year={2016}\n}\n'

__SCREAMING_SNAKE_CASE							=     '\nThis metric wrap the official scoring script for version 1 of the Stanford Question Answering Dataset (SQuAD).\n\nStanford Question Answering Dataset (SQuAD) is a reading comprehension dataset, consisting of questions posed by\ncrowdworkers on a set of Wikipedia articles, where the answer to every question is a segment of text, or span,\nfrom the corresponding reading passage, or the question might be unanswerable.\n'

__SCREAMING_SNAKE_CASE							=     '\nComputes SQuAD scores (F1 and EM).\nArgs:\n    predictions: List of question-answers dictionaries with the following key-values:\n        - \'id\': id of the question-answer pair as given in the references (see below)\n        - \'prediction_text\': the text of the answer\n    references: List of question-answers dictionaries with the following key-values:\n        - \'id\': id of the question-answer pair (see above),\n        - \'answers\': a Dict in the SQuAD dataset format\n            {\n                \'text\': list of possible texts for the answer, as a list of strings\n                \'answer_start\': list of start positions for the answer, as a list of ints\n            }\n            Note that answer_start values are not taken into account to compute the metric.\nReturns:\n    \'exact_match\': Exact match (the normalized answer exactly match the gold answer)\n    \'f1\': The F-score of predicted tokens versus the gold answer\nExamples:\n\n    >>> predictions = [{\'prediction_text\': \'1976\', \'id\': \'56e10a3be3433e1400422b22\'}]\n    >>> references = [{\'answers\': {\'answer_start\': [97], \'text\': [\'1976\']}, \'id\': \'56e10a3be3433e1400422b22\'}]\n    >>> squad_metric = datasets.load_metric("squad")\n    >>> results = squad_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'exact_match\': 100.0, \'f1\': 100.0}\n'





@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION   ,							_KWARGS_DESCRIPTION       )
class 				a__					(						datasets.Metric       ):



     def  lowerCamelCase_						(							self :List[str]   ):







      '''simple docstring'''



      return datasets.MetricInfo(
          description=_DESCRIPTION      ,  citation=_CITATION      ,  inputs_description=_KWARGS_DESCRIPTION      ,  features=datasets.Features(
              {
                  'predictions': {'id': datasets.Value('string'   ), 'prediction_text': datasets.Value('string'   )},
                  'references': {
                      'id': datasets.Value('string'   ),
                      'answers': datasets.features.Sequence(
                          {
                              'text': datasets.Value('string'   ),
                              'answer_start': datasets.Value('int32'   ),
                          }   ),
                  },
              }   )      ,  codebase_urls=['https://rajpurkar.github.io/SQuAD-explorer/']      ,  reference_urls=['https://rajpurkar.github.io/SQuAD-explorer/']      ,  )




     def  lowerCamelCase_						(							self :Optional[int]      ,  _lowerCamelCase :Any      ,  _lowerCamelCase :int   ):







      '''simple docstring'''



      UpperCamelCase_     :					Optional[Any]   	={prediction['id']: prediction['prediction_text'] for prediction in predictions}
      UpperCamelCase_     :					Optional[Any]   	=[
          {
              'paragraphs': [
                  {
                      'qas': [
                          {
                              'answers': [{'text': answer_text} for answer_text in ref['answers']['text']],
                              'id': ref['id'],
                          }
                          for ref in references
                      ]
                  }
              ]
          }
      ]
      UpperCamelCase_     :					Tuple   	=evaluate(dataset=_lowerCamelCase      ,  predictions=_lowerCamelCase   )
      return score


"""simple docstring"""






from manim import *





class 				a__					(						A__       ):



     def  lowerCamelCase_						(							self :List[Any]   ):







      '''simple docstring'''



      UpperCamelCase_     :					Tuple   	=Rectangle(height=0.5      ,  width=0.5   )
      UpperCamelCase_     :					Any   	=Rectangle(height=0.46      ,  width=0.46   ).set_stroke(width=0   )

      UpperCamelCase_     :					Any   	=[mem.copy() for i in range(6   )]
      UpperCamelCase_     :					Optional[int]   	=[mem.copy() for i in range(6   )]
      UpperCamelCase_     :					List[str]   	=VGroup(*_lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )
      UpperCamelCase_     :					Optional[int]   	=VGroup(*_lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )
      UpperCamelCase_     :					Union[str, Any]   	=VGroup(_lowerCamelCase      ,  _lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )
      UpperCamelCase_     :					str   	=Text('CPU'      ,  font_size=24   )
      UpperCamelCase_     :					str   	=Group(_lowerCamelCase      ,  _lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0.5      ,  aligned_edge=_lowerCamelCase   )
      cpu.move_to([-2.5, -0.5, 0]   )
      self.add(_lowerCamelCase   )

      UpperCamelCase_     :					int   	=[mem.copy() for i in range(4   )]
      UpperCamelCase_     :					Any   	=VGroup(*_lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )
      UpperCamelCase_     :					List[Any]   	=Text('GPU'      ,  font_size=24   )
      UpperCamelCase_     :					Any   	=Group(_lowerCamelCase      ,  _lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0.5      ,  aligned_edge=_lowerCamelCase   )
      gpu.move_to([-1, -1, 0]   )
      self.add(_lowerCamelCase   )

      UpperCamelCase_     :					List[str]   	=[mem.copy() for i in range(6   )]
      UpperCamelCase_     :					str   	=VGroup(*_lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )

      UpperCamelCase_     :					Optional[int]   	=Text('Model'      ,  font_size=24   )
      UpperCamelCase_     :					List[Any]   	=Group(_lowerCamelCase      ,  _lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0.5      ,  aligned_edge=_lowerCamelCase   )
      model.move_to([3, -1.0, 0]   )
      self.add(_lowerCamelCase   )

      UpperCamelCase_     :					int   	=[]
      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)

       UpperCamelCase_     :					str   	=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   )

      UpperCamelCase_     :					List[str]   	=[mem.copy() for i in range(6   )]
      UpperCamelCase_     :					Any   	=VGroup(*_lowerCamelCase   ).arrange(_lowerCamelCase      ,  buff=0   )

      UpperCamelCase_     :					Optional[int]   	=Text('Loaded Checkpoint'      ,  font_size=24   )
      UpperCamelCase_     :					List[Any]   	=Group(_lowerCamelCase      ,  _lowerCamelCase   ).arrange(_lowerCamelCase      ,  aligned_edge=_lowerCamelCase      ,  buff=0.4   )
      checkpoint.move_to([3, 0.5, 0]   )

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

      UpperCamelCase_     :					Optional[Any]   	=MarkupText(
          f'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'''      ,  font_size=18      ,  )

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

      self.add(_lowerCamelCase      ,  _lowerCamelCase   )

      UpperCamelCase_     :					Any   	=MarkupText(
          f'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''      ,  font_size=18      ,  )

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

      UpperCamelCase_     :					Dict   	=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=24      ,  )
      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   )   )

      UpperCamelCase_     :					Union[str, Any]   	=[]
      UpperCamelCase_     :					List[Any]   	=[]
      for i, rect in enumerate(_lowerCamelCase   ):
       UpperCamelCase_     :					str   	=fill.copy().set_fill(_lowerCamelCase      ,  opacity=0.7   )
       target.move_to(_lowerCamelCase   )
       first_animations.append(GrowFromCenter(_lowerCamelCase      ,  run_time=1   )   )

       UpperCamelCase_     :					Any   	=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()
