





"""simple docstring"""




import unittest

from parameterized import parameterized

from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    GPTNeoXForCausalLM,
		    GPTNeoXForQuestionAnswering,
		    GPTNeoXForSequenceClassification,
		    GPTNeoXForTokenClassification,
		    GPTNeoXModel,
		)


class  __UpperCamelCase       :






							def __init__(     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__=13   ,      lowerCAmelCase__=7   ,      lowerCAmelCase__=True   ,      lowerCAmelCase__=True   ,      lowerCAmelCase__=True   ,      lowerCAmelCase__=True   ,      lowerCAmelCase__=99   ,      lowerCAmelCase__=64   ,      lowerCAmelCase__=5   ,      lowerCAmelCase__=4   ,      lowerCAmelCase__=37   ,      lowerCAmelCase__="gelu"   ,      lowerCAmelCase__=0.1   ,      lowerCAmelCase__=0.1   ,      lowerCAmelCase__=512   ,      lowerCAmelCase__=16   ,      lowerCAmelCase__=2   ,      lowerCAmelCase__=0.02   ,      lowerCAmelCase__=3   ,      lowerCAmelCase__=4   ,      lowerCAmelCase__=None   ,      )			->				Optional[Any]:
								a   :	str			=       parent
								a   :	Union[str, Any]			=       batch_size
								a   :	Dict			=       seq_length
								a   :	Optional[Any]			=       is_training
								a   :	Optional[int]			=       use_input_mask
								a   :	str			=       use_token_type_ids
								a   :	Optional[int]			=       use_labels
								a   :	Dict			=       vocab_size
								a   :	Dict			=       hidden_size
								a   :	int			=       num_hidden_layers
								a   :	List[str]			=       num_attention_heads
								a   :	Tuple			=       intermediate_size
								a   :	List[Any]			=       hidden_act
								a   :	Optional[int]			=       hidden_dropout_prob
								a   :	Union[str, Any]			=       attention_probs_dropout_prob
								a   :	str			=       max_position_embeddings
								a   :	Optional[int]			=       type_vocab_size
								a   :	Optional[Any]			=       type_sequence_label_size
								a   :	Optional[int]			=       initializer_range
								a   :	List[str]			=       num_labels
								a   :	Any			=       num_choices
								a   :	Dict			=       scope
								a   :	Any			=       vocab_size - 1






							def 					__a     (     self   )			->				Any:
								a   :	Any			=       ids_tensor([self.batch_size, self.seq_length]   ,      self.vocab_size   )

								a   :	Optional[Any]			=       None
								if self.use_input_mask:
									a   :	Union[str, Any]			=       random_attention_mask([self.batch_size, self.seq_length]   )

								a   :	int			=       None
								if self.use_labels:
									a   :	Tuple			=       ids_tensor([self.batch_size, self.seq_length]   ,      self.num_labels   )

								a   :	Any			=       self.get_config()

								return config, input_ids, input_mask, token_labels






							def 					__a     (     self   )			->				Any:
								return GPTNeoXConfig(
								    vocab_size=self.vocab_size   ,      hidden_size=self.hidden_size   ,      num_hidden_layers=self.num_hidden_layers   ,      num_attention_heads=self.num_attention_heads   ,      intermediate_size=self.intermediate_size   ,      hidden_act=self.hidden_act   ,      hidden_dropout_prob=self.hidden_dropout_prob   ,      attention_probs_dropout_prob=self.attention_probs_dropout_prob   ,      max_position_embeddings=self.max_position_embeddings   ,      type_vocab_size=self.type_vocab_size   ,      is_decoder=lowerCAmelCase__   ,      initializer_range=self.initializer_range   ,      pad_token_id=self.pad_token_id   ,      )






							def 					__a     (     self   )			->				int:
								a, a, a, a   :	Optional[int]			=       self.prepare_config_and_inputs()

								a   :	Any			=       True

								return config, input_ids, input_mask, token_labels






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				Optional[int]:
								a   :	Dict			=       GPTNeoXModel(config=lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	Any			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   )
								a   :	Tuple			=       model(lowerCAmelCase__   )
								self.parent.assertEqual(result.last_hidden_state.shape   ,      (self.batch_size, self.seq_length, self.hidden_size)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				Optional[Any]:
								a   :	int			=       True
								a   :	List[Any]			=       GPTNeoXModel(lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	Optional[int]			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   )
								self.parent.assertEqual(result.last_hidden_state.shape   ,      (self.batch_size, self.seq_length, self.hidden_size)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				Union[str, Any]:
								a   :	List[str]			=       GPTNeoXForCausalLM(config=lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	int			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      labels=lowerCAmelCase__   )
								self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.seq_length, self.vocab_size)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				str:
								a   :	str			=       self.num_labels
								a   :	List[str]			=       GPTNeoXForQuestionAnswering(lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	Union[str, Any]			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   )
								self.parent.assertEqual(result.start_logits.shape   ,      (self.batch_size, self.seq_length)   )
								self.parent.assertEqual(result.end_logits.shape   ,      (self.batch_size, self.seq_length)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				Optional[Any]:
								a   :	List[str]			=       self.num_labels
								a   :	Dict			=       GPTNeoXForSequenceClassification(lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	Optional[int]			=       ids_tensor([self.batch_size]   ,      self.type_sequence_label_size   )
								a   :	List[str]			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      labels=lowerCAmelCase__   )
								self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.num_labels)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				Union[str, Any]:
								a   :	Any			=       self.num_labels
								a   :	Tuple			=       GPTNeoXForTokenClassification(lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()
								a   :	List[str]			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      labels=lowerCAmelCase__   )
								self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.seq_length, self.num_labels)   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				List[str]:
								a   :	Tuple			=       True
								a   :	int			=       GPTNeoXForCausalLM(config=lowerCAmelCase__   )
								model.to(lowerCAmelCase__   )
								model.eval()

								# first forward pass
								a   :	Tuple			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      use_cache=lowerCAmelCase__   )
								a   :	int			=       outputs.past_key_values

								# create hypothetical multiple next token and extent to next_input_ids
								a   :	str			=       ids_tensor((self.batch_size, 3)   ,      config.vocab_size   )
								a   :	Optional[Any]			=       ids_tensor((self.batch_size, 3)   ,      vocab_size=2   )

								# append to next input_ids and
								a   :	str			=       torch.cat([input_ids, next_tokens]   ,      dim=-1   )
								a   :	Dict			=       torch.cat([input_mask, next_mask]   ,      dim=-1   )

								a   :	Union[str, Any]			=       model(lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      output_hidden_states=lowerCAmelCase__   )
								a   :	int			=       output_from_no_past["hidden_states"][0]
								a   :	Union[str, Any]			=       model(
								    lowerCAmelCase__   ,      attention_mask=lowerCAmelCase__   ,      past_key_values=lowerCAmelCase__   ,      output_hidden_states=lowerCAmelCase__   ,      )["hidden_states"][0]

								# select random slice
								a   :	Optional[int]			=       ids_tensor((1,)   ,      output_from_past.shape[-1]   ).item()
								a   :	Union[str, Any]			=       output_from_no_past[:, -3:, random_slice_idx].detach()
								a   :	Any			=       output_from_past[:, :, random_slice_idx].detach()

								self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]   )

								# test that outputs are equal for slice
								self.parent.assertTrue(torch.allclose(lowerCAmelCase__   ,      lowerCAmelCase__   ,      atol=1E-3   )   )






							def 					__a     (     self   )			->				Tuple:
								a   :	List[str]			=       self.prepare_config_and_inputs()
								a, a, a, a   :	Any			=       config_and_inputs
								a   :	List[str]			=       {"input_ids": input_ids, "attention_mask": input_mask}
								return config, inputs_dict


@require_torch
class  __UpperCamelCase       (		a__	, a__	, a__	, unittest.TestCase		):
							lowerCamelCase     :      int         =(
							    (
							        GPTNeoXModel,
							        GPTNeoXForCausalLM,
							        GPTNeoXForQuestionAnswering,
							        GPTNeoXForSequenceClassification,
							        GPTNeoXForTokenClassification,
							    )
							    if is_torch_available()
							    else ()
							)
							lowerCamelCase     :      str         =(GPTNeoXForCausalLM,) if is_torch_available() else ()
							lowerCamelCase     :      int         =(
							    {
							        """feature-extraction""": GPTNeoXModel,
							        """question-answering""": GPTNeoXForQuestionAnswering,
							        """text-classification""": GPTNeoXForSequenceClassification,
							        """text-generation""": GPTNeoXForCausalLM,
							        """token-classification""": GPTNeoXForTokenClassification,
							        """zero-shot""": GPTNeoXForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)
							lowerCamelCase     :      Union[str, Any]         =False
							lowerCamelCase     :      Optional[Any]         =False
							lowerCamelCase     :      Union[str, Any]         =False
							lowerCamelCase     :      str         =False






							def 					__a     (     self   )			->				Optional[int]:
								a   :	Tuple			=       GPTNeoXModelTester(self   )
								a   :	Dict			=       ConfigTester(self   ,      config_class=lowerCAmelCase__   ,      hidden_size=64   ,      num_attention_heads=8   )






							def 					__a     (     self   )			->				Optional[Any]:
								self.config_tester.run_common_tests()






							def 					__a     (     self   )			->				Union[str, Any]:
								a, a, a, a   :	Optional[int]			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )






							def 					__a     (     self   )			->				int:
								a, a, a, a   :	str			=       self.model_tester.prepare_config_and_inputs_for_decoder()
								self.model_tester.create_and_check_model_as_decoder(lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )






							def 					__a     (     self   )			->				Optional[int]:
								# This regression test was failing with PyTorch < 1.3
								a, a, a, a   :	str			=       self.model_tester.prepare_config_and_inputs_for_decoder()

								a   :	Optional[int]			=       None

								self.model_tester.create_and_check_model_as_decoder(lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )






							def 					__a     (     self   )			->				Union[str, Any]:
								a, a, a, a   :	int			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_decoder_model_past_large_inputs(lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )






							def 					__a     (     self   )			->				List[str]:
								a   :	str			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_causal_lm(*lowerCAmelCase__   )






							def 					__a     (     self   )			->				str:
								a   :	int			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase__   )






							def 					__a     (     self   )			->				List[str]:
								a   :	List[Any]			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase__   )






							def 					__a     (     self   )			->				str:
								a   :	int			=       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase__   )






							@unittest.skip(reason="Feed forward chunking is not implemented"   )
							def 					__a     (     self   )			->				Union[str, Any]:
								pass






							@parameterized.expand([("linear",), ("dynamic",)]   )
							def 					__a     (     self   ,      lowerCAmelCase__   )			->				str:
								a, a   :	Tuple			=       self.model_tester.prepare_config_and_inputs_for_common()
								a   :	Union[str, Any]			=       ids_tensor([1, 10]   ,      config.vocab_size   )
								a   :	Tuple			=       ids_tensor([1, int(config.max_position_embeddings * 1.5   )]   ,      config.vocab_size   )

								set_seed(42   )  # Fixed seed at init time so the two models get the same random weights
								a   :	List[Any]			=       GPTNeoXModel(lowerCAmelCase__   )
								original_model.to(lowerCAmelCase__   )
								original_model.eval()
								a   :	Tuple			=       original_model(lowerCAmelCase__   ).last_hidden_state
								a   :	Dict			=       original_model(lowerCAmelCase__   ).last_hidden_state

								set_seed(42   )  # Fixed seed at init time so the two models get the same random weights
								a   :	List[Any]			=       {"type": scaling_type, "factor": 10.0}
								a   :	List[Any]			=       GPTNeoXModel(lowerCAmelCase__   )
								scaled_model.to(lowerCAmelCase__   )
								scaled_model.eval()
								a   :	str			=       scaled_model(lowerCAmelCase__   ).last_hidden_state
								a   :	Optional[int]			=       scaled_model(lowerCAmelCase__   ).last_hidden_state

								# Dynamic scaling does not change the RoPE embeddings until it receives an input longer than the original
								# maximum sequence length, so the outputs for the short input should match.
								if scaling_type == "dynamic":
									self.assertTrue(torch.allclose(lowerCAmelCase__   ,      lowerCAmelCase__   ,      atol=1E-5   )   )
								else:
									self.assertFalse(torch.allclose(lowerCAmelCase__   ,      lowerCAmelCase__   ,      atol=1E-5   )   )

								# The output should be different for long inputs
								self.assertFalse(torch.allclose(lowerCAmelCase__   ,      lowerCAmelCase__   ,      atol=1E-5   )   )


@require_torch
class  __UpperCamelCase       (		unittest.TestCase		):






							@slow
							def 					__a     (     self   )			->				int:
								a   :	Optional[Any]			=       AutoTokenizer.from_pretrained("EleutherAI/pythia-410m-deduped"   )
								for checkpointing in [True, False]:
									a   :	List[str]			=       GPTNeoXForCausalLM.from_pretrained("EleutherAI/pythia-410m-deduped"   )

									if checkpointing:
										model.gradient_checkpointing_enable()
									else:
										model.gradient_checkpointing_disable()
									model.to(lowerCAmelCase__   )

									a   :	str			=       tokenizer("My favorite food is"   ,      return_tensors="pt"   ).to(lowerCAmelCase__   )
									# The hub repo. is updated on 2023-04-04, resulting in poor outputs.
									# See: https://github.com/huggingface/transformers/pull/24193
									a   :	List[str]			=       "My favorite food is a good old-fashioned, old-fashioned, old-fashioned.\n\nI'm not sure"

									a   :	List[str]			=       model.generate(**lowerCAmelCase__   ,      do_sample=lowerCAmelCase__   ,      max_new_tokens=20   )
									a   :	str			=       tokenizer.batch_decode(lowerCAmelCase__   )[0]

									self.assertEqual(lowerCAmelCase__   ,      lowerCAmelCase__   )









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


a		:				Optional[Any]  			=    datasets.utils.logging.get_logger(__name__)

a		:				Union[str, Any]  			=    ['''names''', '''prefix''']
a		:				Any  			=    ['''warn_bad_lines''', '''error_bad_lines''', '''mangle_dupe_cols''']
a		:				Any  			=    ['''encoding_errors''', '''on_bad_lines''']
a		:				List[str]  			=    ['''date_format''']


@dataclass
class  __UpperCamelCase       (		datasets.BuilderConfig		):
							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         =1_0000
							lowerCamelCase     :      Optional[datasets.Features]         =None
							lowerCamelCase     :      Optional[str]         ="strict"
							lowerCamelCase     :      Literal["error", "warn", "skip"]         ="error"
							lowerCamelCase     :      Optional[str]         =None






							def 					__a     (     self   )			->				Dict:
								if self.delimiter is not None:
									a   :	int			=       self.delimiter
								if self.column_names is not None:
									a   :	Any			=       self.column_names






							@property
							def 					__a     (     self   )			->				List[str]:
								a   :	Dict			=       {
								    "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()   ,      lowerCAmelCase__   ):
										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  __UpperCamelCase       (		datasets.ArrowBasedBuilder		):
							lowerCamelCase     :      Union[str, Any]         =CsvConfig






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






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






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






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


