





'''simple docstring'''






import time
from dataclasses import dataclass
from multiprocessing import Pool
from unittest import TestCase
from unittest.mock import patch

import multiprocess
import numpy as np
import pytest

from datasets.utils.py_utils import (
    NestedDataStructure,
    asdict,
    iflatmap_unordered,
    map_nested,
    temp_seed,
    temporary_assignment,
    zip_dict,
)

from .utils import require_tf, require_torch



def        UpperCamelCase__		(						__magic_name__  :   int      )				->			List[Any]:  # picklable for multiprocessing
 '''simple docstring'''






 return x.sum()



def        UpperCamelCase__		(						__magic_name__  :   Any      )				->			Optional[int]:  # picklable for multiprocessing
 '''simple docstring'''






 return i + 1
@dataclass
class 					__snake_case  :






   '''simple docstring'''





   lowerCamelCase__    							=      42
   lowerCamelCase__    							=      42



class 					__snake_case  (					__SCREAMING_SNAKE_CASE							):






   '''simple docstring'''





   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					str    =  {}
    snake_case__     :					Tuple    =  []
    snake_case__     :					List[Any]    =  1
    snake_case__     :					Union[str, Any]    =  [1, 2]
    snake_case__     :					str    =  {"""a""": 1, """b""": 2}
    snake_case__     :					Dict    =  {"""a""": [1, 2], """b""": [3, 4]}
    snake_case__     :					Dict    =  {"""a""": {"""1""": 1}, """b""": 2}
    snake_case__     :					Optional[int]    =  {"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
    snake_case__     :					int    =  {}
    snake_case__     :					Tuple    =  []
    snake_case__     :					Optional[Any]    =  2
    snake_case__     :					Tuple    =  [2, 3]
    snake_case__     :					str    =  {"""a""": 2, """b""": 3}
    snake_case__     :					List[Any]    =  {"""a""": [2, 3], """b""": [4, 5]}
    snake_case__     :					Union[str, Any]    =  {"""a""": {"""1""": 2}, """b""": 3}
    snake_case__     :					Optional[int]    =  {"""a""": 2, """b""": 3, """c""": 4, """d""": 5}
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )

    snake_case__     :					Optional[int]    =  2
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )

    snake_case__     :					int    =  {"""a""": np.eye(2       ), """b""": np.zeros(3       ), """c""": np.ones(2       )}
    snake_case__     :					int    =  {"""a""": 2, """b""": 0, """c""": 2}
    snake_case__     :					Union[str, Any]    =  {
        """a""": np.eye(2       ).astype(__SCREAMING_SNAKE_CASE       ),
        """b""": np.zeros(3       ).astype(__SCREAMING_SNAKE_CASE       ),
        """c""": np.ones(2       ).astype(__SCREAMING_SNAKE_CASE       ),
    }
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		map_numpy=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(
        {k: v.tolist() for k, v in map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		map_numpy=__SCREAMING_SNAKE_CASE       ).items()}	,		{k: v.tolist() for k, v in expected_map_nested_sna_int.items()}	,		)
    self.assertEqual(map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		map_numpy=__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )
    self.assertEqual(
        {k: v.tolist() for k, v in map_nested(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		map_numpy=__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       ).items()}	,		{k: v.tolist() for k, v in expected_map_nested_sna_int.items()}	,		)
    with self.assertRaises(__SCREAMING_SNAKE_CASE       ):  # can't pickle a local lambda
     map_nested(lambda __SCREAMING_SNAKE_CASE       : x + 1	,		__SCREAMING_SNAKE_CASE	,		num_proc=__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					Union[str, Any]    =  {"""a""": 1, """b""": 2}
    snake_case__     :					Optional[int]    =  {"""a""": 3, """b""": 4}
    snake_case__     :					List[Any]    =  {"""a""": 5, """b""": 6}
    snake_case__     :					Optional[Any]    =  sorted([("""a""", (1, 3, 5)), ("""b""", (2, 4, 6))]       )
    self.assertEqual(sorted(zip_dict(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )       )	,		__SCREAMING_SNAKE_CASE       )


   def 		__UpperCamelCase						(							self       ):
    class 					__snake_case  :






       '''simple docstring'''





       lowerCamelCase__    							=      '''bar'''



    snake_case__     :					str    =  Foo()
    self.assertEqual(foo.my_attr	,		"""bar"""       )
    with temporary_assignment(__SCREAMING_SNAKE_CASE	,		"""my_attr"""	,		"""BAR"""       ):
     self.assertEqual(foo.my_attr	,		"""BAR"""       )
    self.assertEqual(foo.my_attr	,		"""bar"""       )



@pytest.mark.parametrize(
    """iterable_length, num_proc, expected_num_proc"""		,       [
        (1, None, 1),
        (1, 1, 1),
        (2, None, 1),
        (2, 1, 1),
        (2, 2, 1),
        (2, 3, 1),
        (3, 2, 1),
        (16, 16, 16),
        (16, 17, 16),
        (17, 16, 16),
    ]		,       )
def        UpperCamelCase__		(						__magic_name__  :   List[Any]		,       __magic_name__  :   List[Any]		,       __magic_name__  :   Any      )				->			Optional[int]:
 '''simple docstring'''






 with patch("""datasets.utils.py_utils._single_map_nested"""      ) as mock_single_map_nested, patch(
     """datasets.parallel.parallel.Pool"""      ) as mock_multiprocessing_pool:
  snake_case__     :					Optional[int]    =  {f"{i}": i for i in range(__magic_name__      )}
  snake_case__     :					List[str]    =  map_nested(lambda __magic_name__      : x + 10		,       __magic_name__		,       num_proc=__magic_name__		,       parallel_min_length=16      )
  if expected_num_proc == 1:
   assert mock_single_map_nested.called
   assert not mock_multiprocessing_pool.called
  else:
   assert not mock_single_map_nested.called
   assert mock_multiprocessing_pool.called
   assert mock_multiprocessing_pool.call_args[0][0] == expected_num_proc
class 					__snake_case  (					__SCREAMING_SNAKE_CASE							):






   '''simple docstring'''





   @require_tf
   def 		__UpperCamelCase						(							self       ):
    import tensorflow as tf
    from tensorflow.keras import layers

    snake_case__     :					Any    =  layers.Dense(2       )

    def gen_random_output():
     snake_case__     :					Union[str, Any]    =  tf.random.uniform((1, 3)       )
     return model(__SCREAMING_SNAKE_CASE       ).numpy()

    with temp_seed(4_2	,		set_tensorflow=__SCREAMING_SNAKE_CASE       ):
     snake_case__     :					Optional[Any]    =  gen_random_output()
    with temp_seed(4_2	,		set_tensorflow=__SCREAMING_SNAKE_CASE       ):
     snake_case__     :					Dict    =  gen_random_output()
    snake_case__     :					Optional[Any]    =  gen_random_output()

    np.testing.assert_equal(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )
    self.assertGreater(np.abs(outa - outa       ).sum()	,		0       )

   @require_torch
   def 		__UpperCamelCase						(							self       ):
    import torch

    def gen_random_output():
     snake_case__     :					List[Any]    =  torch.nn.Linear(3	,		2       )
     snake_case__     :					Dict    =  torch.rand(1	,		3       )
     return model(__SCREAMING_SNAKE_CASE       ).detach().numpy()

    with temp_seed(4_2	,		set_pytorch=__SCREAMING_SNAKE_CASE       ):
     snake_case__     :					int    =  gen_random_output()
    with temp_seed(4_2	,		set_pytorch=__SCREAMING_SNAKE_CASE       ):
     snake_case__     :					str    =  gen_random_output()
    snake_case__     :					Any    =  gen_random_output()

    np.testing.assert_equal(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )
    self.assertGreater(np.abs(outa - outa       ).sum()	,		0       )


   def 		__UpperCamelCase						(							self       ):
    def gen_random_output():
     return np.random.rand(1	,		3       )

    with temp_seed(4_2       ):
     snake_case__     :					Any    =  gen_random_output()
    with temp_seed(4_2       ):
     snake_case__     :					Optional[Any]    =  gen_random_output()
    snake_case__     :					int    =  gen_random_output()

    np.testing.assert_equal(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )
    self.assertGreater(np.abs(outa - outa       ).sum()	,		0       )



@pytest.mark.parametrize("""input_data"""		,       [{}]      )
def        UpperCamelCase__		(						__magic_name__  :   List[Any]      )				->			Dict:
 '''simple docstring'''






 snake_case__     :					Union[str, Any]    =  NestedDataStructure(__magic_name__      ).data
 assert output_data == input_data



@pytest.mark.parametrize(
    """data, expected_output"""		,       [
        ({}, []),
        ([], []),
        ("""foo""", ["""foo"""]),
        (["""foo""", """bar"""], ["""foo""", """bar"""]),
        ([["""foo""", """bar"""]], ["""foo""", """bar"""]),
        ([[["""foo"""], ["""bar"""]]], ["""foo""", """bar"""]),
        ([[["""foo"""], """bar"""]], ["""foo""", """bar"""]),
        ({"""a""": 1, """b""": 2}, [1, 2]),
        ({"""a""": [1, 2], """b""": [3, 4]}, [1, 2, 3, 4]),
        ({"""a""": [[1, 2]], """b""": [[3, 4]]}, [1, 2, 3, 4]),
        ({"""a""": [[1, 2]], """b""": [3, 4]}, [1, 2, 3, 4]),
        ({"""a""": [[[1], [2]]], """b""": [[[3], [4]]]}, [1, 2, 3, 4]),
        ({"""a""": [[[1], [2]]], """b""": [[3, 4]]}, [1, 2, 3, 4]),
        ({"""a""": [[[1], [2]]], """b""": [3, 4]}, [1, 2, 3, 4]),
        ({"""a""": [[[1], [2]]], """b""": [3, [4]]}, [1, 2, 3, 4]),
        ({"""a""": {"""1""": 1}, """b""": 2}, [1, 2]),
        ({"""a""": {"""1""": [1]}, """b""": 2}, [1, 2]),
        ({"""a""": {"""1""": [1]}, """b""": [2]}, [1, 2]),
    ]		,       )
def        UpperCamelCase__		(						__magic_name__  :   Tuple		,       __magic_name__  :   Union[str, Any]      )				->			Optional[int]:
 '''simple docstring'''






 snake_case__     :					Optional[int]    =  NestedDataStructure(__magic_name__      ).flatten()
 assert output == expected_output



def        UpperCamelCase__		(						)				->			Union[str, Any]:
 '''simple docstring'''






 snake_case__     :					int    =  A(x=1		,       y="""foobar"""      )
 snake_case__     :					Optional[int]    =  {"""x""": 1, """y""": """foobar"""}
 assert asdict(__magic_name__      ) == expected_output

 snake_case__     :					Tuple    =  {"""a""": {"""b""": A(x=10		,       y="""foo"""      )}, """c""": [A(x=20		,       y="""bar"""      )]}
 snake_case__     :					str    =  {"""a""": {"""b""": {"""x""": 10, """y""": """foo"""}}, """c""": [{"""x""": 20, """y""": """bar"""}]}
 assert asdict(__magic_name__      ) == expected_output

 with pytest.raises(__magic_name__      ):
  asdict([1, A(x=10		,       y="""foo"""      )]      )



def        UpperCamelCase__		(						__magic_name__  :   str      )				->			str:
 '''simple docstring'''






 return text.split()



def        UpperCamelCase__		(						__magic_name__  :   Union[str, Any]      )				->			Optional[int]:
 '''simple docstring'''






 yield (time.time(), content)
 time.sleep(2      )
 yield (time.time(), content)





def        UpperCamelCase__		(						)				->			Optional[int]:
 '''simple docstring'''






 with Pool(2      ) as pool:
  snake_case__     :					Optional[Any]    =  list(iflatmap_unordered(__magic_name__		,       _split_text		,       kwargs_iterable=[{"""text""": """hello there"""}] * 10      )      )
  assert out.count("""hello"""      ) == 10
  assert out.count("""there"""      ) == 10
  assert len(__magic_name__      ) == 20

 # check multiprocess from pathos (uses dill for pickling)
 with multiprocess.Pool(2      ) as pool:
  snake_case__     :					Dict    =  list(iflatmap_unordered(__magic_name__		,       _split_text		,       kwargs_iterable=[{"""text""": """hello there"""}] * 10      )      )
  assert out.count("""hello"""      ) == 10
  assert out.count("""there"""      ) == 10
  assert len(__magic_name__      ) == 20

 # check that we get items as fast as possible
 with Pool(2      ) as pool:
  snake_case__     :					Any    =  []
  for yield_time, content in iflatmap_unordered(
      __magic_name__		,       _aseconds_generator_of_aitems_with_timing		,       kwargs_iterable=[{"""content""": """a"""}, {"""content""": """b"""}]      ):
   assert yield_time < time.time() + 0.1, "we should each item directly after it was yielded"
   out.append(__magic_name__      )
  assert out.count("""a"""      ) == 2
  assert out.count("""b"""      ) == 2
  assert len(__magic_name__      ) == 4









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


_lowerCAmelCase	:   Any    =   datasets.utils.logging.get_logger(__name__)

_lowerCAmelCase	:   Any    =   ["names", "prefix"]
_lowerCAmelCase	:   str    =   ["warn_bad_lines", "error_bad_lines", "mangle_dupe_cols"]
_lowerCAmelCase	:   List[str]    =   ["encoding_errors", "on_bad_lines"]
_lowerCAmelCase	:   int    =   ["date_format"]


@dataclass
class 	__snake_case   ( datasets.BuilderConfig ):
		SCREAMING_SNAKE_CASE__								=	","
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"infer"
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"."
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	'"'
		SCREAMING_SNAKE_CASE__								=	0
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	0
		SCREAMING_SNAKE_CASE__								=	True
		SCREAMING_SNAKE_CASE__								=	False
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	10000
		SCREAMING_SNAKE_CASE__								=	None
		SCREAMING_SNAKE_CASE__								=	"strict"
		SCREAMING_SNAKE_CASE__								=	"error"
		SCREAMING_SNAKE_CASE__								=	None
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						if self.delimiter is not None:
										lowerCAmelCase__		  =  self.delimiter
						if self.column_names is not None:
										lowerCAmelCase__		  =  self.column_names



		@property
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						lowerCAmelCase__		  =  {
						    '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 	__snake_case   ( datasets.ArrowBasedBuilder ):
		SCREAMING_SNAKE_CASE__								=	CsvConfig
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						return datasets.DatasetInfo(features=self.config.features						)
		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







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







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



		def 						SCREAMING_SNAKE_CASE_					(							self    ,a_						):







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