




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


lowerCamelCase	:	str				=   logging.get_logger(__name__)


lowerCamelCase	:	Optional[int]				=   TypeVar('DatasetType', Dataset, IterableDataset)




def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase = None						,lowercase = None						,lowercase = None						,lowercase = None						,lowercase = "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(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:
         snake_case     , snake_case				:    Optional[int]           =	(
             (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 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase = None						,lowercase = None						,lowercase = 0						,)  ->       DatasetType:

   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:
         snake_case     , snake_case				:    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					)











def 						SCREAMING_SNAKE_CASE__ (   lowercase						,lowercase					)  ->       int:
   return int((input_a, input_a).count(1					) != 0					)




def 						SCREAMING_SNAKE_CASE__ (   )  ->       None:
   assert or_gate(0						,0					) == 0
   assert or_gate(0						,1					) == 1
   assert or_gate(1						,0					) == 1
   assert or_gate(1						,1					) == 1


if __name__ == "__main__":
       print(or_gate(0, 1))
       print(or_gate(1, 0))
       print(or_gate(0, 0))
       print(or_gate(1, 1))





