






from __future__ import annotations

from typing import Generic, TypeVar

UpperCAmelCase__	 =	TypeVar('''T''')




class        snake_case_					(						__UpperCamelCase			):

						"""simple docstring"""



						pass




class        snake_case_					(						__UpperCamelCase			):

						"""simple docstring"""



						pass




class        snake_case_					(						Generic[T]			):

						"""simple docstring"""



						def __init__(self:				Dict   ,				__UpperCAmelCase:				int = 10      )						->    Dict:




											'''simple docstring'''



											__a				:	list[T]			=				[]
											__a				:	str			=				limit



						def __bool__(self:				Dict      )						->    bool:




											'''simple docstring'''



											return bool(self.stack      )



						def __str__(self:				List[str]      )						->    str:




											'''simple docstring'''



											return str(self.stack      )



						def 					UpperCAmelCase__				(self:				Any   ,				__UpperCAmelCase:				T      )						->    None:




											'''simple docstring'''



											if len(self.stack      ) >= self.limit:
																raise StackOverflowError
											self.stack.append(__UpperCAmelCase      )



						def 					UpperCAmelCase__				(self:				str      )						->    T:




											'''simple docstring'''



											if not self.stack:
																raise StackUnderflowError
											return self.stack.pop()



						def 					UpperCAmelCase__				(self:				Dict      )						->    T:




											'''simple docstring'''



											if not self.stack:
																raise StackUnderflowError
											return self.stack[-1]



						def 					UpperCAmelCase__				(self:				int      )						->    bool:




											'''simple docstring'''



											return not bool(self.stack      )



						def 					UpperCAmelCase__				(self:				Optional[int]      )						->    bool:




											'''simple docstring'''



											return self.size() == self.limit



						def 					UpperCAmelCase__				(self:				Dict      )						->    int:




											'''simple docstring'''



											return len(self.stack      )



						def __contains__(self:				Optional[int]   ,				__UpperCAmelCase:				T      )						->    bool:




											'''simple docstring'''



											return item in self.stack







def 						a_      ()							->	None:



					"""simple docstring"""
					__a				:	Stack[int]			=				Stack(10			)
					assert bool(__A			) is False
					assert stack.is_empty() is True
					assert stack.is_full() is False
					assert str(__A			) == "[]"

					try:
										__a				:	Optional[int]			=				stack.pop()
										raise AssertionError  # This should not happen
					except StackUnderflowError:
										assert True  # This should happen

					try:
										__a				:	Optional[Any]			=				stack.peek()
										raise AssertionError  # This should not happen
					except StackUnderflowError:
										assert True  # This should happen

					for i in range(10			):
										assert stack.size() == i
										stack.push(__A			)

					assert bool(__A			)
					assert not stack.is_empty()
					assert stack.is_full()
					assert str(__A			) == str(list(range(10			)			)			)
					assert stack.pop() == 9
					assert stack.peek() == 8

					stack.push(100			)
					assert str(__A			) == str([0, 1, 2, 3, 4, 5, 6, 7, 8, 100]			)

					try:
										stack.push(200			)
										raise AssertionError  # This should not happen
					except StackOverflowError:
										assert True  # This should happen

					assert not stack.is_empty()
					assert stack.size() == 10

					assert 5 in stack
					assert 55 not in stack


if __name__ == "__main__":
			test_stack()













import argparse
import json
import re
import string
import sys
from collections import Counter







def 						a_      (__A			)							->	Optional[Any]:



					"""simple docstring"""

					def remove_articles(__A			):
										return re.sub(r"\b(a|an|the)\b"							,					" "							,					__A			)

					def white_space_fix(__A			):
										return " ".join(text.split()			)

					def remove_punc(__A			):
										__a				:	Union[str, Any]			=				set(string.punctuation			)
										return "".join(ch for ch in text if ch not in exclude			)

					def lower(__A			):
										return text.lower()

					return white_space_fix(remove_articles(remove_punc(lower(__A			)			)			)			)







def 						a_      (__A							,					__A			)							->	Union[str, Any]:



					"""simple docstring"""
					__a				:	str			=				normalize_answer(__A			).split()
					__a				:	Dict			=				normalize_answer(__A			).split()
					__a				:	List[Any]			=				Counter(__A			) & Counter(__A			)
					__a				:	List[Any]			=				sum(common.values()			)
					if num_same == 0:
										return 0
					__a				:	Optional[Any]			=				1.0 * num_same / len(__A			)
					__a				:	int			=				1.0 * num_same / len(__A			)
					__a				:	List[str]			=				(2 * precision * recall) / (precision + recall)
					return fa







def 						a_      (__A							,					__A			)							->	Dict:



					"""simple docstring"""
					return normalize_answer(__A			) == normalize_answer(__A			)







def 						a_      (__A							,					__A							,					__A			)							->	Optional[Any]:



					"""simple docstring"""
					__a				:	str			=				[]
					for ground_truth in ground_truths:
										__a				:	Tuple			=				metric_fn(__A							,					__A			)
										scores_for_ground_truths.append(__A			)
					return max(__A			)







def 						a_      (__A							,					__A			)							->	Union[str, Any]:



					"""simple docstring"""
					__a				:	str			=				0
					for article in dataset:
										for paragraph in article["paragraphs"]:
															for qa in paragraph["qas"]:
																				total += 1
																				if qa["id"] not in predictions:
																									__a				:	str			=				"Unanswered question " + qa["id"] + " will receive score 0."
																									print(__A							,					file=sys.stderr			)
																									continue
																				__a				:	Any			=				[x["text"] for x in qa["answers"]]
																				__a				:	List[Any]			=				predictions[qa["id"]]
																				exact_match += metric_max_over_ground_truths(__A							,					__A							,					__A			)
																				fa += metric_max_over_ground_truths(__A							,					__A							,					__A			)

					__a				:	Any			=				100.0 * exact_match / total
					__a				:	List[Any]			=				100.0 * fa / total

					return {"exact_match": exact_match, "f1": fa}


if __name__ == "__main__":
			UpperCAmelCase__			 =	'''1.1'''
			UpperCAmelCase__			 =	argparse.ArgumentParser(description='''Evaluation for SQuAD ''' + expected_version)
			parser.add_argument('''dataset_file''', help='''Dataset file''')
			parser.add_argument('''prediction_file''', help='''Prediction File''')
			UpperCAmelCase__			 =	parser.parse_args()
			with open(args.dataset_file) as dataset_file:
						UpperCAmelCase__			 =	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,
									)
						UpperCAmelCase__			 =	dataset_json['''data''']
			with open(args.prediction_file) as prediction_file:
						UpperCAmelCase__			 =	json.load(prediction_file)
			print(json.dumps(evaluate(dataset, predictions)))





