

'''simple docstring'''





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

		'''simple docstring'''






		SCREAMING_SNAKE_CASE_           =					None


class  UpperCAmelCase (							datasets.ArrowBasedBuilder    ):

		'''simple docstring'''






		SCREAMING_SNAKE_CASE_           =					PandasConfig
		def 			UpperCamelCase(					self		)  ->     str:






							'''simple docstring'''



							return datasets.DatasetInfo(features=self.config.features		)
		def 			UpperCamelCase(					self   ,			SCREAMING_SNAKE_CASE_		)  ->     Dict:






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






		def 			UpperCamelCase(					self   ,			SCREAMING_SNAKE_CASE_		)  ->     str:






							'''simple docstring'''



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







"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__snake_case       =       {
    """configuration_time_series_transformer""": [
        """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """TimeSeriesTransformerConfig""",
    ],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __snake_case       =       [
      """TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TimeSeriesTransformerForPrediction""",
      """TimeSeriesTransformerModel""",
      """TimeSeriesTransformerPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_time_series_transformer import (
      TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      TimeSeriesTransformerConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_time_series_transformer import (
        TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        TimeSeriesTransformerForPrediction,
        TimeSeriesTransformerModel,
        TimeSeriesTransformerPreTrainedModel,
    )

else:
  import sys

  __snake_case       =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





