




import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict







@pytest.mark.parametrize(
    """split_dict""",[
        SplitDict(),
        SplitDict({"""train""": SplitInfo(name="""train""",num_bytes=1337,num_examples=42,dataset_name="""my_dataset"""  )}  ),
        SplitDict({"""train""": SplitInfo(name="""train""",num_bytes=1337,num_examples=42  )}  ),
        SplitDict({"""train""": SplitInfo()}  ),
    ],)
def        lowerCAmelCase_			(  snake_case_  ):
      _A							:  List[Any]    =		split_dict._to_yaml_list()
      assert len(snake_case_  ) == len(snake_case_  )
      _A							:  Tuple    =		SplitDict._from_yaml_list(snake_case_  )
      for split_name, split_info in split_dict.items():
            # dataset_name field is deprecated, and is therefore not part of the YAML dump
            _A							:  Optional[Any]    =		None
            # the split name of split_dict takes over the name of the split info object
            _A							:  List[Any]    =		split_name
      assert split_dict == reloaded







@pytest.mark.parametrize(
    """split_info""",[SplitInfo(), SplitInfo(dataset_name=snake_case_  ), SplitInfo(dataset_name="""my_dataset"""  )]  )
def        lowerCAmelCase_			(  snake_case_  ):
      # For backward compatibility, we need asdict(split_dict) to return split info dictrionaries with the "dataset_name"
      # field even if it's deprecated. This way old versionso of `datasets` can still reload dataset_infos.json files
      _A							:  List[str]    =		asdict(SplitDict({"""train""": split_info}  )  )
      assert "dataset_name" in split_dict_asdict["train"]
      assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name







from typing import TYPE_CHECKING

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


_snake_case            = {
    "configuration_efficientformer": [
        "EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "EfficientFormerConfig",
    ]
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _snake_case            = ["EfficientFormerImageProcessor"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _snake_case            = [
      "EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "EfficientFormerForImageClassification",
      "EfficientFormerForImageClassificationWithTeacher",
      "EfficientFormerModel",
      "EfficientFormerPreTrainedModel",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _snake_case            = [
      "TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFEfficientFormerForImageClassification",
      "TFEfficientFormerForImageClassificationWithTeacher",
      "TFEfficientFormerModel",
      "TFEfficientFormerPreTrainedModel",
  ]

if TYPE_CHECKING:
  from .configuration_efficientformer import EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, EfficientFormerConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .image_processing_efficientformer import EfficientFormerImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_efficientformer import (
        EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        EfficientFormerForImageClassification,
        EfficientFormerForImageClassificationWithTeacher,
        EfficientFormerModel,
        EfficientFormerPreTrainedModel,
    )
  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_efficientformer import (
        TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFEfficientFormerForImageClassification,
        TFEfficientFormerForImageClassificationWithTeacher,
        TFEfficientFormerModel,
        TFEfficientFormerPreTrainedModel,
    )

else:
  import sys

  _snake_case            = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

