






from typing import List, Optional, TypeVar

from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interleave_iterable_datasets
from .splits import NamedSplit
from .utils import logging
from .utils.py_utils import Literal


A_		:		Any		     =			logging.get_logger(__name__)


A_		:		Optional[Any]		     =			TypeVar('DatasetType', Dataset, IterableDataset)

def   snake_case (UpperCAmelCase__     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = "first_exhausted"     ,   )	->    DatasetType:
		from .arrow_dataset import Dataset
		from .iterable_dataset import IterableDataset

		if not datasets:
				raise ValueError('Unable to interleave an empty list of datasets.'  )
		for i, dataset in enumerate(UpperCAmelCase__  ):
				if not isinstance(UpperCAmelCase__     ,   (Dataset, IterableDataset)  ):
						if isinstance(UpperCAmelCase__     ,   (DatasetDict, IterableDatasetDict)  ):
								if not dataset:
										raise ValueError(
										    F'''Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} '''
										    'is an empty dataset dictionary.'  )
								raise ValueError(
								    F'''Dataset at position {i} has at least one split: {list(UpperCAmelCase__  )}\n'''
								    F'''Please pick one to interleave with the other datasets, for example: dataset[\'{next(iter(UpperCAmelCase__  )  )}\']'''  )
						raise ValueError(
						    F'''Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(UpperCAmelCase__  ).__name__}.'''  )
				if i == 0:
						UpperCamelCase_: Any   				=    (
						    (Dataset, IterableDataset) if isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ) else (IterableDataset, Dataset)
						)
				elif not isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ):
						raise ValueError(
						    F'''Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects.'''  )
		if stopping_strategy not in ["first_exhausted", "all_exhausted"]:
				raise ValueError(F'''{stopping_strategy} is not supported. Please enter a valid stopping_strategy.'''  )
		if dataset_type is Dataset:
				return _interleave_map_style_datasets(
				    UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__     ,   info=UpperCAmelCase__     ,   split=UpperCAmelCase__     ,   stopping_strategy=UpperCAmelCase__  )
		else:
				return _interleave_iterable_datasets(
				    UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__     ,   info=UpperCAmelCase__     ,   split=UpperCAmelCase__     ,   stopping_strategy=UpperCAmelCase__  )

def   snake_case (UpperCAmelCase__     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = None     ,   UpperCAmelCase__ = 0     ,   )	->    DatasetType:

		if not dsets:
				raise ValueError('Unable to concatenate an empty list of datasets.'  )
		for i, dataset in enumerate(UpperCAmelCase__  ):
				if not isinstance(UpperCAmelCase__     ,   (Dataset, IterableDataset)  ):
						if isinstance(UpperCAmelCase__     ,   (DatasetDict, IterableDatasetDict)  ):
								if not dataset:
										raise ValueError(
										    F'''Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} '''
										    'is an empty dataset dictionary.'  )
								raise ValueError(
								    F'''Dataset at position {i} has at least one split: {list(UpperCAmelCase__  )}\n'''
								    F'''Please pick one to interleave with the other datasets, for example: dataset[\'{next(iter(UpperCAmelCase__  )  )}\']'''  )
						raise ValueError(
						    F'''Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(UpperCAmelCase__  ).__name__}.'''  )
				if i == 0:
						UpperCamelCase_: Union[str, Any]   				=    (
						    (Dataset, IterableDataset) if isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ) else (IterableDataset, Dataset)
						)
				elif not isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ):
						raise ValueError(
						    F'''Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects.'''  )
		if dataset_type is Dataset:
				return _concatenate_map_style_datasets(UpperCAmelCase__     ,   info=UpperCAmelCase__     ,   split=UpperCAmelCase__     ,   axis=UpperCAmelCase__  )
		else:
				return _concatenate_iterable_datasets(UpperCAmelCase__     ,   info=UpperCAmelCase__     ,   split=UpperCAmelCase__     ,   axis=UpperCAmelCase__  )







def   snake_case (UpperCAmelCase__  )	->    int:
  assert isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ), F'''The input value of [n={number}] is not an integer'''

  if number == 1:
    return 2
  elif number < 1:
    UpperCamelCase_: List[Any]   				=    F'''The input value of [n={number}] has to be > 0'''
    raise ValueError(UpperCAmelCase__  )
  else:
    UpperCamelCase_: str   				=    sylvester(number - 1  )
    UpperCamelCase_: str   				=    num - 1
    UpperCamelCase_: Any   				=    num
    return lower * upper + 1


if __name__ == "__main__":
   print(F'''The 8th number in Sylvester\'s sequence: {sylvester(8)}''')