

"""simple docstring"""




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


_lowercase   :	str												=						logging.get_logger(__name__)


_lowercase   :	List[Any]												=						TypeVar('DatasetType', Dataset, IterableDataset)





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





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

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



'''simple docstring'''



def       snake_case   (	snake_case      : int					,		snake_case      : int					,		snake_case      : int			) ->  int:


    """simple docstring"""


    if exponent == 1:
        return base
    if exponent % 2 == 0:
        lowerCAmelCase 						=							_modexpt(snake_case					,		exponent // 2					,		snake_case			) % modulo_value
        return (x * x) % modulo_value
    else:
        return (base * _modexpt(snake_case					,		exponent - 1					,		snake_case			)) % modulo_value


def       snake_case   (	snake_case      : int = 1777					,		snake_case      : int = 1855					,		snake_case      : int = 8			) ->  int:


    """simple docstring"""


    lowerCAmelCase 						=							base
    for _ in range(1					,		snake_case			):
        lowerCAmelCase 						=							_modexpt(snake_case					,		snake_case					,		10**digits			)

    return result


if __name__ == "__main__":
     print(F"""{solution() = }""")





