


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





							"""simple docstring"""







							_UpperCAmelCase      =						None







class 	__lowercase    (datasets.ArrowBasedBuilder  ):





							"""simple docstring"""







							_UpperCAmelCase      =						PandasConfig






							def 					UpperCamelCase__     (      self       ):





										"""simple docstring"""




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






							def 					UpperCamelCase__     (      self			,						lowerCAmelCase__       ):





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






							def 					UpperCamelCase__     (      self			,						lowerCAmelCase__       ):





										"""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
													SCREAMING_SNAKE_CASE_		:     List[str]					=					table_cast(lowerCAmelCase__			,						self.config.features.arrow_schema       )
										return pa_table






							def 					UpperCamelCase__     (      self			,						lowerCAmelCase__       ):





										"""simple docstring"""




										for i, file in enumerate(itertools.chain.from_iterable(lowerCAmelCase__       )       ):
													with open(lowerCAmelCase__			,						'rb'       ) as f:
																SCREAMING_SNAKE_CASE_		:     Union[str, Any]					=					pa.Table.from_pandas(pd.read_pickle(lowerCAmelCase__       )       )
																yield i, self._cast_table(lowerCAmelCase__       )









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


_lowerCAmelCase:						Optional[Any]   				=       {
    'configuration_swiftformer': [
        'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'SwiftFormerConfig',
        'SwiftFormerOnnxConfig',
    ]
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowerCAmelCase:						List[str]   				=       [
	    'SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'SwiftFormerForImageClassification',
	    'SwiftFormerModel',
	    'SwiftFormerPreTrainedModel',
	]

if TYPE_CHECKING:
	from .configuration_swiftformer import (
	    SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    SwiftFormerConfig,
	    SwiftFormerOnnxConfig,
	)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_swiftformer import (
		    SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    SwiftFormerForImageClassification,
		    SwiftFormerModel,
		    SwiftFormerPreTrainedModel,
		)

else:
	import sys

	_lowerCAmelCase:						List[Any]   				=       _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

