






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

import numpy as np


A_						:						Optional[Any]						      =					re.compile(r'\b(a|an|the)\b', re.UNICODE)

A_						:						Dict						      =					None

def     snake_case   ()			->							str:
  UpperCamelCase_:   List[Any]        =							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=UpperCAmelCase__      ,       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=UpperCAmelCase__      ,       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   (UpperCAmelCase__    )			->							Optional[Any]:
  UpperCamelCase_:   Tuple        =							{}
  for article in dataset:
    for p in article["paragraphs"]:
      for qa in p["qas"]:
        UpperCamelCase_:   List[str]        =							bool(qa['answers']['text']    )
  return qid_to_has_ans

def     snake_case   (UpperCAmelCase__    )			->							List[str]:

  def remove_articles(UpperCAmelCase__    ):
    return ARTICLES_REGEX.sub(' '      ,       UpperCAmelCase__    )

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

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

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

  return white_space_fix(remove_articles(remove_punc(lower(UpperCAmelCase__    )    )    )    )

def     snake_case   (UpperCAmelCase__    )			->							Union[str, Any]:
  if not s:
    return []
  return normalize_answer(UpperCAmelCase__    ).split()

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__    )			->							List[Any]:
  return int(normalize_answer(UpperCAmelCase__    ) == normalize_answer(UpperCAmelCase__    )    )

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__    )			->							Tuple:
  UpperCamelCase_:   Union[str, Any]        =							get_tokens(UpperCAmelCase__    )
  UpperCamelCase_:   Tuple        =							get_tokens(UpperCAmelCase__    )
  UpperCamelCase_:   Union[str, Any]        =							collections.Counter(UpperCAmelCase__    ) & collections.Counter(UpperCAmelCase__    )
  UpperCamelCase_:   Optional[int]        =							sum(common.values()    )
  if len(UpperCAmelCase__    ) == 0 or len(UpperCAmelCase__    ) == 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_:   Union[str, Any]        =							1.0 * num_same / len(UpperCAmelCase__    )
  UpperCamelCase_:   Tuple        =							1.0 * num_same / len(UpperCAmelCase__    )
  UpperCamelCase_:   List[str]        =							(2 * precision * recall) / (precision + recall)
  return fa

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__    )			->							List[Any]:
  UpperCamelCase_:   str        =							{}
  UpperCamelCase_:   Union[str, Any]        =							{}
  for article in dataset:
    for p in article["paragraphs"]:
      for qa in p["qas"]:
        UpperCamelCase_:   List[str]        =							qa['id']
        UpperCamelCase_:   Union[str, Any]        =							[t for t in qa['answers']['text'] if normalize_answer(UpperCAmelCase__    )]
        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_:   Dict        =							max(compute_exact(UpperCAmelCase__      ,       UpperCAmelCase__    ) for a in gold_answers    )
        UpperCamelCase_:   Any        =							max(compute_fa(UpperCAmelCase__      ,       UpperCAmelCase__    ) for a in gold_answers    )
  return exact_scores, fa_scores

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )			->							Optional[Any]:
  UpperCamelCase_:   List[Any]        =							{}
  for qid, s in scores.items():
    UpperCamelCase_:   Optional[Any]        =							na_probs[qid] > na_prob_thresh
    if pred_na:
      UpperCamelCase_:   List[str]        =							float(not qid_to_has_ans[qid]    )
    else:
      UpperCamelCase_:   int        =							s
  return new_scores

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__=None    )			->							int:
  if not qid_list:
    UpperCamelCase_:   Tuple        =							len(UpperCAmelCase__    )
    return collections.OrderedDict(
        [
            ('exact', 100.0 * sum(exact_scores.values()    ) / total),
            ('f1', 100.0 * sum(fa_scores.values()    ) / total),
            ('total', total),
        ]    )
  else:
    UpperCamelCase_:   Optional[int]        =							len(UpperCAmelCase__    )
    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   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )			->							Dict:
  for k in new_eval:
    UpperCamelCase_:   int        =							new_eval[k]

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )			->							str:
  plt.step(UpperCAmelCase__      ,       UpperCAmelCase__      ,       color='b'      ,       alpha=0.2      ,       where='post'    )
  plt.fill_between(UpperCAmelCase__      ,       UpperCAmelCase__      ,       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(UpperCAmelCase__    )
  plt.savefig(UpperCAmelCase__    )
  plt.clf()

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__=None      ,       UpperCAmelCase__=None    )			->							Optional[int]:
  UpperCamelCase_:   List[str]        =							sorted(UpperCAmelCase__      ,       key=lambda UpperCAmelCase__    : na_probs[k]    )
  UpperCamelCase_:   Dict        =							0.0
  UpperCamelCase_:   Optional[int]        =							1.0
  UpperCamelCase_:   Optional[Any]        =							0.0
  UpperCamelCase_:   List[str]        =							[1.0]
  UpperCamelCase_:   Dict        =							[0.0]
  UpperCamelCase_:   Optional[int]        =							0.0
  for i, qid in enumerate(UpperCAmelCase__    ):
    if qid_to_has_ans[qid]:
      true_pos += scores[qid]
    UpperCamelCase_:   str        =							true_pos / float(i + 1    )
    UpperCamelCase_:   Any        =							true_pos / float(UpperCAmelCase__    )
    if i == len(UpperCAmelCase__    ) - 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(UpperCAmelCase__    )
      recalls.append(UpperCAmelCase__    )
  if out_image:
    plot_pr_curve(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )
  return {"ap": 100.0 * avg_prec}

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

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )			->							Optional[Any]:
  if not qid_list:
    return
  UpperCamelCase_:   Union[str, Any]        =							[na_probs[k] for k in qid_list]
  UpperCamelCase_:   Optional[Any]        =							np.ones_like(UpperCAmelCase__    ) / float(len(UpperCAmelCase__    )    )
  plt.hist(UpperCAmelCase__      ,       weights=UpperCAmelCase__      ,       bins=2_0      ,       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(UpperCAmelCase__      ,       F'''na_prob_hist_{name}.png'''    )    )
  plt.clf()

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

def     snake_case   (UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )			->							Tuple:
  UpperCamelCase_ ,UpperCamelCase_:   Dict        =							find_best_thresh(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )
  UpperCamelCase_ ,UpperCamelCase_:   Optional[int]        =							find_best_thresh(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )
  UpperCamelCase_:   Tuple        =							best_exact
  UpperCamelCase_:   int        =							exact_thresh
  UpperCamelCase_:   Optional[int]        =							best_fa
  UpperCamelCase_:   Tuple        =							fa_thresh

def     snake_case   ()			->							str:
  with open(OPTS.data_file    ) as f:
    UpperCamelCase_:   int        =							json.load(UpperCAmelCase__    )
    UpperCamelCase_:   int        =							dataset_json['data']
  with open(OPTS.pred_file    ) as f:
    UpperCamelCase_:   Optional[int]        =							json.load(UpperCAmelCase__    )
  if OPTS.na_prob_file:
    with open(OPTS.na_prob_file    ) as f:
      UpperCamelCase_:   List[str]        =							json.load(UpperCAmelCase__    )
  else:
    UpperCamelCase_:   int        =							{k: 0.0 for k in preds}
  UpperCamelCase_:   str        =							make_qid_to_has_ans(UpperCAmelCase__    )  # maps qid to True/False
  UpperCamelCase_:   int        =							[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_ ,UpperCamelCase_:   Union[str, Any]        =							get_raw_scores(UpperCAmelCase__      ,       UpperCAmelCase__    )
  UpperCamelCase_:   Union[str, Any]        =							apply_no_ans_threshold(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       OPTS.na_prob_thresh    )
  UpperCamelCase_:   Union[str, Any]        =							apply_no_ans_threshold(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       OPTS.na_prob_thresh    )
  UpperCamelCase_:   Optional[Any]        =							make_eval_dict(UpperCAmelCase__      ,       UpperCAmelCase__    )
  if has_ans_qids:
    UpperCamelCase_:   Optional[Any]        =							make_eval_dict(UpperCAmelCase__      ,       UpperCAmelCase__      ,       qid_list=UpperCAmelCase__    )
    merge_eval(UpperCAmelCase__      ,       UpperCAmelCase__      ,       'HasAns'    )
  if no_ans_qids:
    UpperCamelCase_:   Any        =							make_eval_dict(UpperCAmelCase__      ,       UpperCAmelCase__      ,       qid_list=UpperCAmelCase__    )
    merge_eval(UpperCAmelCase__      ,       UpperCAmelCase__      ,       'NoAns'    )
  if OPTS.na_prob_file:
    find_all_best_thresh(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__    )
  if OPTS.na_prob_file and OPTS.out_image_dir:
    run_precision_recall_analysis(UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       UpperCAmelCase__      ,       OPTS.out_image_dir    )
    histogram_na_prob(UpperCAmelCase__      ,       UpperCAmelCase__      ,       OPTS.out_image_dir      ,       'hasAns'    )
    histogram_na_prob(UpperCAmelCase__      ,       UpperCAmelCase__      ,       OPTS.out_image_dir      ,       'noAns'    )
  if OPTS.out_file:
    with open(OPTS.out_file      ,       'w'    ) as f:
      json.dump(UpperCAmelCase__      ,       UpperCAmelCase__    )
  else:
    print(json.dumps(UpperCAmelCase__      ,       indent=2    )    )


if __name__ == "__main__":
   A_						:						Optional[int]						      =					parse_args()
   if OPTS.out_image_dir:
      import matplotlib

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

"""simple docstring"""


import itertools
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast
from datasets.utils.py_utils import Literal


_lowercase				 =					datasets.utils.logging.get_logger(__name__)

_lowercase				 =					['''names''', '''prefix''']
_lowercase				 =					['''warn_bad_lines''', '''error_bad_lines''', '''mangle_dupe_cols''']
_lowercase				 =					['''encoding_errors''', '''on_bad_lines''']
_lowercase				 =					['''date_format''']







@dataclass
class 					lowerCAmelCase_					(   datasets.BuilderConfig     ):



						'''simple docstring'''


						_lowerCamelCase:     str   =     ","
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     Optional[Union[int, List[int], str]]   =     "infer"
						_lowerCamelCase:     Optional[List[str]]   =     None
						_lowerCamelCase:     Optional[List[str]]   =     None
						_lowerCamelCase:     Optional[Union[int, str, List[int], List[str]]]   =     None
						_lowerCamelCase:     Optional[Union[List[int], List[str]]]   =     None
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     Optional[Literal["c", "python", "pyarrow"]]   =     None
						_lowerCamelCase:     Dict[Union[int, str], Callable[[Any], Any]]   =     None
						_lowerCamelCase:     Optional[list]   =     None
						_lowerCamelCase:     Optional[list]   =     None
						_lowerCamelCase:     bool   =     False
						_lowerCamelCase:     Optional[Union[int, List[int]]]   =     None
						_lowerCamelCase:     Optional[int]   =     None
						_lowerCamelCase:     Optional[Union[str, List[str]]]   =     None
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     bool   =     False
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     str   =     "."
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     str   =     '"'
						_lowerCamelCase:     int   =     0
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     int   =     0
						_lowerCamelCase:     bool   =     True
						_lowerCamelCase:     bool   =     False
						_lowerCamelCase:     Optional[str]   =     None
						_lowerCamelCase:     int   =     10000
						_lowerCamelCase:     Optional[datasets.Features]   =     None
						_lowerCamelCase:     Optional[str]   =     "strict"
						_lowerCamelCase:     Literal["error", "warn", "skip"]   =     "error"
						_lowerCamelCase:     Optional[str]   =     None


						def     _SCREAMING_SNAKE_CASE   (			self  :   str   )  -> Any:
							if self.delimiter is not None:
								A     = self.delimiter
							if self.column_names is not None:
								A     = self.column_names




						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Any:
							A     = {
							    'sep': self.sep,
							    'header': self.header,
							    'names': self.names,
							    'index_col': self.index_col,
							    'usecols': self.usecols,
							    'prefix': self.prefix,
							    'mangle_dupe_cols': self.mangle_dupe_cols,
							    'engine': self.engine,
							    'converters': self.converters,
							    'true_values': self.true_values,
							    'false_values': self.false_values,
							    'skipinitialspace': self.skipinitialspace,
							    'skiprows': self.skiprows,
							    'nrows': self.nrows,
							    'na_values': self.na_values,
							    'keep_default_na': self.keep_default_na,
							    'na_filter': self.na_filter,
							    'verbose': self.verbose,
							    'skip_blank_lines': self.skip_blank_lines,
							    'thousands': self.thousands,
							    'decimal': self.decimal,
							    'lineterminator': self.lineterminator,
							    'quotechar': self.quotechar,
							    'quoting': self.quoting,
							    'escapechar': self.escapechar,
							    'comment': self.comment,
							    'encoding': self.encoding,
							    'dialect': self.dialect,
							    'error_bad_lines': self.error_bad_lines,
							    'warn_bad_lines': self.warn_bad_lines,
							    'skipfooter': self.skipfooter,
							    'doublequote': self.doublequote,
							    'memory_map': self.memory_map,
							    'float_precision': self.float_precision,
							    'chunksize': self.chunksize,
							    'encoding_errors': self.encoding_errors,
							    'on_bad_lines': self.on_bad_lines,
							    'date_format': self.date_format,
							}

							# some kwargs must not be passed if they don't have a default value
							# some others are deprecated and we can also not pass them if they are the default value
							for pd_read_csv_parameter in _PANDAS_READ_CSV_NO_DEFAULT_PARAMETERS + _PANDAS_READ_CSV_DEPRECATED_PARAMETERS:
								if pd_read_csv_kwargs[pd_read_csv_parameter] == getattr(CsvConfig()	,A_   ):
									del pd_read_csv_kwargs[pd_read_csv_parameter]

        # Remove 2.0 new arguments
							if not (datasets.config.PANDAS_VERSION.major >= 2):
								for pd_read_csv_parameter in _PANDAS_READ_CSV_NEW_2_0_0_PARAMETERS:
									del pd_read_csv_kwargs[pd_read_csv_parameter]

        # Remove 1.3 new arguments
							if not (datasets.config.PANDAS_VERSION.major >= 1 and datasets.config.PANDAS_VERSION.minor >= 3):
								for pd_read_csv_parameter in _PANDAS_READ_CSV_NEW_1_3_0_PARAMETERS:
									del pd_read_csv_kwargs[pd_read_csv_parameter]

							return pd_read_csv_kwargs







class 					lowerCAmelCase_					(   datasets.ArrowBasedBuilder     ):



						'''simple docstring'''


						_lowerCamelCase:     Any   =     CsvConfig


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Optional[int]:
							return datasets.DatasetInfo(features=self.config.features   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Any	,A_  :   Any   )  -> str:
							if not self.config.data_files:
								raise ValueError(F'At least one data file must be specified, but got data_files={self.config.data_files}'   )
							A     = dl_manager.download_and_extract(self.config.data_files   )
							if isinstance(A_	,(str, list, tuple)   ):
								A     = data_files
								if isinstance(A_	,A_   ):
									A     = [files]
								A     = [dl_manager.iter_files(A_   ) for file in files]
								return [datasets.SplitGenerator(name=datasets.Split.TRAIN	,gen_kwargs={'files': files}   )]
							A     = []
							for split_name, files in data_files.items():
								if isinstance(A_	,A_   ):
									A     = [files]
								A     = [dl_manager.iter_files(A_   ) for file in files]
								splits.append(datasets.SplitGenerator(name=A_	,gen_kwargs={'files': files}   )   )
							return splits


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]	,A_  :   pa.Table   )  -> pa.Table:
							if self.config.features is not None:
								A     = self.config.features.arrow_schema
								if all(not require_storage_cast(A_   ) for feature in self.config.features.values()   ):
									# cheaper cast
									A     = pa.Table.from_arrays([pa_table[field.name] for field in schema]	,schema=A_   )
								else:
									# more expensive cast; allows str <-> int/float or str to Audio for example
									A     = table_cast(A_	,A_   )
							return pa_table




						def     _SCREAMING_SNAKE_CASE   (			self  :   Tuple	,A_  :   Union[str, Any]   )  -> List[Any]:
							A     = self.config.features.arrow_schema if self.config.features else None
							# dtype allows reading an int column as str
							A     = (
							    {
							        name: dtype.to_pandas_dtype() if not require_storage_cast(A_   ) else object
							        for name, dtype, feature in zip(schema.names	,schema.types	,self.config.features.values()   )
							    }
							    if schema is not None
							    else None
							)
							for file_idx, file in enumerate(itertools.chain.from_iterable(A_   )   ):
								A     = pd.read_csv(A_	,iterator=A_	,dtype=A_	,**self.config.pd_read_csv_kwargs   )
								try:
									for batch_idx, df in enumerate(A_   ):
										A     = pa.Table.from_pandas(A_   )
										# Uncomment for debugging (will print the Arrow table size and elements)
										# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
										# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
										yield (file_idx, batch_idx), self._cast_table(A_   )
								except ValueError as e:
									logger.error(F'Failed to read file \'{file}\' with error {type(A_   )}: {e}'   )
									raise