



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


__lowerCAmelCase       :					str      					=					logging.get_logger(__name__)


__lowerCAmelCase       :					Union[str, Any]      					=					TypeVar('''DatasetType''', Dataset, IterableDataset)
def 	__lowerCAmelCase						(		__UpperCamelCase      :			List[DatasetType]					, __UpperCamelCase      :			Optional[List[float]] = None					, __UpperCamelCase      :			Optional[int] = None					, __UpperCamelCase      :			Optional[DatasetInfo] = None					, __UpperCamelCase      :			Optional[NamedSplit] = None					, __UpperCamelCase      :			Literal["first_exhausted", "all_exhausted"] = "first_exhausted"					, ):


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






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


      '''simple docstring'''






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






"""simple docstring"""





from .data_collator import (
    DataCollatorForLanguageModeling,
    DataCollatorForPermutationLanguageModeling,
    DataCollatorForSeqaSeq,
    DataCollatorForSOP,
    DataCollatorForTokenClassification,
    DataCollatorForWholeWordMask,
    DataCollatorWithPadding,
    DefaultDataCollator,
    default_data_collator,
)
from .metrics import glue_compute_metrics, xnli_compute_metrics
from .processors import (
    DataProcessor,
    InputExample,
    InputFeatures,
    SingleSentenceClassificationProcessor,
    SquadExample,
    SquadFeatures,
    SquadVaProcessor,
    SquadVaProcessor,
    glue_convert_examples_to_features,
    glue_output_modes,
    glue_processors,
    glue_tasks_num_labels,
    squad_convert_examples_to_features,
    xnli_output_modes,
    xnli_processors,
    xnli_tasks_num_labels,
)

