



import itertools
import json
import os
import unittest

from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast
from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class 		lowercase						(			snake_case__			,   unittest.TestCase):






 """simple docstring"""


 a__				: Any		       =							LongformerTokenizer
 a__				: Tuple		       =							True
 a__				: Optional[int]		       =							LongformerTokenizerFast
 a__				: str		       =							True




 def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[int]					)      ->			Optional[Any]:
       super().setUp()

       # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
       UpperCAmelCase_=       [
           """l""",
           """o""",
           """w""",
           """e""",
           """r""",
           """s""",
           """t""",
           """i""",
           """d""",
           """n""",
           """\u0120""",
           """\u0120l""",
           """\u0120n""",
           """\u0120lo""",
           """\u0120low""",
           """er""",
           """\u0120lowest""",
           """\u0120newer""",
           """\u0120wider""",
           """<unk>""",
       ]
       UpperCAmelCase_=       dict(zip(__UpperCAmelCase						,  range(len(__UpperCAmelCase					)					)					)					)
       UpperCAmelCase_=       ["""#version: 0.2""", """\u0120 l""", """\u0120l o""", """\u0120lo w""", """e r""", """"""]
       UpperCAmelCase_=       {"""unk_token""": """<unk>"""}

       UpperCAmelCase_=       os.path.join(self.tmpdirname						,  VOCAB_FILES_NAMES["""vocab_file"""]					)
       UpperCAmelCase_=       os.path.join(self.tmpdirname						,  VOCAB_FILES_NAMES["""merges_file"""]					)
       with open(self.vocab_file						,  """w"""						,  encoding="""utf-8"""					) as fp:
             fp.write(json.dumps(__UpperCAmelCase					) + """\n"""					)
       with open(self.merges_file						,  """w"""						,  encoding="""utf-8"""					) as fp:
             fp.write("""\n""".join(__UpperCAmelCase					)					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						Union[str, Any]						,  **__UpperCAmelCase     :						int					)      ->			Union[str, Any]:
       kwargs.update(self.special_tokens_map					)
       return self.tokenizer_class.from_pretrained(self.tmpdirname						,  **__UpperCAmelCase					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						List[Any]						,  **__UpperCAmelCase     :						Union[str, Any]					)      ->			List[str]:
       kwargs.update(self.special_tokens_map					)
       return self.rust_tokenizer_class.from_pretrained(self.tmpdirname						,  **__UpperCAmelCase					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						Dict						,  __UpperCAmelCase     :						Any					)      ->			int:
       UpperCAmelCase_=       """lower newer"""
       UpperCAmelCase_=       """lower newer"""
       return input_text, output_text




 def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			Optional[Any]:
       UpperCAmelCase_=       self.tokenizer_class(self.vocab_file						,  self.merges_file						,  **self.special_tokens_map					)
       UpperCAmelCase_=       """lower newer"""
       UpperCAmelCase_=       ["""l""", """o""", """w""", """er""", """\u0120""", """n""", """e""", """w""", """er"""]
       UpperCAmelCase_=       tokenizer.tokenize(__UpperCAmelCase					)  # , add_prefix_space=True)
       self.assertListEqual(__UpperCAmelCase						,  __UpperCAmelCase					)

       UpperCAmelCase_=       tokens + [tokenizer.unk_token]
       UpperCAmelCase_=       [0, 1, 2, 15, 10, 9, 3, 2, 15, 19]
       self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCAmelCase					)						,  __UpperCAmelCase					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						str					)      ->			Tuple:
       UpperCAmelCase_=       self.get_tokenizer()

       self.assertListEqual(tokenizer.encode("""Hello world!"""						,  add_special_tokens=__UpperCAmelCase					)						,  [0, 31_414, 232, 328, 2]					)
       self.assertListEqual(
           tokenizer.encode("""Hello world! cécé herlolip 418"""						,  add_special_tokens=__UpperCAmelCase					)						,  [0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]						,  )




 @slow
 def   _SCREAMING_SNAKE_CASE		(     self     :						List[Any]					)      ->			Union[str, Any]:
       UpperCAmelCase_=       self.tokenizer_class.from_pretrained("""allenai/longformer-base-4096"""					)

       UpperCAmelCase_=       tokenizer.encode("""sequence builders"""						,  add_special_tokens=__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.encode("""multi-sequence build"""						,  add_special_tokens=__UpperCAmelCase					)

       UpperCAmelCase_=       tokenizer.encode(
           """sequence builders"""						,  add_special_tokens=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.encode(
           """sequence builders"""						,  """multi-sequence build"""						,  add_special_tokens=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase					)

       UpperCAmelCase_=       tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase						,  __UpperCAmelCase					)

       assert encoded_sentence == encoded_text_from_decode
       assert encoded_pair == encoded_pair_from_decode




 def   _SCREAMING_SNAKE_CASE		(     self     :						Dict					)      ->			str:
       UpperCAmelCase_=       self.get_tokenizer()

       UpperCAmelCase_=       """Encode this sequence."""
       UpperCAmelCase_=       tokenizer.byte_encoder[""" """.encode("""utf-8"""					)[0]]

       # Testing encoder arguments
       UpperCAmelCase_=       tokenizer.encode(__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.convert_ids_to_tokens(encoded[0]					)[0]
       self.assertNotEqual(__UpperCAmelCase						,  __UpperCAmelCase					)

       UpperCAmelCase_=       tokenizer.encode(__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.convert_ids_to_tokens(encoded[0]					)[0]
       self.assertEqual(__UpperCAmelCase						,  __UpperCAmelCase					)

       tokenizer.add_special_tokens({"""bos_token""": """<s>"""}					)
       UpperCAmelCase_=       tokenizer.encode(__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.convert_ids_to_tokens(encoded[1]					)[0]
       self.assertNotEqual(__UpperCAmelCase						,  __UpperCAmelCase					)

       # Testing spaces after special tokens
       UpperCAmelCase_=       """<mask>"""
       tokenizer.add_special_tokens(
           {"""mask_token""": AddedToken(__UpperCAmelCase						,  lstrip=__UpperCAmelCase						,  rstrip=__UpperCAmelCase					)}					)  # mask token has a left space
       UpperCAmelCase_=       tokenizer.convert_tokens_to_ids(__UpperCAmelCase					)

       UpperCAmelCase_=       """Encode <mask> sequence"""
       UpperCAmelCase_=       """Encode <mask>sequence"""

       UpperCAmelCase_=       tokenizer.encode(__UpperCAmelCase					)
       UpperCAmelCase_=       encoded.index(__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1]					)[0]
       self.assertEqual(__UpperCAmelCase						,  __UpperCAmelCase					)

       UpperCAmelCase_=       tokenizer.encode(__UpperCAmelCase					)
       UpperCAmelCase_=       encoded.index(__UpperCAmelCase					)
       UpperCAmelCase_=       tokenizer.convert_ids_to_tokens(encoded[mask_loc + 1]					)[0]
       self.assertNotEqual(__UpperCAmelCase						,  __UpperCAmelCase					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						Any					)      ->			str:
       pass




 def   _SCREAMING_SNAKE_CASE		(     self     :						Dict					)      ->			List[str]:
       for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
             with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""					):
                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(__UpperCAmelCase						,  **__UpperCAmelCase					)
                   UpperCAmelCase_=       self.tokenizer_class.from_pretrained(__UpperCAmelCase						,  **__UpperCAmelCase					)
                   UpperCAmelCase_=       """A, <mask> AllenNLP sentence."""
                   UpperCAmelCase_=       tokenizer_r.encode_plus(__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase						,  return_token_type_ids=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_p.encode_plus(__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase						,  return_token_type_ids=__UpperCAmelCase					)

                   # token_type_ids should put 0 everywhere
                   self.assertEqual(sum(tokens_r["""token_type_ids"""]					)						,  sum(tokens_p["""token_type_ids"""]					)					)

                   # attention_mask should put 1 everywhere, so sum over length should be 1
                   self.assertEqual(
                       sum(tokens_r["""attention_mask"""]					) / len(tokens_r["""attention_mask"""]					)						,  sum(tokens_p["""attention_mask"""]					) / len(tokens_p["""attention_mask"""]					)						,  )

                   UpperCAmelCase_=       tokenizer_r.convert_ids_to_tokens(tokens_r["""input_ids"""]					)
                   UpperCAmelCase_=       tokenizer_p.convert_ids_to_tokens(tokens_p["""input_ids"""]					)

                   # Rust correctly handles the space before the mask while python doesnt
                   self.assertSequenceEqual(tokens_p["""input_ids"""]						,  [0, 250, 6, 50_264, 3_823, 487, 21_992, 3_645, 4, 2]					)
                   self.assertSequenceEqual(tokens_r["""input_ids"""]						,  [0, 250, 6, 50_264, 3_823, 487, 21_992, 3_645, 4, 2]					)

                   self.assertSequenceEqual(
                       __UpperCAmelCase						,  ["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]					)
                   self.assertSequenceEqual(
                       __UpperCAmelCase						,  ["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple					)      ->			Tuple:
       for trim_offsets, add_prefix_space in itertools.product([True, False]						,  repeat=2					):
             UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                 self.tmpdirname						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)

             UpperCAmelCase_=       json.loads(tokenizer_r.backend_tokenizer.pre_tokenizer.__getstate__()					)
             UpperCAmelCase_=       json.loads(tokenizer_r.backend_tokenizer.post_processor.__getstate__()					)

             self.assertEqual(pre_tokenizer_state["""add_prefix_space"""]						,  __UpperCAmelCase					)

             self.assertEqual(post_processor_state["""add_prefix_space"""]						,  __UpperCAmelCase					)
             self.assertEqual(post_processor_state["""trim_offsets"""]						,  __UpperCAmelCase					)




 def   _SCREAMING_SNAKE_CASE		(     self     :						List[Any]					)      ->			List[Any]:
       # Test which aims to verify that the offsets are well adapted to the argument `add_prefix_space` and
       # `trim_offsets`
       for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
             with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})"""					):
                   UpperCAmelCase_=       """hello"""  # `hello` is a token in the vocabulary of `pretrained_name`
                   UpperCAmelCase_=       F"""{text_of_1_token} {text_of_1_token}"""

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (len(__UpperCAmelCase					) + 1, len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (len(__UpperCAmelCase					) + 1, len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (len(__UpperCAmelCase					), len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (len(__UpperCAmelCase					), len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       F""" {text}"""

                   # tokenizer_r = self.rust_tokenizer_class.from_pretrained(
                   #     pretrained_name, use_fast=True, add_prefix_space=True, trim_offsets=True
                   # )
                   # encoding = tokenizer_r(text, return_offsets_mapping=True, add_special_tokens=False)
                   # self.assertEqual(encoding.offset_mapping[0], (1, 1 + len(text_of_1_token)))
                   # self.assertEqual(
                   #     encoding.offset_mapping[1],
                   #     (1 + len(text_of_1_token) + 1, 1 + len(text_of_1_token) + 1 + len(text_of_1_token)),
                   # )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (1, 1 + len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (1 + len(__UpperCAmelCase					) + 1, 1 + len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, 1 + len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (1 + len(__UpperCAmelCase					), 1 + len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )

                   UpperCAmelCase_=       self.rust_tokenizer_class.from_pretrained(
                       __UpperCAmelCase						,  use_fast=__UpperCAmelCase						,  add_prefix_space=__UpperCAmelCase						,  trim_offsets=__UpperCAmelCase					)
                   UpperCAmelCase_=       tokenizer_r(__UpperCAmelCase						,  return_offsets_mapping=__UpperCAmelCase						,  add_special_tokens=__UpperCAmelCase					)
                   self.assertEqual(encoding.offset_mapping[0]						,  (0, 1 + len(__UpperCAmelCase					))					)
                   self.assertEqual(
                       encoding.offset_mapping[1]						,  (1 + len(__UpperCAmelCase					), 1 + len(__UpperCAmelCase					) + 1 + len(__UpperCAmelCase					))						,  )









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


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

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






@dataclass
class 		lowercase						(			datasets.BuilderConfig):






	"""simple docstring"""


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




	def   _SCREAMING_SNAKE_CASE		(     self     :						Optional[Any]					)      ->			int:
							if self.delimiter is not None:
													UpperCAmelCase_=       self.delimiter
							if self.column_names is not None:
													UpperCAmelCase_=       self.column_names




	@property
	def   _SCREAMING_SNAKE_CASE		(     self     :						str					)      ->			Tuple:
							UpperCAmelCase_=       {
							    """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()						,  __UpperCAmelCase					):
																			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 		lowercase						(			datasets.ArrowBasedBuilder):






	"""simple docstring"""


	a__				: int		       =							CsvConfig




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




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




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




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						List[Any]					)      ->			List[str]:
							UpperCAmelCase_=       self.config.features.arrow_schema if self.config.features else None
							# dtype allows reading an int column as str
							UpperCAmelCase_=       (
							    {
							        name: dtype.to_pandas_dtype() if not require_storage_cast(__UpperCAmelCase					) 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(__UpperCAmelCase					)					):
													UpperCAmelCase_=       pd.read_csv(__UpperCAmelCase						,  iterator=__UpperCAmelCase						,  dtype=__UpperCAmelCase						,  **self.config.pd_read_csv_kwargs					)
													try:
																			for batch_idx, df in enumerate(__UpperCAmelCase					):
																									UpperCAmelCase_=       pa.Table.from_pandas(__UpperCAmelCase					)
																									# 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(__UpperCAmelCase					)
													except ValueError as e:
																			logger.error(F"""Failed to read file '{file}' with error {type(__UpperCAmelCase					)}: {e}"""					)
																			raise




