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__           =							logging.get_logger(__name__)


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





def  _lowerCamelCase					(   a_				: List[DatasetType]						,			a_				: Optional[List[float]] = None						,			a_				: Optional[int] = None						,			a_				: Optional[DatasetInfo] = None						,			a_				: Optional[NamedSplit] = None						,			a_				: Literal["first_exhausted", "all_exhausted"] = "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(a_):
						if not isinstance(a_						,			(Dataset, IterableDataset)):
									if isinstance(a_						,			(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(a_)}\n"
												    F"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(a_))}']")
									raise ValueError(
									    F"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(a_).__name__}.")
						if i == 0:
									lowerCamelCase  ,    lowerCamelCase						:Tuple						  =     (
									    (Dataset, IterableDataset) if isinstance(a_						,			a_) else (IterableDataset, Dataset)
									)
						elif not isinstance(a_						,			a_):
									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(
						    a_						,			a_						,			a_						,			info=a_						,			split=a_						,			stopping_strategy=a_)
			else:
						return _interleave_iterable_datasets(
						    a_						,			a_						,			a_						,			info=a_						,			split=a_						,			stopping_strategy=a_)





def  _lowerCamelCase					(   a_				: List[DatasetType]						,			a_				: Optional[DatasetInfo] = None						,			a_				: Optional[NamedSplit] = None						,			a_				: int = 0						,			):

			if not dsets:
						raise ValueError('''Unable to concatenate an empty list of datasets.''')
			for i, dataset in enumerate(a_):
						if not isinstance(a_						,			(Dataset, IterableDataset)):
									if isinstance(a_						,			(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(a_)}\n"
												    F"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(a_))}']")
									raise ValueError(
									    F"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(a_).__name__}.")
						if i == 0:
									lowerCamelCase  ,    lowerCamelCase						:Dict						  =     (
									    (Dataset, IterableDataset) if isinstance(a_						,			a_) else (IterableDataset, Dataset)
									)
						elif not isinstance(a_						,			a_):
									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(a_						,			info=a_						,			split=a_						,			axis=a_)
			else:
						return _concatenate_iterable_datasets(a_						,			info=a_						,			split=a_						,			axis=a_)




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


A__           =							{
    """configuration_nllb_moe""": [
        """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """NllbMoeConfig""",
    ]
}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			A__           =							[
			    """NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """NllbMoeForConditionalGeneration""",
			    """NllbMoeModel""",
			    """NllbMoePreTrainedModel""",
			    """NllbMoeTop2Router""",
			    """NllbMoeSparseMLP""",
			]


if TYPE_CHECKING:
			from .configuration_nllb_moe import (
			    NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP,
			    NllbMoeConfig,
			)

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_nllb_moe import (
						    NLLB_MOE_PRETRAINED_MODEL_ARCHIVE_LIST,
						    NllbMoeForConditionalGeneration,
						    NllbMoeModel,
						    NllbMoePreTrainedModel,
						    NllbMoeSparseMLP,
						    NllbMoeTopaRouter,
						)


else:
			import sys

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



