




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


_UpperCAmelCase	:						Optional[Any]			=     logging.get_logger(__name__)


_UpperCAmelCase	:						Any			=     TypeVar("DatasetType", Dataset, IterableDataset)



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







def       UpperCAmelCase__  (     lowerCamelCase,			lowerCamelCase = None,			lowerCamelCase = None,			lowerCamelCase = 0,			):

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









def       UpperCAmelCase__  (     lowerCamelCase   ):
  if divisor % 5 == 0 or divisor % 2 == 0:
    return 0
  lowercase    :str      	=						1
  lowercase    :Tuple      	=						1
  while repunit:
    lowercase    :Dict      	=						(10 * repunit + 1) % divisor
    repunit_index += 1
  return repunit_index



def       UpperCAmelCase__  (     lowerCamelCase = 1000000   ):
  lowercase    :List[Any]      	=						limit - 1
  if divisor % 2 == 0:
    divisor += 1
  while least_divisible_repunit(lowerCamelCase   ) <= limit:
    divisor += 2
  return divisor


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



