






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 							snake_case_       (    datasets.BuilderConfig      ):

						"""simple docstring"""



						snake_case__        =      None




class 							snake_case_       (    datasets.ArrowBasedBuilder      ):

						"""simple docstring"""



						snake_case__        =      PandasConfig



						def        UpperCAmelCase__					(self:					Union[str, Any]   )    ->     List[Any]:




											'''simple docstring'''



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



						def        UpperCAmelCase__					(self:					Optional[int] ,					__UpperCAmelCase:					Dict   )    ->     str:




											'''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}'   )
											__a					:						Any      =					dl_manager.download_and_extract(self.config.data_files   )
											if isinstance(__UpperCAmelCase ,					(str, list, tuple)   ):
																__a					:						str      =					data_files
																if isinstance(__UpperCAmelCase ,					__UpperCAmelCase   ):
																					__a					:						List[str]      =					[files]
																# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																__a					:						Optional[Any]      =					[dl_manager.iter_files(__UpperCAmelCase   ) for file in files]
																return [datasets.SplitGenerator(name=datasets.Split.TRAIN ,					gen_kwargs={"files": files}   )]
											__a					:						List[Any]      =					[]
											for split_name, files in data_files.items():
																if isinstance(__UpperCAmelCase ,					__UpperCAmelCase   ):
																					__a					:						Tuple      =					[files]
																# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																__a					:						Union[str, Any]      =					[dl_manager.iter_files(__UpperCAmelCase   ) for file in files]
																splits.append(datasets.SplitGenerator(name=__UpperCAmelCase ,					gen_kwargs={"files": files}   )   )
											return splits



						def        UpperCAmelCase__					(self:					str ,					__UpperCAmelCase:					pa.Table   )    ->     pa.Table:




											'''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
																__a					:						List[Any]      =					table_cast(__UpperCAmelCase ,					self.config.features.arrow_schema   )
											return pa_table



						def        UpperCAmelCase__					(self:					List[str] ,					__UpperCAmelCase:					Optional[int]   )    ->     str:




											'''simple docstring'''



											for i, file in enumerate(itertools.chain.from_iterable(__UpperCAmelCase   )   ):
																with open(__UpperCAmelCase ,					"rb"   ) as f:
																					__a					:						List[Any]      =					pa.Table.from_pandas(pd.read_pickle(__UpperCAmelCase   )   )
																					yield i, self._cast_table(__UpperCAmelCase   )













def     a_   (__A				,       __A				,       __A				,       __A      )				->						int:



					"""simple docstring"""
					__a      ,			__a					:						Any      =					len(__A      ), len(grid[0]      )
					if (
					    min(__A				,       __A      ) < 0
					    or row == row_length
					    or col == col_length
					    or (row, col) in visit
					    or grid[row][col] == 1
					):
										return 0
					if row == row_length - 1 and col == col_length - 1:
										return 1

					visit.add((row, col)      )

					__a					:						Dict      =					0
					count += depth_first_search(__A				,       row + 1				,       __A				,       __A      )
					count += depth_first_search(__A				,       row - 1				,       __A				,       __A      )
					count += depth_first_search(__A				,       __A				,       col + 1				,       __A      )
					count += depth_first_search(__A				,       __A				,       col - 1				,       __A      )

					visit.remove((row, col)      )
					return count


if __name__ == "__main__":
			import doctest

			doctest.testmod()





