



"""simple docstring"""




import argparse
import collections
import json
import os
import re
import string
import sys

import numpy as np


_lowerCAmelCase    : Dict							=							re.compile(r"\b(a|an|the)\b", re.UNICODE)

_lowerCAmelCase    : int							=							None

def 						__snake_case						(				)  ->       Tuple:





     '''simple docstring'''

     _UpperCAmelCase      :     List[str]        =   argparse.ArgumentParser("Official evaluation script for SQuAD version 2.0."    )
     parser.add_argument("data_file"						,  metavar="data.json"						,  help="Input data JSON file."    )
     parser.add_argument("pred_file"						,  metavar="pred.json"						,  help="Model predictions."    )
     parser.add_argument(
         "--out-file"						,  "-o"						,  metavar="eval.json"						,  help="Write accuracy metrics to file (default is stdout)."    )
     parser.add_argument(
         "--na-prob-file"						,  "-n"						,  metavar="na_prob.json"						,  help="Model estimates of probability of no answer."    )
     parser.add_argument(
         "--na-prob-thresh"						,  "-t"						,  type=SCREAMING_SNAKE_CASE__						,  default=1.0						,  help="Predict \"\" if no-answer probability exceeds this (default = 1.0)."						,  )
     parser.add_argument(
         "--out-image-dir"						,  "-p"						,  metavar="out_images"						,  default=SCREAMING_SNAKE_CASE__						,  help="Save precision-recall curves to directory."    )
     parser.add_argument("--verbose"						,  "-v"						,  action="store_true"    )
     if len(sys.argv    ) == 1:
          parser.print_help()
          sys.exit(1    )
     return parser.parse_args()

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       Tuple:





     '''simple docstring'''

     _UpperCAmelCase      :     int        =   {}
     for article in dataset:
          for p in article["paragraphs"]:
               for qa in p["qas"]:
                    _UpperCAmelCase      :     List[Any]        =   bool(qa["answers"]["text"]    )
     return qid_to_has_ans

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[str]    )  ->       Dict:





     '''simple docstring'''

     def remove_articles(SCREAMING_SNAKE_CASE__     :						int    ):
          return ARTICLES_REGEX.sub(" "						,  SCREAMING_SNAKE_CASE__    )

     def white_space_fix(SCREAMING_SNAKE_CASE__     :						List[str]    ):
          return " ".join(text.split()    )

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

     def lower(SCREAMING_SNAKE_CASE__     :						Tuple    ):
          return text.lower()

     return white_space_fix(remove_articles(remove_punc(lower(SCREAMING_SNAKE_CASE__    )    )    )    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       Union[str, Any]:





     '''simple docstring'''

     if not s:
          return []
     return normalize_answer(SCREAMING_SNAKE_CASE__    ).split()

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						List[str]    )  ->       int:





     '''simple docstring'''

     return int(normalize_answer(SCREAMING_SNAKE_CASE__    ) == normalize_answer(SCREAMING_SNAKE_CASE__    )    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						List[Any]    )  ->       Optional[Any]:





     '''simple docstring'''

     _UpperCAmelCase      :     str        =   get_tokens(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     Tuple        =   get_tokens(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     Optional[Any]        =   collections.Counter(SCREAMING_SNAKE_CASE__    ) & collections.Counter(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     Optional[Any]        =   sum(common.values()    )
     if len(SCREAMING_SNAKE_CASE__    ) == 0 or len(SCREAMING_SNAKE_CASE__    ) == 0:
          # If either is no-answer, then F1 is 1 if they agree, 0 otherwise
          return int(gold_toks == pred_toks    )
     if num_same == 0:
          return 0
     _UpperCAmelCase      :     Any        =   1.0 * num_same / len(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     int        =   1.0 * num_same / len(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     Optional[Any]        =   (2 * precision * recall) / (precision + recall)
     return fa

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						int    )  ->       List[str]:





     '''simple docstring'''

     _UpperCAmelCase      :     Optional[int]        =   {}
     _UpperCAmelCase      :     int        =   {}
     for article in dataset:
          for p in article["paragraphs"]:
               for qa in p["qas"]:
                    _UpperCAmelCase      :     Tuple        =   qa["id"]
                    _UpperCAmelCase      :     Optional[int]        =   [t for t in qa["answers"]["text"] if normalize_answer(SCREAMING_SNAKE_CASE__    )]
                    if not gold_answers:
                         # For unanswerable questions, only correct answer is empty string
                         _UpperCAmelCase      :     Union[str, Any]        =   [""]
                    if qid not in preds:
                         print(f'Missing prediction for {qid}'    )
                         continue
                    _UpperCAmelCase      :     Tuple        =   preds[qid]
                    # Take max over all gold answers
                    _UpperCAmelCase      :     str        =   max(compute_exact(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) for a in gold_answers    )
                    _UpperCAmelCase      :     Dict        =   max(compute_fa(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) for a in gold_answers    )
     return exact_scores, fa_scores

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       str:





     '''simple docstring'''

     _UpperCAmelCase      :     Union[str, Any]        =   {}
     for qid, s in scores.items():
          _UpperCAmelCase      :     Dict        =   na_probs[qid] > na_prob_thresh
          if pred_na:
               _UpperCAmelCase      :     List[Any]        =   float(not qid_to_has_ans[qid]    )
          else:
               _UpperCAmelCase      :     Optional[Any]        =   s
     return new_scores

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						List[Any]=None    )  ->       List[Any]:





     '''simple docstring'''

     if not qid_list:
          _UpperCAmelCase      :     Union[str, Any]        =   len(SCREAMING_SNAKE_CASE__    )
          return collections.OrderedDict(
              [
                  ("exact", 100.0 * sum(exact_scores.values()    ) / total),
                  ("f1", 100.0 * sum(fa_scores.values()    ) / total),
                  ("total", total),
              ]    )
     else:
          _UpperCAmelCase      :     str        =   len(SCREAMING_SNAKE_CASE__    )
          return collections.OrderedDict(
              [
                  ("exact", 100.0 * sum(exact_scores[k] for k in qid_list    ) / total),
                  ("f1", 100.0 * sum(fa_scores[k] for k in qid_list    ) / total),
                  ("total", total),
              ]    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						Optional[int]						,  SCREAMING_SNAKE_CASE__     :						List[Any]    )  ->       List[Any]:





     '''simple docstring'''

     for k in new_eval:
          _UpperCAmelCase      :     List[str]        =   new_eval[k]

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						Union[str, Any]						,  SCREAMING_SNAKE_CASE__     :						int    )  ->       str:





     '''simple docstring'''

     plt.step(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  color="b"						,  alpha=0.2						,  where="post"    )
     plt.fill_between(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  step="post"						,  alpha=0.2						,  color="b"    )
     plt.xlabel("Recall"    )
     plt.ylabel("Precision"    )
     plt.xlim([0.0, 1.05]    )
     plt.ylim([0.0, 1.05]    )
     plt.title(SCREAMING_SNAKE_CASE__    )
     plt.savefig(SCREAMING_SNAKE_CASE__    )
     plt.clf()

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						Optional[int]						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						Dict=None						,  SCREAMING_SNAKE_CASE__     :						Tuple=None    )  ->       List[Any]:





     '''simple docstring'''

     _UpperCAmelCase      :     List[str]        =   sorted(SCREAMING_SNAKE_CASE__						,  key=lambda SCREAMING_SNAKE_CASE__    : na_probs[k]    )
     _UpperCAmelCase      :     List[str]        =   0.0
     _UpperCAmelCase      :     int        =   1.0
     _UpperCAmelCase      :     Tuple        =   0.0
     _UpperCAmelCase      :     Tuple        =   [1.0]
     _UpperCAmelCase      :     List[Any]        =   [0.0]
     _UpperCAmelCase      :     Dict        =   0.0
     for i, qid in enumerate(SCREAMING_SNAKE_CASE__    ):
          if qid_to_has_ans[qid]:
               true_pos += scores[qid]
          _UpperCAmelCase      :     Optional[Any]        =   true_pos / float(i + 1    )
          _UpperCAmelCase      :     int        =   true_pos / float(SCREAMING_SNAKE_CASE__    )
          if i == len(SCREAMING_SNAKE_CASE__    ) - 1 or na_probs[qid] != na_probs[qid_list[i + 1]]:
               # i.e., if we can put a threshold after this point
               avg_prec += cur_p * (cur_r - recalls[-1])
               precisions.append(SCREAMING_SNAKE_CASE__    )
               recalls.append(SCREAMING_SNAKE_CASE__    )
     if out_image:
          plot_pr_curve(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     return {"ap": 100.0 * avg_prec}

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						Tuple    )  ->       str:





     '''simple docstring'''

     if out_image_dir and not os.path.exists(SCREAMING_SNAKE_CASE__    ):
          os.makedirs(SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     Tuple        =   sum(1 for v in qid_to_has_ans.values() if v    )
     if num_true_pos == 0:
          return
     _UpperCAmelCase      :     Any        =   make_precision_recall_eval(
         SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  out_image=os.path.join(SCREAMING_SNAKE_CASE__						,  "pr_exact.png"    )						,  title="Precision-Recall curve for Exact Match score"						,  )
     _UpperCAmelCase      :     List[str]        =   make_precision_recall_eval(
         SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  out_image=os.path.join(SCREAMING_SNAKE_CASE__						,  "pr_f1.png"    )						,  title="Precision-Recall curve for F1 score"						,  )
     _UpperCAmelCase      :     Dict        =   {k: float(SCREAMING_SNAKE_CASE__    ) for k, v in qid_to_has_ans.items()}
     _UpperCAmelCase      :     Union[str, Any]        =   make_precision_recall_eval(
         SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  out_image=os.path.join(SCREAMING_SNAKE_CASE__						,  "pr_oracle.png"    )						,  title="Oracle Precision-Recall curve (binary task of HasAns vs. NoAns)"						,  )
     merge_eval(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  "pr_exact"    )
     merge_eval(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  "pr_f1"    )
     merge_eval(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  "pr_oracle"    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						str    )  ->       int:





     '''simple docstring'''

     if not qid_list:
          return
     _UpperCAmelCase      :     int        =   [na_probs[k] for k in qid_list]
     _UpperCAmelCase      :     Union[str, Any]        =   np.ones_like(SCREAMING_SNAKE_CASE__    ) / float(len(SCREAMING_SNAKE_CASE__    )    )
     plt.hist(SCREAMING_SNAKE_CASE__						,  weights=SCREAMING_SNAKE_CASE__						,  bins=20						,  range=(0.0, 1.0)    )
     plt.xlabel("Model probability of no-answer"    )
     plt.ylabel("Proportion of dataset"    )
     plt.title(f'Histogram of no-answer probability: {name}'    )
     plt.savefig(os.path.join(SCREAMING_SNAKE_CASE__						,  f'na_prob_hist_{name}.png'    )    )
     plt.clf()

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Optional[int]						,  SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]    )  ->       str:





     '''simple docstring'''

     _UpperCAmelCase      :     Optional[Any]        =   sum(1 for k in qid_to_has_ans if not qid_to_has_ans[k]    )
     _UpperCAmelCase      :     Any        =   num_no_ans
     _UpperCAmelCase      :     int        =   cur_score
     _UpperCAmelCase      :     Optional[Any]        =   0.0
     _UpperCAmelCase      :     Optional[Any]        =   sorted(SCREAMING_SNAKE_CASE__						,  key=lambda SCREAMING_SNAKE_CASE__    : na_probs[k]    )
     for i, qid in enumerate(SCREAMING_SNAKE_CASE__    ):
          if qid not in scores:
               continue
          if qid_to_has_ans[qid]:
               _UpperCAmelCase      :     int        =   scores[qid]
          else:
               if preds[qid]:
                    _UpperCAmelCase      :     Any        =   -1
               else:
                    _UpperCAmelCase      :     List[str]        =   0
          cur_score += diff
          if cur_score > best_score:
               _UpperCAmelCase      :     str        =   cur_score
               _UpperCAmelCase      :     int        =   na_probs[qid]
     return 100.0 * best_score / len(SCREAMING_SNAKE_CASE__    ), best_thresh

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						List[str]						,  SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						str						,  SCREAMING_SNAKE_CASE__     :						Tuple						,  SCREAMING_SNAKE_CASE__     :						Any    )  ->       Union[str, Any]:





     '''simple docstring'''

     _UpperCAmelCase      :     Dict        =   find_best_thresh(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     str        =   find_best_thresh(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     int        =   best_exact
     _UpperCAmelCase      :     List[Any]        =   exact_thresh
     _UpperCAmelCase      :     str        =   best_fa
     _UpperCAmelCase      :     int        =   fa_thresh

def 						__snake_case						(				)  ->       List[str]:





     '''simple docstring'''

     with open(OPTS.data_file    ) as f:
          _UpperCAmelCase      :     Optional[Any]        =   json.load(SCREAMING_SNAKE_CASE__    )
          _UpperCAmelCase      :     int        =   dataset_json["data"]
     with open(OPTS.pred_file    ) as f:
          _UpperCAmelCase      :     Tuple        =   json.load(SCREAMING_SNAKE_CASE__    )
     if OPTS.na_prob_file:
          with open(OPTS.na_prob_file    ) as f:
               _UpperCAmelCase      :     int        =   json.load(SCREAMING_SNAKE_CASE__    )
     else:
          _UpperCAmelCase      :     Any        =   {k: 0.0 for k in preds}
     _UpperCAmelCase      :     Union[str, Any]        =   make_qid_to_has_ans(SCREAMING_SNAKE_CASE__    )  # maps qid to True/False
     _UpperCAmelCase      :     List[str]        =   [k for k, v in qid_to_has_ans.items() if v]
     _UpperCAmelCase      :     Optional[int]        =   [k for k, v in qid_to_has_ans.items() if not v]
     _UpperCAmelCase      :     List[str]        =   get_raw_scores(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     _UpperCAmelCase      :     str        =   apply_no_ans_threshold(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  OPTS.na_prob_thresh    )
     _UpperCAmelCase      :     List[str]        =   apply_no_ans_threshold(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  OPTS.na_prob_thresh    )
     _UpperCAmelCase      :     Tuple        =   make_eval_dict(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     if has_ans_qids:
          _UpperCAmelCase      :     Optional[int]        =   make_eval_dict(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  qid_list=SCREAMING_SNAKE_CASE__    )
          merge_eval(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  "HasAns"    )
     if no_ans_qids:
          _UpperCAmelCase      :     int        =   make_eval_dict(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  qid_list=SCREAMING_SNAKE_CASE__    )
          merge_eval(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  "NoAns"    )
     if OPTS.na_prob_file:
          find_all_best_thresh(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     if OPTS.na_prob_file and OPTS.out_image_dir:
          run_precision_recall_analysis(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  OPTS.out_image_dir    )
          histogram_na_prob(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  OPTS.out_image_dir						,  "hasAns"    )
          histogram_na_prob(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  OPTS.out_image_dir						,  "noAns"    )
     if OPTS.out_file:
          with open(OPTS.out_file						,  "w"    ) as f:
               json.dump(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     else:
          print(json.dumps(SCREAMING_SNAKE_CASE__						,  indent=2    )    )


if __name__ == "__main__":
 _lowerCAmelCase    : Any							=							parse_args()
 if OPTS.out_image_dir:
  import matplotlib

  matplotlib.use("Agg")
  import matplotlib.pyplot as plt
 main()










"""simple docstring"""




import inspect
import warnings
from typing import Any, Dict, Optional, Union

from packaging import version

def 						__snake_case						(				*SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						Optional[Union[Dict, Any]] = None						,  SCREAMING_SNAKE_CASE__     :						int=True						,  SCREAMING_SNAKE_CASE__     :						Tuple=2    )  ->       Optional[Any]:





     '''simple docstring'''

     from .. import __version__

     _UpperCAmelCase      :     Tuple        =   take_from
     _UpperCAmelCase      :     Optional[int]        =   ()
     if not isinstance(args[0]						,  SCREAMING_SNAKE_CASE__    ):
          _UpperCAmelCase      :     int        =   (args,)

     for attribute, version_name, message in args:
          if version.parse(version.parse(SCREAMING_SNAKE_CASE__    ).base_version    ) >= version.parse(SCREAMING_SNAKE_CASE__    ):
               raise ValueError(
                   f'The deprecation tuple {(attribute, version_name, message)} should be removed since diffusers\''
                   f' version {__version__} is >= {version_name}'    )

          _UpperCAmelCase      :     Any        =   None
          if isinstance(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) and attribute in deprecated_kwargs:
               values += (deprecated_kwargs.pop(SCREAMING_SNAKE_CASE__    ),)
               _UpperCAmelCase      :     Tuple        =   f'The `{attribute}` argument is deprecated and will be removed in version {version_name}.'
          elif hasattr(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ):
               values += (getattr(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ),)
               _UpperCAmelCase      :     str        =   f'The `{attribute}` attribute is deprecated and will be removed in version {version_name}.'
          elif deprecated_kwargs is None:
               _UpperCAmelCase      :     Tuple        =   f'`{attribute}` is deprecated and will be removed in version {version_name}.'

          if warning is not None:
               _UpperCAmelCase      :     Optional[int]        =   warning + " " if standard_warn else ""
               warnings.warn(warning + message						,  SCREAMING_SNAKE_CASE__						,  stacklevel=SCREAMING_SNAKE_CASE__    )

     if isinstance(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    ) and len(SCREAMING_SNAKE_CASE__    ) > 0:
          _UpperCAmelCase      :     List[Any]        =   inspect.getouterframes(inspect.currentframe()    )[1]
          _UpperCAmelCase      :     Optional[int]        =   call_frame.filename
          _UpperCAmelCase      :     Dict        =   call_frame.lineno
          _UpperCAmelCase      :     List[Any]        =   call_frame.function
          _UpperCAmelCase    ,	_UpperCAmelCase      :     Optional[int]        =   next(iter(deprecated_kwargs.items()    )    )
          raise TypeError(f'{function} in {filename} line {line_number-1} got an unexpected keyword argument `{key}`'    )

     if len(SCREAMING_SNAKE_CASE__    ) == 0:
          return
     elif len(SCREAMING_SNAKE_CASE__    ) == 1:
          return values[0]
     return values
