


"""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"""





	snake_case__    :  Optional[datasets.Features]    =      None




class 			UpperCamelCase_     (			datasets.ArrowBasedBuilder):

	"""simple docstring"""





	snake_case__    :  str    =      PandasConfig




	def   UpperCAmelCase_				(			self      :    Union[str, Any]       )	->     Dict:
						return datasets.DatasetInfo(features=self.config.features       )




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




	def   UpperCAmelCase_				(			self      :    Dict      ,      UpperCAmelCase__      :    pa.Table       )	->     pa.Table:

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




	def   UpperCAmelCase_				(			self      :    Dict      ,      UpperCAmelCase__      :    List[str]       )	->     Tuple:

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




"""simple docstring"""







from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
		if not (is_transformers_available() and is_torch_available()):
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		from ...utils.dummy_torch_and_transformers_objects import KandinskyPipeline, KandinskyPriorPipeline
else:
		from .pipeline_kandinsky import KandinskyPipeline
		from .pipeline_kandinsky_imgaimg import KandinskyImgaImgPipeline
		from .pipeline_kandinsky_inpaint import KandinskyInpaintPipeline
		from .pipeline_kandinsky_prior import KandinskyPriorPipeline, KandinskyPriorPipelineOutput
		from .text_encoder import MultilingualCLIP
