
"""simple docstring"""
from importlib import import_module

from .logging import get_logger


SCREAMING_SNAKE_CASE_					     =	get_logger(__name__)
class       lowerCAmelCase_		:



							'''simple docstring'''





							def __init__( self    ,				snake_case_    ,				snake_case_=None				)       ->  List[str]:
													__lowerCAmelCase     =  attrs or []
													if module is not None:
																			for key in module.__dict__:
																									if key in attrs or not key.startswith("""__"""				):
																															setattr(self    ,				snake_case_    ,				getattr(snake_case_    ,				snake_case_				)				)
													__lowerCAmelCase     =  module._original_module if isinstance(snake_case_    ,				_PatchedModuleObj				) else module
class       lowerCAmelCase_		:



							'''simple docstring'''





							_snake_case						      =		[]




							def __init__( self    ,				snake_case_    ,				snake_case_    ,				snake_case_    ,				snake_case_=None				)       ->  Union[str, Any]:
													__lowerCAmelCase     =  obj
													__lowerCAmelCase     =  target
													__lowerCAmelCase     =  new
													__lowerCAmelCase     =  target.split("""."""				)[0]
													__lowerCAmelCase     =  {}
													__lowerCAmelCase     =  attrs or []




							def __enter__( self				)       ->  Any:
													*__lowerCAmelCase   ,     __lowerCAmelCase     =  self.target.split("""."""				)

													# Patch modules:
													# it's used to patch attributes of submodules like "os.path.join";
													# in this case we need to patch "os" and "os.path"

													for i in range(len(snake_case_				)				):
																			try:
																									__lowerCAmelCase     =  import_module(""".""".join(submodules[: i + 1]				)				)
																			except ModuleNotFoundError:
																									continue
																			# We iterate over all the globals in self.obj in case we find "os" or "os.path"
																			for attr in self.obj.__dir__():
																									__lowerCAmelCase     =  getattr(self.obj    ,				snake_case_				)
																									# We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
																									# This allows to patch renamed modules like "from os import path as ospath".
																									if obj_attr is submodule or (
																									    (isinstance(snake_case_    ,				_PatchedModuleObj				) and obj_attr._original_module is submodule)
																									):
																															__lowerCAmelCase     =  obj_attr
																															# patch at top level
																															setattr(self.obj    ,				snake_case_    ,				_PatchedModuleObj(snake_case_    ,				attrs=self.attrs				)				)
																															__lowerCAmelCase     =  getattr(self.obj    ,				snake_case_				)
																															# construct lower levels patches
																															for key in submodules[i + 1 :]:
																																					setattr(snake_case_    ,				snake_case_    ,				_PatchedModuleObj(getattr(snake_case_    ,				snake_case_    ,				snake_case_				)    ,				attrs=self.attrs				)				)
																																					__lowerCAmelCase     =  getattr(snake_case_    ,				snake_case_				)
																															# finally set the target attribute
																															setattr(snake_case_    ,				snake_case_    ,				self.new				)

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

													if submodules:  # if it's an attribute of a submodule like "os.path.join"
																			try:
																									__lowerCAmelCase     =  getattr(import_module(""".""".join(snake_case_				)				)    ,				snake_case_				)
																			except (AttributeError, ModuleNotFoundError):
																									return
																			# We iterate over all the globals in self.obj in case we find "os.path.join"
																			for attr in self.obj.__dir__():
																									# We don't check for the name of the global, but rather if its value *is* "os.path.join".
																									# This allows to patch renamed attributes like "from os.path import join as pjoin".
																									if getattr(self.obj    ,				snake_case_				) is attr_value:
																															__lowerCAmelCase     =  getattr(self.obj    ,				snake_case_				)
																															setattr(self.obj    ,				snake_case_    ,				self.new				)
													elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
																			__lowerCAmelCase     =  globals()["""__builtins__"""][target_attr]
																			setattr(self.obj    ,				snake_case_    ,				self.new				)
													else:
																			raise RuntimeError(f"""Tried to patch attribute {target_attr} instead of a submodule."""				)




							def __exit__( self    ,				*snake_case_				)       ->  str:
													for attr in list(self.original				):
																			setattr(self.obj    ,				snake_case_    ,				self.original.pop(snake_case_				)				)




							def    A__						( self				)       ->  Tuple:
													self.__enter__()
													self._active_patches.append(self				)




							def    A__						( self				)       ->  Any:
													try:
																			self._active_patches.remove(self				)
													except ValueError:
																			# If the patch hasn't been started this will fail
																			return None

													return self.__exit__()


"""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


SCREAMING_SNAKE_CASE_					     =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_					     =	{
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							_snake_case						      =		'''efficientnet'''




							def __init__( self    ,				snake_case_ = 3    ,				snake_case_ = 600    ,				snake_case_ = 2.0    ,				snake_case_ = 3.1    ,				snake_case_ = 8    ,				snake_case_ = [3, 3, 5, 3, 5, 5, 3]    ,				snake_case_ = [32, 16, 24, 40, 80, 112, 192]    ,				snake_case_ = [16, 24, 40, 80, 112, 192, 320]    ,				snake_case_ = []    ,				snake_case_ = [1, 2, 2, 2, 1, 2, 1]    ,				snake_case_ = [1, 2, 2, 3, 3, 4, 1]    ,				snake_case_ = [1, 6, 6, 6, 6, 6, 6]    ,				snake_case_ = 0.25    ,				snake_case_ = "swish"    ,				snake_case_ = 2_560    ,				snake_case_ = "mean"    ,				snake_case_ = 0.02    ,				snake_case_ = 0.001    ,				snake_case_ = 0.99    ,				snake_case_ = 0.5    ,				snake_case_ = 0.2    ,				**snake_case_    ,				)       ->  List[str]:
													super().__init__(**snake_case_				)

													__lowerCAmelCase     =  num_channels
													__lowerCAmelCase     =  image_size
													__lowerCAmelCase     =  width_coefficient
													__lowerCAmelCase     =  depth_coefficient
													__lowerCAmelCase     =  depth_divisor
													__lowerCAmelCase     =  kernel_sizes
													__lowerCAmelCase     =  in_channels
													__lowerCAmelCase     =  out_channels
													__lowerCAmelCase     =  depthwise_padding
													__lowerCAmelCase     =  strides
													__lowerCAmelCase     =  num_block_repeats
													__lowerCAmelCase     =  expand_ratios
													__lowerCAmelCase     =  squeeze_expansion_ratio
													__lowerCAmelCase     =  hidden_act
													__lowerCAmelCase     =  hidden_dim
													__lowerCAmelCase     =  pooling_type
													__lowerCAmelCase     =  initializer_range
													__lowerCAmelCase     =  batch_norm_eps
													__lowerCAmelCase     =  batch_norm_momentum
													__lowerCAmelCase     =  dropout_rate
													__lowerCAmelCase     =  drop_connect_rate
													__lowerCAmelCase     =  sum(snake_case_				) * 4
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							_snake_case						      =		version.parse('''1.11''' )




							@property
							def    A__						( self				)       ->  Mapping[str, Mapping[int, str]]:
													return OrderedDict(
													    [
													        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
													    ]				)




							@property
							def    A__						( self				)       ->  float:
													return 1e-5
