



'''simple docstring'''



from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase	 =       logging.get_logger(__name__)

lowerCamelCase	 =       {
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}





class _UpperCamelCase		(     a__		):





				'''simple docstring'''





				lowerCAmelCase__					    =    """efficientnet"""

				def __init__(							self  :  List[str]  ,       _lowerCAmelCase  :  List[Any] = 3  ,       _lowerCAmelCase  :  Dict = 6_0_0  ,       _lowerCAmelCase  :  List[Any] = 2.0  ,       _lowerCAmelCase  :  Tuple = 3.1  ,       _lowerCAmelCase  :  Tuple = 8  ,       _lowerCAmelCase  :  Tuple = [3, 3, 5, 3, 5, 5, 3]  ,       _lowerCAmelCase  :  int = [3_2, 1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2]  ,       _lowerCAmelCase  :  List[Any] = [1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2, 3_2_0]  ,       _lowerCAmelCase  :  List[str] = []  ,       _lowerCAmelCase  :  Union[str, Any] = [1, 2, 2, 2, 1, 2, 1]  ,       _lowerCAmelCase  :  Optional[int] = [1, 2, 2, 3, 3, 4, 1]  ,       _lowerCAmelCase  :  int = [1, 6, 6, 6, 6, 6, 6]  ,       _lowerCAmelCase  :  Any = 0.25  ,       _lowerCAmelCase  :  Dict = "swish"  ,       _lowerCAmelCase  :  Tuple = 2_5_6_0  ,       _lowerCAmelCase  :  Optional[int] = "mean"  ,       _lowerCAmelCase  :  int = 0.02  ,       _lowerCAmelCase  :  Optional[Any] = 0.001  ,       _lowerCAmelCase  :  Optional[Any] = 0.99  ,       _lowerCAmelCase  :  str = 0.5  ,       _lowerCAmelCase  :  Any = 0.2  ,       **_lowerCAmelCase  :  List[str]  ,       ):







											'''simple docstring'''

											super().__init__(**lowerCAmelCase__)

											__lowercase       	=num_channels
											__lowercase       	=image_size
											__lowercase       	=width_coefficient
											__lowercase       	=depth_coefficient
											__lowercase       	=depth_divisor
											__lowercase       	=kernel_sizes
											__lowercase       	=in_channels
											__lowercase       	=out_channels
											__lowercase       	=depthwise_padding
											__lowercase       	=strides
											__lowercase       	=num_block_repeats
											__lowercase       	=expand_ratios
											__lowercase       	=squeeze_expansion_ratio
											__lowercase       	=hidden_act
											__lowercase       	=hidden_dim
											__lowercase       	=pooling_type
											__lowercase       	=initializer_range
											__lowercase       	=batch_norm_eps
											__lowercase       	=batch_norm_momentum
											__lowercase       	=dropout_rate
											__lowercase       	=drop_connect_rate
											__lowercase       	=sum(lowerCAmelCase__) * 4





class _UpperCamelCase		(     a__		):





				'''simple docstring'''





				lowerCAmelCase__					    =    version.parse("""1.11"""		)

				@property
				def 				__lowerCamelCase     (							self  :  int):







											'''simple docstring'''

											return OrderedDict(
											    [
											        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
											    ])

				@property
				def 				__lowerCamelCase     (							self  :  List[Any]):







											'''simple docstring'''

											return 1e-5








'''simple docstring'''



import os

import pytest
import yaml

from datasets.features.features import Features, Value
from datasets.info import DatasetInfo, DatasetInfosDict



@pytest.mark.parametrize(
    'files'  ,   [
        ['full:README.md', 'dataset_infos.json'],
        ['empty:README.md', 'dataset_infos.json'],
        ['dataset_infos.json'],
        ['full:README.md'],
    ]  ,   )
def   _A       (   _lowerCAmelCase  ,   _lowerCAmelCase					):



							"""simple docstring"""



							__lowercase       	=tmp_path_factory.mktemp('dset_infos_dir'					)
							if "full:README.md" in files:
														with open(dataset_infos_dir / 'README.md'  ,   'w'					) as f:
																					f.write('---\ndataset_info:\n  dataset_size: 42\n---'					)
							if "empty:README.md" in files:
														with open(dataset_infos_dir / 'README.md'  ,   'w'					) as f:
																					f.write(''					)
    # we want to support dataset_infos.json for backward compatibility
							if "dataset_infos.json" in files:
														with open(dataset_infos_dir / 'dataset_infos.json'  ,   'w'					) as f:
																					f.write('{"default": {"dataset_size": 42}}'					)
							__lowercase       	=DatasetInfosDict.from_directory(_lowerCAmelCase					)
							assert dataset_infos
							assert dataset_infos["default"].dataset_size == 42



@pytest.mark.parametrize(
    'dataset_info'  ,   [
        DatasetInfo(),
        DatasetInfo(
            description='foo'  ,   features=Features({'a': Value('int32'					)}					)  ,   builder_name='builder'  ,   config_name='config'  ,   version='1.0.0'  ,   splits=[{'name': 'train'}]  ,   download_size=42  ,   ),
    ]  ,   )
def   _A       (   _lowerCAmelCase  ,   _lowerCAmelCase					):



							"""simple docstring"""



							__lowercase       	=str(_lowerCAmelCase					)
							dataset_info.write_to_directory(_lowerCAmelCase					)
							__lowercase       	=DatasetInfo.from_directory(_lowerCAmelCase					)
							assert dataset_info == reloaded
							assert os.path.exists(os.path.join(_lowerCAmelCase  ,   'dataset_info.json'					)					)



def   _A       (   ):



							"""simple docstring"""



							__lowercase       	=DatasetInfo(
							    description='foo'  ,   citation='bar'  ,   homepage='https://foo.bar'  ,   license='CC0'  ,   features=Features({'a': Value('int32'					)}					)  ,   post_processed={}  ,   supervised_keys=()  ,   task_templates=[]  ,   builder_name='builder'  ,   config_name='config'  ,   version='1.0.0'  ,   splits=[{'name': 'train', 'num_examples': 42}]  ,   download_checksums={}  ,   download_size=1_337  ,   post_processing_size=442  ,   dataset_size=1_234  ,   size_in_bytes=1_337 + 442 + 1_234  ,   )
							__lowercase       	=dataset_info._to_yaml_dict()
							assert sorted(_lowerCAmelCase					) == sorted(DatasetInfo._INCLUDED_INFO_IN_YAML					)
							for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
														assert key in dataset_info_yaml_dict
														assert isinstance(dataset_info_yaml_dict[key]  ,   (list, dict, int, str)					)
							__lowercase       	=yaml.safe_dump(_lowerCAmelCase					)
							__lowercase       	=yaml.safe_load(_lowerCAmelCase					)
							assert dataset_info_yaml_dict == reloaded



def   _A       (   ):



							"""simple docstring"""



							__lowercase       	=DatasetInfo()
							__lowercase       	=dataset_info._to_yaml_dict()
							assert dataset_info_yaml_dict == {}



@pytest.mark.parametrize(
    'dataset_infos_dict'  ,   [
        DatasetInfosDict(),
        DatasetInfosDict({'default': DatasetInfo()}					),
        DatasetInfosDict({'my_config_name': DatasetInfo()}					),
        DatasetInfosDict(
            {
                'default': DatasetInfo(
                    description='foo'  ,   features=Features({'a': Value('int32'					)}					)  ,   builder_name='builder'  ,   config_name='config'  ,   version='1.0.0'  ,   splits=[{'name': 'train'}]  ,   download_size=42  ,   )
            }					),
        DatasetInfosDict(
            {
                'v1': DatasetInfo(dataset_size=42					),
                'v2': DatasetInfo(dataset_size=1_337					),
            }					),
    ]  ,   )
def   _A       (   _lowerCAmelCase  ,   _lowerCAmelCase					):



							"""simple docstring"""



							__lowercase       	=str(_lowerCAmelCase					)
							dataset_infos_dict.write_to_directory(_lowerCAmelCase					)
							__lowercase       	=DatasetInfosDict.from_directory(_lowerCAmelCase					)

							# the config_name of the dataset_infos_dict take over the attribute
							for config_name, dataset_info in dataset_infos_dict.items():
														__lowercase       	=config_name
														# the yaml representation doesn't include fields like description or citation
														# so we just test that we can recover what we can from the yaml
														__lowercase       	=DatasetInfo._from_yaml_dict(dataset_info._to_yaml_dict()					)
							assert dataset_infos_dict == reloaded

							if dataset_infos_dict:
														assert os.path.exists(os.path.join(_lowerCAmelCase  ,   'README.md'					)					)



