




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     :		Optional[int]								=       logging.get_logger(__name__)


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







def SCREAMING_SNAKE_CASE    (	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:
            A__			,							A__							=   (
                (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:



    """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:
            A__			,							A__							=   (
                (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_						)








from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowerCamelCase     :		str								=       {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase     :		Dict								=       [
      """FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """FocalNetForImageClassification""",
      """FocalNetForMaskedImageModeling""",
      """FocalNetBackbone""",
      """FocalNetModel""",
      """FocalNetPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_focalnet import FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FocalNetConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_focalnet import (
        FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        FocalNetBackbone,
        FocalNetForImageClassification,
        FocalNetForMaskedImageModeling,
        FocalNetModel,
        FocalNetPreTrainedModel,
    )

else:
  import sys

  _lowerCamelCase     :		Tuple								=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


