



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


__snake_case		:Tuple   	=  logging.get_logger(__name__)


__snake_case		:str   	=  TypeVar('''DatasetType''', Dataset, IterableDataset)





def   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = "first_exhausted"     ,				):
    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:
            __a ,     __a		 =       (
                (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   __snake_case			(    _UpperCAmelCase     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = None     ,				_UpperCAmelCase = 0     ,				):

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










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__snake_case		:Union[str, Any]   	=  {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTConfig''', '''ViTOnnxConfig''']}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __snake_case		:List[str]   	=  ['''ViTFeatureExtractor''']
 __snake_case		:Optional[Any]   	=  ['''ViTImageProcessor''']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __snake_case		:str   	=  [
     '''VIT_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''ViTForImageClassification''',
     '''ViTForMaskedImageModeling''',
     '''ViTModel''',
     '''ViTPreTrainedModel''',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __snake_case		:Tuple   	=  [
     '''TFViTForImageClassification''',
     '''TFViTModel''',
     '''TFViTPreTrainedModel''',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __snake_case		:Tuple   	=  [
     '''FlaxViTForImageClassification''',
     '''FlaxViTModel''',
     '''FlaxViTPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig, ViTOnnxConfig

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_vit import ViTFeatureExtractor
  from .image_processing_vit import ViTImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_vit import (
      VIT_PRETRAINED_MODEL_ARCHIVE_LIST,
      ViTForImageClassification,
      ViTForMaskedImageModeling,
      ViTModel,
      ViTPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_vit import TFViTForImageClassification, TFViTModel, TFViTPreTrainedModel

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel, FlaxViTPreTrainedModel


else:
 import sys

 __snake_case		:Optional[int]   	=  _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





