






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


UpperCAmelCase_   : List[str]   			= TypeVar("""DatasetType""", Dataset, IterableDataset)



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





def 					_A			(__a    ,				__a = None    ,				__a = None    ,				__a = 0    ,				) ->       DatasetType:
    """simple docstring"""






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










"""simple docstring"""






from . import (
    albert,
    align,
    altclip,
    audio_spectrogram_transformer,
    auto,
    autoformer,
    bark,
    bart,
    barthez,
    bartpho,
    beit,
    bert,
    bert_generation,
    bert_japanese,
    bertweet,
    big_bird,
    bigbird_pegasus,
    biogpt,
    bit,
    blenderbot,
    blenderbot_small,
    blip,
    blip_a,
    bloom,
    bridgetower,
    byta,
    camembert,
    canine,
    chinese_clip,
    clap,
    clip,
    clipseg,
    codegen,
    conditional_detr,
    convbert,
    convnext,
    convnextva,
    cpm,
    cpmant,
    ctrl,
    cvt,
    dataavec,
    deberta,
    deberta_va,
    decision_transformer,
    deformable_detr,
    deit,
    deprecated,
    deta,
    detr,
    dialogpt,
    dinat,
    distilbert,
    dit,
    donut,
    dpr,
    dpt,
    efficientformer,
    efficientnet,
    electra,
    encodec,
    encoder_decoder,
    ernie,
    ernie_m,
    esm,
    falcon,
    flaubert,
    flava,
    fnet,
    focalnet,
    fsmt,
    funnel,
    git,
    glpn,
    gpta,
    gpt_bigcode,
    gpt_neo,
    gpt_neox,
    gpt_neox_japanese,
    gpt_swa,
    gptj,
    gptsan_japanese,
    graphormer,
    groupvit,
    herbert,
    hubert,
    ibert,
    imagegpt,
    informer,
    instructblip,
    jukebox,
    layoutlm,
    layoutlmva,
    layoutlmva,
    layoutxlm,
    led,
    levit,
    lilt,
    llama,
    longformer,
    longta,
    luke,
    lxmert,
    mam_aaa,
    marian,
    markuplm,
    maskaformer,
    maskformer,
    mbart,
    mbartaa,
    mega,
    megatron_bert,
    megatron_gpta,
    mgp_str,
    mluke,
    mobilebert,
    mobilenet_va,
    mobilenet_va,
    mobilevit,
    mobilevitva,
    mpnet,
    mra,
    mta,
    musicgen,
    mvp,
    nat,
    nezha,
    nllb,
    nllb_moe,
    nystromformer,
    oneformer,
    open_llama,
    openai,
    opt,
    owlvit,
    pegasus,
    pegasus_x,
    perceiver,
    phobert,
    pixastruct,
    plbart,
    poolformer,
    prophetnet,
    qdqbert,
    rag,
    realm,
    reformer,
    regnet,
    rembert,
    resnet,
    roberta,
    roberta_prelayernorm,
    roc_bert,
    roformer,
    rwkv,
    sam,
    segformer,
    sew,
    sew_d,
    speech_encoder_decoder,
    speech_to_text,
    speech_to_text_a,
    speechta,
    splinter,
    squeezebert,
    swiftformer,
    swin,
    swinasr,
    swinva,
    switch_transformers,
    ta,
    table_transformer,
    tapas,
    time_series_transformer,
    timesformer,
    timm_backbone,
    transfo_xl,
    trocr,
    tvlt,
    umta,
    unispeech,
    unispeech_sat,
    upernet,
    videomae,
    vilt,
    vision_encoder_decoder,
    vision_text_dual_encoder,
    visual_bert,
    vit,
    vit_hybrid,
    vit_mae,
    vit_msn,
    vivit,
    wavaveca,
    wavaveca_conformer,
    wavaveca_phoneme,
    wavaveca_with_lm,
    wavlm,
    whisper,
    x_clip,
    xglm,
    xlm,
    xlm_prophetnet,
    xlm_roberta,
    xlm_roberta_xl,
    xlnet,
    xmod,
    yolos,
    yoso,
)


