






'''simple docstring'''





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






def  lowerCamelCase_  (     lowercase__):

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

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

 def remove_punc(lowercase__):
  lowerCamelCase__	=  set(string.punctuation)
  return "".join(ch for ch in text if ch not in exclude)

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

 return white_space_fix(remove_articles(remove_punc(lower(lowercase__))))






def  lowerCamelCase_  (     lowercase__					,  lowercase__):
 lowerCamelCase__	=  normalize_answer(lowercase__).split()
 lowerCamelCase__	=  normalize_answer(lowercase__).split()
 lowerCamelCase__	=  Counter(lowercase__) & Counter(lowercase__)
 lowerCamelCase__	=  sum(common.values())
 if num_same == 0:
  return 0
 lowerCamelCase__	=  1.0 * num_same / len(lowercase__)
 lowerCamelCase__	=  1.0 * num_same / len(lowercase__)
 lowerCamelCase__	=  (2 * precision * recall) / (precision + recall)
 return fa






def  lowerCamelCase_  (     lowercase__					,  lowercase__):
 return normalize_answer(lowercase__) == normalize_answer(lowercase__)






def  lowerCamelCase_  (     lowercase__					,  lowercase__					,  lowercase__):
 lowerCamelCase__	=  []
 for ground_truth in ground_truths:
  lowerCamelCase__	=  metric_fn(lowercase__					,  lowercase__)
  scores_for_ground_truths.append(lowercase__)
 return max(lowercase__)






def  lowerCamelCase_  (     lowercase__					,  lowercase__):
 lowerCamelCase__	=  lowerCamelCase__	=  lowerCamelCase__	=  0
 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(lowercase__					,  file=sys.stderr)
     continue
    lowerCamelCase__	=  [x["text"] for x in qa["answers"]]
    lowerCamelCase__	=  predictions[qa["id"]]
    exact_match += metric_max_over_ground_truths(lowercase__					,  lowercase__					,  lowercase__)
    fa += metric_max_over_ground_truths(lowercase__					,  lowercase__					,  lowercase__)

 lowerCamelCase__	=  100.0 * exact_match / total
 lowerCamelCase__	=  100.0 * fa / total

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


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









'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


__A				:				Optional[int]					=		logging.get_logger(__name__)

__A				:				Tuple					=		{
    """facebook/convnext-tiny-224""": """https://huggingface.co/facebook/convnext-tiny-224/resolve/main/config.json""",
    # See all ConvNeXT models at https://huggingface.co/models?filter=convnext
}
class 					lowercase							(				_lowerCamelCase			,							_lowerCamelCase   ):


    '''simple docstring'''

    lowerCAmelCase__   					=				"convnext"

    def __init__(       self  :  Any					,  __lowerCamelCase  :  Dict=3					,  __lowerCamelCase  :  int=4					,  __lowerCamelCase  :  Any=4					,  __lowerCamelCase  :  Dict=None					,  __lowerCamelCase  :  str=None					,  __lowerCamelCase  :  Optional[int]="gelu"					,  __lowerCamelCase  :  List[str]=0.0_2					,  __lowerCamelCase  :  int=1E-12					,  __lowerCamelCase  :  Optional[Any]=1E-6					,  __lowerCamelCase  :  Any=0.0					,  __lowerCamelCase  :  Union[str, Any]=224					,  __lowerCamelCase  :  Dict=None					,  __lowerCamelCase  :  List[str]=None					,  **__lowerCamelCase  :  Tuple					,  )				->				Dict:

     '''simple docstring'''




     super().__init__(**__lowerCamelCase  )

     lowerCamelCase__	=  num_channels
     lowerCamelCase__	=  patch_size
     lowerCamelCase__	=  num_stages
     lowerCamelCase__	=  [96, 192, 384, 768] if hidden_sizes is None else hidden_sizes
     lowerCamelCase__	=  [3, 3, 9, 3] if depths is None else depths
     lowerCamelCase__	=  hidden_act
     lowerCamelCase__	=  initializer_range
     lowerCamelCase__	=  layer_norm_eps
     lowerCamelCase__	=  layer_scale_init_value
     lowerCamelCase__	=  drop_path_rate
     lowerCamelCase__	=  image_size
     lowerCamelCase__	=  ["stem"] + [f'''stage{idx}''' for idx in range(1					,  len(self.depths  ) + 1  )]
     lowerCamelCase__	,						lowerCamelCase__	=  get_aligned_output_features_output_indices(
         out_features=__lowerCamelCase					,  out_indices=__lowerCamelCase					,  stage_names=self.stage_names  )
class 					lowercase							(				_lowerCamelCase   ):


    '''simple docstring'''

    lowerCAmelCase__   					=				version.parse("1.11"   )

    @property
    def  a__					(       self  :  List[Any]  )				->				Mapping[str, Mapping[int, str]]:

     '''simple docstring'''




     return OrderedDict(
         [
             ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
         ]  )




    @property
    def  a__					(       self  :  Tuple  )				->				float:

     '''simple docstring'''




     return 1E-5

