


import itertools
from dataclasses import dataclass
from typing import Optional

import pandas as pd
import pyarrow as pa

import datasets
from datasets.table import table_cast







@dataclass
class        lowerCamelCase__	(							datasets.BuilderConfig      ):






			"""simple docstring"""






			_UpperCamelCase		:					Optional[datasets.Features]    =		None







class        lowerCamelCase__	(							datasets.ArrowBasedBuilder      ):






			"""simple docstring"""






			_UpperCamelCase		:					Optional[Any]    =		PandasConfig




			def 				snake_case__				(							self				):

						'''simple docstring'''


						return datasets.DatasetInfo(features=self.config.features				)




			def 				snake_case__				(							self      ,						snake_case				):

						'''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}'''				)
						UpperCamelCase__					=       dl_manager.download_and_extract(self.config.data_files				)
						if isinstance(snake_case      ,						(str, list, tuple)				):
									UpperCamelCase__					=       data_files
									if isinstance(snake_case      ,						snake_case				):
												UpperCamelCase__					=       [files]
									# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
									UpperCamelCase__					=       [dl_manager.iter_files(snake_case				) 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(snake_case      ,						snake_case				):
												UpperCamelCase__					=       [files]
									# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
									UpperCamelCase__					=       [dl_manager.iter_files(snake_case				) for file in files]
									splits.append(datasets.SplitGenerator(name=snake_case      ,						gen_kwargs={"files": files}				)				)
						return splits




			def 				snake_case__				(							self      ,						snake_case				):

						'''simple docstring'''


						if self.config.features is not None:
									# more expensive cast to support nested features with keys in a different order
									# allows str <-> int/float or str to Audio for example
									UpperCamelCase__					=       table_cast(snake_case      ,						self.config.features.arrow_schema				)
						return pa_table







			def 				snake_case__				(							self      ,						snake_case				):

						'''simple docstring'''


						for i, file in enumerate(itertools.chain.from_iterable(snake_case				)				):
									with open(snake_case      ,						"rb"				) as f:
												UpperCamelCase__					=       pa.Table.from_pandas(pd.read_pickle(snake_case				)				)
												yield i, self._cast_table(snake_case				)






def        UpperCamelCase_(				_A   :str  )->		int:
			UpperCamelCase__					=       hex_num.strip()
			if not hex_num:
						raise ValueError("No value was passed to the function"  )

			UpperCamelCase__					=       hex_num[0] == "-"
			if is_negative:
						UpperCamelCase__					=       hex_num[1:]

			try:
						UpperCamelCase__					=       int(_A				,     16  )
			except ValueError:
						raise ValueError("Invalid value was passed to the function"  )

			UpperCamelCase__					=       ""
			while int_num > 0:
						UpperCamelCase__					=       str(int_num % 2  ) + bin_str
						int_num >>= 1

			return int(("-" + bin_str) if is_negative else bin_str  )


if __name__ == "__main__":
						import doctest

						doctest.testmod()


