
'''simple docstring'''
import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


_SCREAMING_SNAKE_CASE =	datasets.utils.logging.get_logger(__name__)
@dataclass
class      __UpperCAmelCase							(    datasets.BuilderConfig							):



					'''simple docstring'''





					_UpperCamelCase  	=		None





class      __UpperCAmelCase							(    datasets.ArrowBasedBuilder							):



					'''simple docstring'''





					_UpperCamelCase  	=		ArrowConfig



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



					def 						__snake_case	(  self    :	Optional[int]			,					_lowercase    :	List[Any])						->       Union[str, Any]:
								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_       		=   dl_manager.download_and_extract(self.config.data_files)
								if isinstance(_lowercase			,					(str, list, tuple)):
											A_       		=   data_files
											if isinstance(_lowercase			,					_lowercase):
														A_       		=   [files]
											# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
											A_       		=   [dl_manager.iter_files(_lowercase) for file in files]
											return [datasets.SplitGenerator(name=datasets.Split.TRAIN			,					gen_kwargs={'files': files})]
								A_       		=   []
								for split_name, files in data_files.items():
											if isinstance(_lowercase			,					_lowercase):
														A_       		=   [files]
											# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
											A_       		=   [dl_manager.iter_files(_lowercase) for file in files]
											# Infer features is they are stoed in the arrow schema
											if self.info.features is None:
														for file in itertools.chain.from_iterable(_lowercase):
																	with open(_lowercase			,					'rb') as f:
																				A_       		=   datasets.Features.from_arrow_schema(pa.ipc.open_stream(_lowercase).schema)
																	break
											splits.append(datasets.SplitGenerator(name=_lowercase			,					gen_kwargs={'files': files}))
								return splits



					def 						__snake_case	(  self    :	List[Any]			,					_lowercase    :	pa.Table)						->       pa.Table:
								if self.info.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
											A_       		=   table_cast(_lowercase			,					self.info.features.arrow_schema)
								return pa_table



					def 						__snake_case	(  self    :	Dict			,					_lowercase    :	Any)						->       List[str]:
								for file_idx, file in enumerate(itertools.chain.from_iterable(_lowercase)):
											with open(_lowercase			,					'rb') as f:
														try:
																	for batch_idx, record_batch in enumerate(pa.ipc.open_stream(_lowercase)):
																				A_       		=   pa.Table.from_batches([record_batch])
																				# 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 F'{file_idx}_{batch_idx}', self._cast_table(_lowercase)
														except ValueError as e:
																	logger.error(F'Failed to read file \'{file}\' with error {type(_lowercase)}: {e}')
																	raise










'''simple docstring'''
from __future__ import annotations

import sys





def  lowerCamelCase(       SCREAMING_SNAKE_CASE_					,SCREAMING_SNAKE_CASE_    )		->		tuple[int, int]:
			# base cases
			if abs(SCREAMING_SNAKE_CASE_    ) == 1:
						return a, 0
			elif abs(SCREAMING_SNAKE_CASE_    ) == 1:
						return 0, b

			A_		,   A_       		=   a, b
			A_		,   A_       		=   1, 0
			A_		,   A_       		=   0, 1

			while remainder != 0:
						A_       		=   old_remainder // remainder
						A_		,   A_       		=   remainder, old_remainder - quotient * remainder
						A_		,   A_       		=   coeff_a, old_coeff_a - quotient * coeff_a
						A_		,   A_       		=   coeff_b, old_coeff_b - quotient * coeff_b

			# sign correction for negative numbers
			if a < 0:
						A_       		=   -old_coeff_a
			if b < 0:
						A_       		=   -old_coeff_b

			return old_coeff_a, old_coeff_b





def  lowerCamelCase(       )		->		Tuple:
			if len(sys.argv    ) < 3:
						print('2 integer arguments required'    )
						return 1
			A_       		=   int(sys.argv[1]    )
			A_       		=   int(sys.argv[2]    )
			print(extended_euclidean_algorithm(SCREAMING_SNAKE_CASE_					,SCREAMING_SNAKE_CASE_    )    )
			return 0


if __name__ == "__main__":
							raise SystemExit(main())




