






"""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


_SCREAMING_SNAKE_CASE   :							Tuple          =		logging.get_logger(__name__)


_SCREAMING_SNAKE_CASE   :							Tuple          =		TypeVar('''DatasetType''', Dataset, IterableDataset)







def 	lowerCamelCase__			(				_lowerCamelCase			:						List[DatasetType]						,							_lowerCamelCase			:						Optional[List[float]] = None						,							_lowerCamelCase			:						Optional[int] = None						,							_lowerCamelCase			:						Optional[DatasetInfo] = None						,							_lowerCamelCase			:						Optional[NamedSplit] = None						,							_lowerCamelCase			:						Literal["first_exhausted", "all_exhausted"] = "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(_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:
      lowerCamelCase_	,      lowerCamelCase_       	=		(
          (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 	lowerCamelCase__			(				_lowerCamelCase			:						List[DatasetType]						,							_lowerCamelCase			:						Optional[DatasetInfo] = None						,							_lowerCamelCase			:						Optional[NamedSplit] = None						,							_lowerCamelCase			:						int = 0						,							) ->							DatasetType:

  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:
      lowerCamelCase_	,      lowerCamelCase_       	=		(
          (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					)












"""simple docstring"""





def 	lowerCamelCase__			(				_lowerCamelCase			:						float						,							_lowerCamelCase			:						float					) ->							float:

  if density <= 0:
    raise ValueError('Impossible fluid density'					)
  if bulk_modulus <= 0:
    raise ValueError('Impossible bulk modulus'					)

  return (bulk_modulus / density) ** 0.5


if __name__ == "__main__":
  import doctest

  doctest.testmod()




