code: 
  
  
  
  
  
  import argparse
  import json
  import re
  import string
  import sys
  from collections import Counter
  
  
  
  
  
  def 		UpperCamelCase       (							_lowerCamelCase      :      str ):
  
      def remove_articles(_lowerCamelCase      :      Optional[Any] ):
          return re.sub(r"\b(a|an|the)\b"		, " "		, _lowerCamelCase )
  
      def white_space_fix(_lowerCamelCase      :      int ):
          return " ".join(text.split() )
  
      def remove_punc(_lowerCamelCase      :      Dict ):
          A__       =    set(string.punctuation )
          return "".join(ch for ch in text if ch not in exclude )
  
      def lower(_lowerCamelCase      :      Tuple ):
          return text.lower()
  
      return white_space_fix(remove_articles(remove_punc(lower(_lowerCamelCase ) ) ) )
  
  
  
  
  
  def 		UpperCamelCase       (							_lowerCamelCase      :      Union[str, Any]		, _lowerCamelCase      :      int ):
      A__       =    normalize_answer(_lowerCamelCase ).split()
      A__       =    normalize_answer(_lowerCamelCase ).split()
      A__       =    Counter(_lowerCamelCase ) & Counter(_lowerCamelCase )
      A__       =    sum(common.values() )
      if num_same == 0:
          return 0
      A__       =    1.0 * num_same / len(_lowerCamelCase )
      A__       =    1.0 * num_same / len(_lowerCamelCase )
      A__       =    (2 * precision * recall) / (precision + recall)
      return fa
  
  
  
  
  
  def 		UpperCamelCase       (							_lowerCamelCase      :      str		, _lowerCamelCase      :      Any ):
      return normalize_answer(_lowerCamelCase ) == normalize_answer(_lowerCamelCase )
  
  
  
  
  
  def 		UpperCamelCase       (							_lowerCamelCase      :      str		, _lowerCamelCase      :      Optional[int]		, _lowerCamelCase      :      str ):
      A__       =    []
      for ground_truth in ground_truths:
          A__       =    metric_fn(_lowerCamelCase		, _lowerCamelCase )
          scores_for_ground_truths.append(_lowerCamelCase )
      return max(_lowerCamelCase )
  
  
  
  
  
  def 		UpperCamelCase       (							_lowerCamelCase      :      str		, _lowerCamelCase      :      Optional[int] ):
      A__       =    A__       =    A__       =    0
      for article in dataset:
          for paragraph in article["paragraphs"]:
              for qa in paragraph["qas"]:
                  total += 1
                  if qa["id"] not in predictions:
                      A__       =    "Unanswered question " + qa["id"] + " will receive score 0."
                      print(_lowerCamelCase		, file=sys.stderr )
                      continue
                  A__       =    [x["text"] for x in qa["answers"]]
                  A__       =    predictions[qa["id"]]
                  exact_match += metric_max_over_ground_truths(_lowerCamelCase		, _lowerCamelCase		, _lowerCamelCase )
                  fa += metric_max_over_ground_truths(_lowerCamelCase		, _lowerCamelCase		, _lowerCamelCase )
  
      A__       =    1_00.0 * exact_match / total
      A__       =    1_00.0 * fa / total
  
      return {"exact_match": exact_match, "f1": fa}
  
  
  if __name__ == "__main__":
    __lowerCAmelCase							:			List[Any]				="1.1"
    __lowerCAmelCase							:			Tuple				=argparse.ArgumentParser(description="Evaluation for SQuAD " + expected_version)
    parser.add_argument("dataset_file", help="Dataset file")
    parser.add_argument("prediction_file", help="Prediction File")
    __lowerCAmelCase							:			str				=parser.parse_args()
    with open(args.dataset_file) as dataset_file:
      __lowerCAmelCase							:			Optional[int]				=json.load(dataset_file)
      if dataset_json["version"] != expected_version:
        print(
            "Evaluation expects v-" + expected_version + ", but got dataset with v-" + dataset_json["version"],
            file=sys.stderr,
        )
      __lowerCAmelCase							:			List[str]				=dataset_json["data"]
    with open(args.prediction_file) as prediction_file:
      __lowerCAmelCase							:			Optional[Any]				=json.load(prediction_file)
    print(json.dumps(evaluate(dataset, predictions)))
  
  
  
  
style_context: 
  
  
  
  
  
  '''simple docstring'''
  
  import torch
  
  from transformers import AutoTokenizer
  
  
  
  
  
  
  class      UpperCAmelCase			( UpperCamelCase__       ):
   def __init__(       self   :Any		, lowercase_   :Dict							)->							Any:
       A__       =    AutoTokenizer.from_pretrained(lowercase_							)
   def   UpperCAmelCase_							(       self   :Tuple		, lowercase_   :int							)->							Optional[int]:
  
       if isinstance(lowercase_		, lowercase_							) and all(isinstance(_x		, lowercase_							) for _x in x							):
           A__       =    None
           for l in x:
               A__       =    self.tokenizer(
                   lowercase_		, padding="max_length"		, max_length=3_84		, truncation=lowercase_		, return_tensors="pt"		, )
               A__       =    torch.tensor([len(lowercase_							)]							)
               if d is not None:
                   for k in d.keys():
                       A__       =    torch.cat((d[k], t[k])		, 0							)
               else:
                   A__       =    t
  
           A__       =    torch.tensor(self.tokenizer.convert_tokens_to_ids("[E]"							)							)
           A__       =    torch.tensor(self.tokenizer.convert_tokens_to_ids("[/E]"							)							)
  
       elif isinstance(lowercase_		, lowercase_							) and all(isinstance(_x		, lowercase_							) for _x in x							):
           A__       =    self.tokenizer(
               lowercase_		, padding="max_length"		, max_length=3_84		, truncation=lowercase_		, return_tensors="pt"		, )
  
       else:
           raise Exception(
               "Type of parameter x was not recognized! Only `list of strings` for query or `list of lists of"
               " strings` for supports are supported."							)
  
       return d
  
  
  
   def   UpperCAmelCase_							(       self   :Union[str, Any]		, lowercase_   :List[str]		, lowercase_   :str		, lowercase_   :str		, lowercase_   :List[Any]		, lowercase_   :Dict=0.7_0							)->							int:
       A__       =    []
       for idx in range(len(W_query["input_ids"]							)							):
           A__       =    A__       =    range(p_start.shape[1]							)
  
           A__       =    []
           for start_id in start_indexes:
               for end_id in end_indexes:
                   if start_id < end_id:
                       output.append(
                           (
                               start_id,
                               end_id,
                               p_start[idx][start_id].item(),
                               p_end[idx][end_id].item(),
                           )							)
  
           output.sort(key=lambda lowercase_							: (tup[2] * tup[3])		, reverse=lowercase_							)
           A__       =    []
           for k in range(len(lowercase_							)							):
               if output[k][2] * output[k][3] >= thresh:
                   A__,			A__       =    output[k][0], output[k][1]
                   A__       =    self.tokenizer.decode(W_query["input_ids"][idx][c_start_pos:c_end_pos]							)
                   temp.append((decoded, output[k][2] * output[k][3])							)
  
           final_outputs.append(lowercase_							)
  
       return final_outputs
  
  
  
  