code: 
  
  
  import argparse
  import json
  import re
  import string
  import sys
  
  import numpy as np
  
  
  UpperCAmelCase      :						List[str]    =		0.5
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	Dict     ,       lowerCamelCase__		:	Optional[Any]			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     [""".""", """,""", """;""", """:"""]
  
  			for token in remove_tokens:
  						lowerCamelCase								=     ground_truth.replace(lowerCamelCase__     ,       """"""			)
  						lowerCamelCase								=     prediction.replace(lowerCamelCase__     ,       """"""			)
  
  			lowerCamelCase		,		lowerCamelCase								=     ground_truth.lower(), prediction.lower()
  			lowerCamelCase		,		lowerCamelCase								=     ground_truth.replace("""/"""     ,       """ """			), prediction.replace("""/"""     ,       """ """			)
  			lowerCamelCase		,		lowerCamelCase								=     set(ground_truth.split(""" """			)			), set(prediction.split(""" """			)			)
  
  			lowerCamelCase								=     ground_truth.intersection(lowerCamelCase__			)
  			lowerCamelCase								=     ground_truth.union(lowerCamelCase__			)
  			lowerCamelCase								=     len(lowerCamelCase__			) / len(lowerCamelCase__			)
  			return jaccard
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	str			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			def remove_articles(lowerCamelCase__		:	Optional[Any]			):
  						return re.sub(R"""\b(a|an|the)\b"""     ,       """ """     ,       lowerCamelCase__			)
  
  			def white_space_fix(lowerCamelCase__		:	Dict			):
  						return " ".join(text.split()			)
  
  			def remove_punc(lowerCamelCase__		:	Dict			):
  						lowerCamelCase								=     set(string.punctuation			)
  						return "".join(ch for ch in text if ch not in exclude			)
  
  			def lower(lowerCamelCase__		:	Union[str, Any]			):
  						return text.lower()
  
  			return white_space_fix(remove_articles(remove_punc(lower(lowerCamelCase__			)			)			)			)
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	int     ,       lowerCamelCase__		:	Optional[int]     ,       lowerCamelCase__		:	int			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase		,		lowerCamelCase		,		lowerCamelCase								=     0, 0, 0
  
  			lowerCamelCase								=     """Parties""" in qa_id
  
  			# first check if ground truth is empty
  			if len(lowerCamelCase__			) == 0:
  						if len(lowerCamelCase__			) > 0:
  									fp += len(lowerCamelCase__			)  # false positive for each one
  			else:
  						for ground_truth in ground_truths:
  									assert len(lowerCamelCase__			) > 0
  									# check if there is a match
  									lowerCamelCase								=     False
  									for pred in predictions:
  												if substr_ok:
  															lowerCamelCase								=     get_jaccard(lowerCamelCase__     ,       lowerCamelCase__			) >= IOU_THRESH or ground_truth in pred
  												else:
  															lowerCamelCase								=     get_jaccard(lowerCamelCase__     ,       lowerCamelCase__			) >= IOU_THRESH
  												if is_match:
  															lowerCamelCase								=     True
  
  									if match_found:
  												tp += 1
  									else:
  												fn += 1
  
          # now also get any fps by looping through preds
  						for pred in predictions:
  									# Check if there's a match. if so, don't count (don't want to double count based on the above)
  									# but if there's no match, then this is a false positive.
  									# (Note: we get the true positives in the above loop instead of this loop so that we don't double count
  									# multiple predictions that are matched with the same answer.)
  									lowerCamelCase								=     False
  									for ground_truth in ground_truths:
  												assert len(lowerCamelCase__			) > 0
  												if substr_ok:
  															lowerCamelCase								=     get_jaccard(lowerCamelCase__     ,       lowerCamelCase__			) >= IOU_THRESH or ground_truth in pred
  												else:
  															lowerCamelCase								=     get_jaccard(lowerCamelCase__     ,       lowerCamelCase__			) >= IOU_THRESH
  												if is_match:
  															lowerCamelCase								=     True
  
  									if not match_found:
  												fp += 1
  
  			lowerCamelCase								=     tp / (tp + fp) if tp + fp > 0 else np.nan
  			lowerCamelCase								=     tp / (tp + fn) if tp + fn > 0 else np.nan
  
  			return precision, recall
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	List[Any]			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     precisions[::-1]
  			for i in range(1     ,       len(lowerCamelCase__			)			):
  						lowerCamelCase								=     max(precision_best[i - 1]     ,       precision_best[i]			)
  			lowerCamelCase								=     precision_best[::-1]
  			return precisions
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	Union[str, Any]     ,       lowerCamelCase__		:	Any			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     process_precisions(lowerCamelCase__			)
  			lowerCamelCase								=     np.trapz(lowerCamelCase__     ,       lowerCamelCase__			)
  			if np.isnan(lowerCamelCase__			):
  						return 0
  			return aupr
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	str     ,       lowerCamelCase__		:	str     ,       lowerCamelCase__		:	Union[str, Any]			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     process_precisions(lowerCamelCase__			)
  			lowerCamelCase								=     0
  			for prec, recall in zip(lowerCamelCase__     ,       lowerCamelCase__			):
  						if recall >= recall_thresh:
  									lowerCamelCase								=     prec
  									break
  			return prec_at_recall
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	str     ,       lowerCamelCase__		:	List[Any]			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			return normalize_answer(lowerCamelCase__			) == normalize_answer(lowerCamelCase__			)
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	Optional[Any]     ,       lowerCamelCase__		:	Dict     ,       lowerCamelCase__		:	Optional[Any]			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     0
  			for pred in predictions:
  						for ground_truth in ground_truths:
  									lowerCamelCase								=     metric_fn(lowerCamelCase__     ,       lowerCamelCase__			)
  									if score == 1:  # break the loop when one prediction matches the ground truth
  												break
  						if score == 1:
  									break
  			return score
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	Optional[int]     ,       lowerCamelCase__		:	Tuple			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			lowerCamelCase								=     lowerCamelCase								=     lowerCamelCase								=     0
  			lowerCamelCase								=     []
  			lowerCamelCase								=     []
  			for article in dataset:
  						for paragraph in article["paragraphs"]:
  									for qa in paragraph["qas"]:
  												total += 1
  												if qa["id"] not in predictions:
  															lowerCamelCase								=     """Unanswered question """ + qa["""id"""] + """ will receive score 0."""
  															print(lowerCamelCase__     ,       file=sys.stderr			)
  															continue
  												lowerCamelCase								=     [x["""text"""] for x in qa["""answers"""]]
  												lowerCamelCase								=     predictions[qa["""id"""]]
  												lowerCamelCase		,		lowerCamelCase								=     compute_precision_recall(lowerCamelCase__     ,       lowerCamelCase__     ,       qa["""id"""]			)
  
  												precisions.append(lowerCamelCase__			)
  												recalls.append(lowerCamelCase__			)
  
  												if precision == 0 and recall == 0:
  															fa += 0
  												else:
  															fa += 2 * (precision * recall) / (precision + recall)
  
  												exact_match += metric_max_over_ground_truths(lowerCamelCase__     ,       lowerCamelCase__     ,       lowerCamelCase__			)
  
  			lowerCamelCase								=     [x for _, x in sorted(zip(lowerCamelCase__     ,       lowerCamelCase__			)			)]
  			recalls.sort()
  
  			lowerCamelCase								=     1_0_0.0 * fa / total
  			lowerCamelCase								=     1_0_0.0 * exact_match / total
  			lowerCamelCase								=     get_aupr(lowerCamelCase__     ,       lowerCamelCase__			)
  
  			lowerCamelCase								=     get_prec_at_recall(lowerCamelCase__     ,       lowerCamelCase__     ,       recall_thresh=0.9			)
  			lowerCamelCase								=     get_prec_at_recall(lowerCamelCase__     ,       lowerCamelCase__     ,       recall_thresh=0.8			)
  
  			return {
  			    "exact_match": exact_match,
  			    "f1": fa,
  			    "aupr": aupr,
  			    "prec_at_80_recall": prec_at_aa_recall,
  			    "prec_at_90_recall": prec_at_aa_recall,
  			}
  
  
  if __name__ == "__main__":
  		UpperCAmelCase      :						List[str]    =		argparse.ArgumentParser(description="Evaluation for CUAD")
  		parser.add_argument("dataset_file", help="Dataset file")
  		parser.add_argument("prediction_file", help="Prediction File")
  		UpperCAmelCase      :						List[str]    =		parser.parse_args()
  		with open(args.dataset_file) as dataset_file:
  				UpperCAmelCase      :						Any    =		json.load(dataset_file)
  				UpperCAmelCase      :						str    =		dataset_json["data"]
  		with open(args.prediction_file) as prediction_file:
  				UpperCAmelCase      :						Any    =		json.load(prediction_file)
  		print(json.dumps(evaluate(dataset, predictions)))
  
  
style_context: 
  
  
  import math
  
  import qiskit
  from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute
  
  
  
  
  
  
  def   __lowerCamelCase	(       lowerCamelCase__		:	int = 1     ,       lowerCamelCase__		:	int = 1			):
  
  
  
  
  
  			'''simple docstring'''
  
  
  
  
  			if isinstance(lowerCamelCase__     ,       lowerCamelCase__			) or isinstance(lowerCamelCase__     ,       lowerCamelCase__			):
  						raise TypeError("""inputs must be integers."""			)
  			if (bit_a < 0) or (bit_a < 0):
  						raise ValueError("""inputs must be positive."""			)
  			if (math.floor(lowerCamelCase__			) != bit_a) or (math.floor(lowerCamelCase__			) != bit_a):
  						raise ValueError("""inputs must be exact integers."""			)
  			if (bit_a > 1) or (bit_a > 1):
  						raise ValueError("""inputs must be less or equal to 1."""			)
  
  			# build registers
  			lowerCamelCase								=     QuantumRegister(2     ,       """qr"""			)
  			lowerCamelCase								=     ClassicalRegister(2     ,       """cr"""			)
  
  			lowerCamelCase								=     QuantumCircuit(lowerCamelCase__     ,       lowerCamelCase__			)
  
  			# entanglement the qubits
  			quantum_circuit.h(1			)
  			quantum_circuit.cx(1     ,       0			)
  
  			# send the information
  			lowerCamelCase								=     str(lowerCamelCase__			) + str(lowerCamelCase__			)
  
  			if c_information == "11":
  						quantum_circuit.x(1			)
  						quantum_circuit.z(1			)
  			elif c_information == "10":
  						quantum_circuit.z(1			)
  			elif c_information == "01":
  						quantum_circuit.x(1			)
  			else:
  						quantum_circuit.i(1			)
  
  			# unentangled the circuit
  			quantum_circuit.cx(1     ,       0			)
  			quantum_circuit.h(1			)
  
  			# measure the circuit
  			quantum_circuit.measure(lowerCamelCase__     ,       lowerCamelCase__			)
  
  			lowerCamelCase								=     Aer.get_backend("""aer_simulator"""			)
  			lowerCamelCase								=     execute(lowerCamelCase__     ,       lowerCamelCase__     ,       shots=1000			)
  
  			return job.result().get_counts(lowerCamelCase__			)
  
  
  if __name__ == "__main__":
  		print(f"""Counts for classical state send: {superdense_coding(1,1)}""")
  
  