





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


_SCREAMING_SNAKE_CASE      	=		logging.get_logger(__name__)


_SCREAMING_SNAKE_CASE      	=		TypeVar("""DatasetType""", Dataset, IterableDataset)


def 							SCREAMING_SNAKE_CASE__						(    __a   , __a = None   , __a = None   , __a = None   , __a = None   , __a = "first_exhausted"   , ):
	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:
			snake_case_						,snake_case_		:			Dict											=	(
			    (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 							SCREAMING_SNAKE_CASE__						(    __a   , __a = None   , __a = None   , __a = 0   , ):






	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:
			snake_case_						,snake_case_		:			Optional[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   )








from ....utils import logging


_SCREAMING_SNAKE_CASE      	=		logging.get_logger(__name__)
class SCREAMING_SNAKE_CASE_						(					snake_case_					):






						def __init__(      self      :      str		,   _A      :      List[Any]		,   _A      :      List[Any]=None		,   _A      :      str=2048	)							->    Optional[int]:







							"""simple docstring"""


							snake_case_		:			Tuple											=	config.__dict__
							snake_case_		:			List[str]											=	modal_hidden_size
							if num_labels:
								snake_case_		:			int											=	num_labels

