


'''simple docstring'''






from collections.abc import Generator
from math import sin





def lowerCamelCase__      (						__lowerCamelCase	:							bytes							):







   '''simple docstring'''




   if len(a_							) != 3_2:
      raise ValueError('Input must be of length 32'							)

   _UpperCAmelCase       :       Optional[int]							   =B""
   for i in [3, 2, 1, 0]:
      little_endian += string_aa[8 * i : 8 * i + 8]
   return little_endian





def lowerCamelCase__      (						__lowerCamelCase	:							int							):







   '''simple docstring'''




   if i < 0:
      raise ValueError('Input must be non-negative'							)

   _UpperCAmelCase       :       Any							   =format(a_	,   '08x'							)[-8:]
   _UpperCAmelCase       :       Optional[Any]							   =B""
   for i in [3, 2, 1, 0]:
      little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('utf-8'							)
   return little_endian_hex





def lowerCamelCase__      (						__lowerCamelCase	:							bytes							):







   '''simple docstring'''




   _UpperCAmelCase       :       Union[str, Any]							   =B""
   for char in message:
      bit_string += format(a_	,   '08b'							).encode('utf-8'							)
   _UpperCAmelCase       :       int							   =format(len(a_							)	,   '064b'							).encode('utf-8'							)

   # Pad bit_string to a multiple of 512 chars
   bit_string += b"1"
   while len(a_							) % 5_1_2 != 4_4_8:
      bit_string += b"0"
   bit_string += to_little_endian(start_len[3_2:]							) + to_little_endian(start_len[:3_2]							)

   return bit_string





def lowerCamelCase__      (						__lowerCamelCase	:							bytes							):







   '''simple docstring'''




   if len(a_							) % 5_1_2 != 0:
      raise ValueError('Input must have length that\'s a multiple of 512'							)

   for pos in range(0	,   len(a_							)	,   5_1_2							):
      _UpperCAmelCase       :       Optional[Any]							   =bit_string[pos : pos + 5_1_2]
      _UpperCAmelCase       :       int							   =[]
      for i in range(0	,   5_1_2	,   3_2							):
         block_words.append(int(to_little_endian(block[i : i + 3_2]							)	,   2							)							)
      yield block_words





def lowerCamelCase__      (						__lowerCamelCase	:							int							):







   '''simple docstring'''




   if i < 0:
      raise ValueError('Input must be non-negative'							)

   _UpperCAmelCase       :       Optional[Any]							   =format(a_	,   '032b'							)
   _UpperCAmelCase       :       Any							   =""
   for c in i_str:
      new_str += "1" if c == "0" else "0"
   return int(a_	,   2							)





def lowerCamelCase__      (						__lowerCamelCase	:							int	,   __lowerCamelCase	:							int							):







   '''simple docstring'''




   return (a + b) % 2**3_2





def lowerCamelCase__      (						__lowerCamelCase	:							int	,   __lowerCamelCase	:							int							):







   '''simple docstring'''




   if i < 0:
      raise ValueError('Input must be non-negative'							)
   if shift < 0:
      raise ValueError('Shift must be non-negative'							)
   return ((i << shift) ^ (i >> (3_2 - shift))) % 2**3_2





def lowerCamelCase__      (						__lowerCamelCase	:							bytes							):







   '''simple docstring'''




   _UpperCAmelCase       :       Optional[int]							   =preprocess(a_							)

   _UpperCAmelCase       :       str							   =[int(2**3_2 * abs(sin(i + 1							)							)							) for i in range(6_4							)]

   # Starting states
   _UpperCAmelCase       :       List[Any]							   =0X67_45_23_01
   _UpperCAmelCase       :       List[Any]							   =0XEF_CD_AB_89
   _UpperCAmelCase       :       str							   =0X98_BA_DC_FE
   _UpperCAmelCase       :       Union[str, Any]							   =0X10_32_54_76

   _UpperCAmelCase       :       Dict							   =[
       7,
       1_2,
       1_7,
       2_2,
       7,
       1_2,
       1_7,
       2_2,
       7,
       1_2,
       1_7,
       2_2,
       7,
       1_2,
       1_7,
       2_2,
       5,
       9,
       1_4,
       2_0,
       5,
       9,
       1_4,
       2_0,
       5,
       9,
       1_4,
       2_0,
       5,
       9,
       1_4,
       2_0,
       4,
       1_1,
       1_6,
       2_3,
       4,
       1_1,
       1_6,
       2_3,
       4,
       1_1,
       1_6,
       2_3,
       4,
       1_1,
       1_6,
       2_3,
       6,
       1_0,
       1_5,
       2_1,
       6,
       1_0,
       1_5,
       2_1,
       6,
       1_0,
       1_5,
       2_1,
       6,
       1_0,
       1_5,
       2_1,
   ]

   # Process bit string in chunks, each with 16 32-char words
   for block_words in get_block_words(a_							):
      _UpperCAmelCase       :       Optional[Any]							   =aa
      _UpperCAmelCase       :       Dict							   =ba
      _UpperCAmelCase       :       Optional[int]							   =ca
      _UpperCAmelCase       :       int							   =da

      # Hash current chunk
      for i in range(6_4							):
         if i <= 1_5:
            # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
            _UpperCAmelCase       :       Tuple							   =d ^ (b & (c ^ d))
            _UpperCAmelCase       :       int							   =i
         elif i <= 3_1:
            # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
            _UpperCAmelCase       :       int							   =c ^ (d & (b ^ c))
            _UpperCAmelCase       :       Union[str, Any]							   =(5 * i + 1) % 1_6
         elif i <= 4_7:
            _UpperCAmelCase       :       Dict							   =b ^ c ^ d
            _UpperCAmelCase       :       Any							   =(3 * i + 5) % 1_6
         else:
            _UpperCAmelCase       :       Dict							   =c ^ (b | not_aa(a_							))
            _UpperCAmelCase       :       List[str]							   =(7 * i) % 1_6
         _UpperCAmelCase       :       str							   =(f + a + added_consts[i] + block_words[g]) % 2**3_2
         _UpperCAmelCase       :       Optional[int]							   =d
         _UpperCAmelCase       :       str							   =c
         _UpperCAmelCase       :       List[str]							   =b
         _UpperCAmelCase       :       List[Any]							   =sum_aa(a_	,   left_rotate_aa(a_	,   shift_amounts[i]							)							)

      # Add hashed chunk to running total
      _UpperCAmelCase       :       Optional[int]							   =sum_aa(a_	,   a_							)
      _UpperCAmelCase       :       List[str]							   =sum_aa(a_	,   a_							)
      _UpperCAmelCase       :       str							   =sum_aa(a_	,   a_							)
      _UpperCAmelCase       :       Union[str, Any]							   =sum_aa(a_	,   a_							)

   _UpperCAmelCase       :       Optional[int]							   =reformat_hex(a_							) + reformat_hex(a_							) + reformat_hex(a_							) + reformat_hex(a_							)
   return digest


if __name__ == "__main__":
  import doctest

  doctest.testmod()





'''simple docstring'''






import datasets

from .evaluate import evaluate


lowercase							='\\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'

lowercase							='\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'

lowercase							='\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  __magic_name__							(		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  ,							snake_case  ,							snake_case)						->  int:




          '''simple docstring'''
          _UpperCAmelCase       :       Optional[int]							   ={prediction['id']: prediction['prediction_text'] for prediction in predictions}
          _UpperCAmelCase       :       Optional[int]							   =[
              {
                  'paragraphs': [
                      {
                          'qas': [
                              {
                                  'answers': [{'text': answer_text} for answer_text in ref['answers']['text']],
                                  'id': ref['id'],
                              }
                              for ref in references
                          ]
                      }
                  ]
              }
          ]
          _UpperCAmelCase       :       List[Any]							   =evaluate(dataset=snake_case  ,							predictions=snake_case)
          return score

