






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


UpperCAmelCase__						:List[str]          =			logging.get_logger(__name__)


UpperCAmelCase__						:Optional[Any]          =			TypeVar("""DatasetType""", Dataset, IterableDataset)
def     __lowercase  (_lowercase,						_lowercase = None,						_lowercase = None,						_lowercase = None,						_lowercase = None,						_lowercase = "first_exhausted",						)   ->     DatasetType:


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


     """simple docstring"""

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











'''simple docstring'''

from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

UpperCAmelCase__						:List[str]          =			typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
UpperCAmelCase__						:Optional[int]          =			typing.Union[np.floataa, int, float]  # noqa: UP007
def     __lowercase  (_lowercase,						_lowercase     )   ->     VectorOut:


     """simple docstring"""
     return np.sqrt(np.sum((np.asarray(_lowercase     ) - np.asarray(_lowercase     )) ** 2     )     )
def     __lowercase  (_lowercase,						_lowercase     )   ->     VectorOut:


     """simple docstring"""
     return sum((va - va) ** 2 for va, va in zip(_lowercase,						_lowercase     )     ) ** (1 / 2)


if __name__ == "__main__":
   def     __lowercase  ()   ->     None:


        """simple docstring"""
        from timeit import timeit

        print("""Without Numpy"""     )
        print(
            timeit(
                """euclidean_distance_no_np([1, 2, 3], [4, 5, 6])""",						number=10_000,						globals=globals(),						)     )
        print("""With Numpy"""     )
        print(
            timeit(
                """euclidean_distance([1, 2, 3], [4, 5, 6])""",						number=10_000,						globals=globals(),						)     )
   benchmark()



