


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            =				None




class 	lowerCamelCase_       (				datasets.ArrowBasedBuilder				):



					'''simple docstring'''







					__UpperCAmelCase            =				PandasConfig






					def A      (				self						)   ->			List[str]:







								'''simple docstring'''

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






					def A      (				self ,       snake_case_						)   ->			Any:







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






					def A      (				self ,       snake_case_						)   ->			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
											__lowercase 					=   table_cast(snake_case_ ,       self.config.features.arrow_schema						)
								return pa_table






					def A      (				self ,       snake_case_						)   ->			int:







								'''simple docstring'''

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






from typing import List

from ...configuration_utils import PretrainedConfig
from ...utils import logging


a : Any		=				logging.get_logger(__name__)

a : int		=				{
    '''snap-research/efficientformer-l1-300''': (
        '''https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/config.json'''
    ),
}
class 	lowerCamelCase_       (				lowerCAmelCase__				):



					'''simple docstring'''







					__UpperCAmelCase            =				"efficientformer"






					def __init__(				self ,       snake_case_ = [3, 2, 6, 4] ,       snake_case_ = [4_8, 9_6, 2_2_4, 4_4_8] ,       snake_case_ = [True, True, True, True] ,       snake_case_ = 4_4_8 ,       snake_case_ = 3_2 ,       snake_case_ = 4 ,       snake_case_ = 7 ,       snake_case_ = 5 ,       snake_case_ = 8 ,       snake_case_ = 4 ,       snake_case_ = 0.0 ,       snake_case_ = 1_6 ,       snake_case_ = 3 ,       snake_case_ = 3 ,       snake_case_ = 3 ,       snake_case_ = 2 ,       snake_case_ = 1 ,       snake_case_ = 0.0 ,       snake_case_ = 1 ,       snake_case_ = True ,       snake_case_ = True ,       snake_case_ = 1e-5 ,       snake_case_ = "gelu" ,       snake_case_ = 0.0_2 ,       snake_case_ = 1e-1_2 ,       snake_case_ = 2_2_4 ,       snake_case_ = 1e-0_5 ,       **snake_case_ ,       )   ->			None:







								'''simple docstring'''

								super().__init__(**snake_case_						)

								__lowercase 					=   hidden_act
								__lowercase 					=   hidden_dropout_prob
								__lowercase 					=   hidden_sizes
								__lowercase 					=   num_hidden_layers
								__lowercase 					=   num_attention_heads
								__lowercase 					=   initializer_range
								__lowercase 					=   layer_norm_eps
								__lowercase 					=   patch_size
								__lowercase 					=   num_channels
								__lowercase 					=   depths
								__lowercase 					=   mlp_expansion_ratio
								__lowercase 					=   downsamples
								__lowercase 					=   dim
								__lowercase 					=   key_dim
								__lowercase 					=   attention_ratio
								__lowercase 					=   resolution
								__lowercase 					=   pool_size
								__lowercase 					=   downsample_patch_size
								__lowercase 					=   downsample_stride
								__lowercase 					=   downsample_pad
								__lowercase 					=   drop_path_rate
								__lowercase 					=   num_metaad_blocks
								__lowercase 					=   distillation
								__lowercase 					=   use_layer_scale
								__lowercase 					=   layer_scale_init_value
								__lowercase 					=   image_size
								__lowercase 					=   batch_norm_eps


