
"""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


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

__magic_name__       =			["names", "prefix"]
__magic_name__       =			["warn_bad_lines", "error_bad_lines", "mangle_dupe_cols"]
__magic_name__       =			["encoding_errors", "on_bad_lines"]
__magic_name__       =			["date_format"]
@dataclass
class 						SCREAMING_SNAKE_CASE_ (						datasets.BuilderConfig ):




		"""simple docstring"""





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




		def 	snake_case_     (     self):
				if self.delimiter is not None:
						__SCREAMING_SNAKE_CASE            = self.delimiter
				if self.column_names is not None:
						__SCREAMING_SNAKE_CASE            = self.column_names




		@property
		def 	snake_case_     (     self):
				__SCREAMING_SNAKE_CASE            = {
				    """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 						SCREAMING_SNAKE_CASE_ (						datasets.ArrowBasedBuilder ):




		"""simple docstring"""





		__lowercase							:  Optional[int]						   =		CsvConfig




		def 	snake_case_     (     self):
				return datasets.DatasetInfo(features=self.config.features)




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				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}")
				__SCREAMING_SNAKE_CASE            = dl_manager.download_and_extract(self.config.data_files)
				if isinstance(A__							,  (str, list, tuple)):
						__SCREAMING_SNAKE_CASE            = data_files
						if isinstance(A__							,  A__):
								__SCREAMING_SNAKE_CASE            = [files]
						__SCREAMING_SNAKE_CASE            = [dl_manager.iter_files(A__) for file in files]
						return [datasets.SplitGenerator(name=datasets.Split.TRAIN							,  gen_kwargs={"""files""": files})]
				__SCREAMING_SNAKE_CASE            = []
				for split_name, files in data_files.items():
						if isinstance(A__							,  A__):
								__SCREAMING_SNAKE_CASE            = [files]
						__SCREAMING_SNAKE_CASE            = [dl_manager.iter_files(A__) for file in files]
						splits.append(datasets.SplitGenerator(name=A__							,  gen_kwargs={"""files""": files}))
				return splits




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if self.config.features is not None:
						__SCREAMING_SNAKE_CASE            = self.config.features.arrow_schema
						if all(not require_storage_cast(A__) for feature in self.config.features.values()):
								# cheaper cast
								__SCREAMING_SNAKE_CASE            = 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
								__SCREAMING_SNAKE_CASE            = table_cast(A__							,  A__)
				return pa_table




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.config.features.arrow_schema if self.config.features else None
				# dtype allows reading an int column as str
				__SCREAMING_SNAKE_CASE            = (
				    {
				        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__)):
						__SCREAMING_SNAKE_CASE            = pd.read_csv(A__							,  iterator=A__							,  dtype=A__							,  **self.config.pd_read_csv_kwargs)
						try:
								for batch_idx, df in enumerate(A__):
										__SCREAMING_SNAKE_CASE            = 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






import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_bert import BertTokenizer


lowercase__		:List[Any]   =    logging.get_logger(__name__)

lowercase__		:Optional[Any]   =    {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

lowercase__		:Union[str, Any]   =    {
    "vocab_file": {
        "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt",
        "bert-large-uncased": "https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt",
        "bert-base-cased": "https://huggingface.co/bert-base-cased/resolve/main/vocab.txt",
        "bert-large-cased": "https://huggingface.co/bert-large-cased/resolve/main/vocab.txt",
        "bert-base-multilingual-uncased": (
            "https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt"
        ),
        "bert-base-multilingual-cased": "https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt",
        "bert-base-chinese": "https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt",
        "bert-base-german-cased": "https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt",
        "bert-large-uncased-whole-word-masking": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt"
        ),
        "bert-large-cased-whole-word-masking": (
            "https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt"
        ),
        "bert-large-uncased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"
        ),
        "bert-large-cased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt"
        ),
        "bert-base-cased-finetuned-mrpc": (
            "https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt"
        ),
        "bert-base-german-dbmdz-cased": "https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt",
        "bert-base-german-dbmdz-uncased": (
            "https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt"
        ),
        "TurkuNLP/bert-base-finnish-cased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt"
        ),
        "TurkuNLP/bert-base-finnish-uncased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt"
        ),
        "wietsedv/bert-base-dutch-cased": (
            "https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt"
        ),
    },
    "tokenizer_file": {
        "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json",
        "bert-large-uncased": "https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json",
        "bert-base-cased": "https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json",
        "bert-large-cased": "https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json",
        "bert-base-multilingual-uncased": (
            "https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json"
        ),
        "bert-base-multilingual-cased": (
            "https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json"
        ),
        "bert-base-chinese": "https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json",
        "bert-base-german-cased": "https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json",
        "bert-large-uncased-whole-word-masking": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json"
        ),
        "bert-large-cased-whole-word-masking": (
            "https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json"
        ),
        "bert-large-uncased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"
        ),
        "bert-large-cased-whole-word-masking-finetuned-squad": (
            "https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json"
        ),
        "bert-base-cased-finetuned-mrpc": (
            "https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json"
        ),
        "bert-base-german-dbmdz-cased": (
            "https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json"
        ),
        "bert-base-german-dbmdz-uncased": (
            "https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json"
        ),
        "TurkuNLP/bert-base-finnish-cased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json"
        ),
        "TurkuNLP/bert-base-finnish-uncased-v1": (
            "https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json"
        ),
        "wietsedv/bert-base-dutch-cased": (
            "https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json"
        ),
    },
}

lowercase__		:str   =    {
    "bert-base-uncased": 512,
    "bert-large-uncased": 512,
    "bert-base-cased": 512,
    "bert-large-cased": 512,
    "bert-base-multilingual-uncased": 512,
    "bert-base-multilingual-cased": 512,
    "bert-base-chinese": 512,
    "bert-base-german-cased": 512,
    "bert-large-uncased-whole-word-masking": 512,
    "bert-large-cased-whole-word-masking": 512,
    "bert-large-uncased-whole-word-masking-finetuned-squad": 512,
    "bert-large-cased-whole-word-masking-finetuned-squad": 512,
    "bert-base-cased-finetuned-mrpc": 512,
    "bert-base-german-dbmdz-cased": 512,
    "bert-base-german-dbmdz-uncased": 512,
    "TurkuNLP/bert-base-finnish-cased-v1": 512,
    "TurkuNLP/bert-base-finnish-uncased-v1": 512,
    "wietsedv/bert-base-dutch-cased": 512,
}

lowercase__		:Dict   =    {
    "bert-base-uncased": {"do_lower_case": True},
    "bert-large-uncased": {"do_lower_case": True},
    "bert-base-cased": {"do_lower_case": False},
    "bert-large-cased": {"do_lower_case": False},
    "bert-base-multilingual-uncased": {"do_lower_case": True},
    "bert-base-multilingual-cased": {"do_lower_case": False},
    "bert-base-chinese": {"do_lower_case": False},
    "bert-base-german-cased": {"do_lower_case": False},
    "bert-large-uncased-whole-word-masking": {"do_lower_case": True},
    "bert-large-cased-whole-word-masking": {"do_lower_case": False},
    "bert-large-uncased-whole-word-masking-finetuned-squad": {"do_lower_case": True},
    "bert-large-cased-whole-word-masking-finetuned-squad": {"do_lower_case": False},
    "bert-base-cased-finetuned-mrpc": {"do_lower_case": False},
    "bert-base-german-dbmdz-cased": {"do_lower_case": False},
    "bert-base-german-dbmdz-uncased": {"do_lower_case": True},
    "TurkuNLP/bert-base-finnish-cased-v1": {"do_lower_case": False},
    "TurkuNLP/bert-base-finnish-uncased-v1": {"do_lower_case": True},
    "wietsedv/bert-base-dutch-cased": {"do_lower_case": False},
}







class 				lowercase		(					SCREAMING_SNAKE_CASE__		):
							lowercase_       :       str       					=VOCAB_FILES_NAMES
							lowercase_       :       Dict       					=PRETRAINED_VOCAB_FILES_MAP
							lowercase_       :       Optional[int]       					=PRETRAINED_INIT_CONFIGURATION
							lowercase_       :       Tuple       					=PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowercase_       :       Any       					=BertTokenizer




							def __init__(				self   ,A__=None   ,A__=None   ,A__=True   ,A__="[UNK]"   ,A__="[SEP]"   ,A__="[PAD]"   ,A__="[CLS]"   ,A__="[MASK]"   ,A__=True   ,A__=None   ,**A__   ,):
												super().__init__(
												    A__   ,tokenizer_file=A__   ,do_lower_case=A__   ,unk_token=A__   ,sep_token=A__   ,pad_token=A__   ,cls_token=A__   ,mask_token=A__   ,tokenize_chinese_chars=A__   ,strip_accents=A__   ,**A__   ,)

												lowercase							=						json.loads(self.backend_tokenizer.normalizer.__getstate__())
												if (
												    normalizer_state.get('''lowercase'''   ,A__) != do_lower_case
												    or normalizer_state.get('''strip_accents'''   ,A__) != strip_accents
												    or normalizer_state.get('''handle_chinese_chars'''   ,A__) != tokenize_chinese_chars
												):
																	lowercase							=						getattr(A__   ,normalizer_state.pop('''type'''))
																	lowercase							=						do_lower_case
																	lowercase							=						strip_accents
																	lowercase							=						tokenize_chinese_chars
																	lowercase							=						normalizer_class(**A__)

												lowercase							=						do_lower_case




							def  A__      (				self   ,A__   ,A__=None):
												lowercase							=						[self.cls_token_id] + token_ids_a + [self.sep_token_id]

												if token_ids_a:
																	output += token_ids_a + [self.sep_token_id]

												return output




							def  A__      (				self   ,A__   ,A__ = None):
												lowercase							=						[self.sep_token_id]
												lowercase							=						[self.cls_token_id]
												if token_ids_a is None:
																	return len(cls + token_ids_a + sep) * [0]
												return len(cls + token_ids_a + sep) * [0] + len(token_ids_a + sep) * [1]





							def  A__      (				self   ,A__   ,A__ = None):
												lowercase							=						self._tokenizer.model.save(A__   ,name=A__)
												return tuple(A__)




