
"""simple docstring"""
import argparse
import os
import re

import packaging.version


SCREAMING_SNAKE_CASE_					     =	'''examples/'''
SCREAMING_SNAKE_CASE_					     =	{
    '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''),
    '''init''': (re.compile(R'''^__version__\s+=\s+"([^"]+)"\s*$''', re.MULTILINE), '''__version__ = "VERSION"\n'''),
    '''setup''': (re.compile(R'''^(\s*)version\s*=\s*"[^"]+",''', re.MULTILINE), R'''\1version="VERSION",'''),
    '''doc''': (re.compile(R'''^(\s*)release\s*=\s*"[^"]+"$''', re.MULTILINE), '''release = "VERSION"\n'''),
}
SCREAMING_SNAKE_CASE_					     =	{
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
SCREAMING_SNAKE_CASE_					     =	'''README.md'''

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase ,    _lowerCAmelCase						):
						with open(_lowerCAmelCase ,    """r""" ,    encoding="""utf-8""" ,    newline="""\n"""						) as f:
												__lowerCAmelCase     =  f.read()
						__lowerCAmelCase   ,     __lowerCAmelCase     =  REPLACE_PATTERNS[pattern]
						__lowerCAmelCase     =  replace.replace("""VERSION""" ,    _lowerCAmelCase						)
						__lowerCAmelCase     =  re_pattern.sub(_lowerCAmelCase ,    _lowerCAmelCase						)
						with open(_lowerCAmelCase ,    """w""" ,    encoding="""utf-8""" ,    newline="""\n"""						) as f:
												f.write(_lowerCAmelCase						)

def  lowercase     (_lowerCAmelCase						):
						for folder, directories, fnames in os.walk(_lowerCAmelCase						):
												# Removing some of the folders with non-actively maintained examples from the walk
												if "research_projects" in directories:
																		directories.remove("""research_projects"""						)
												if "legacy" in directories:
																		directories.remove("""legacy"""						)
												for fname in fnames:
																		if fname.endswith(""".py"""						):
																								update_version_in_file(os.path.join(_lowerCAmelCase ,    _lowerCAmelCase						) ,    _lowerCAmelCase ,    pattern="""examples"""						)

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase=False						):
						for pattern, fname in REPLACE_FILES.items():
												update_version_in_file(_lowerCAmelCase ,    _lowerCAmelCase ,    _lowerCAmelCase						)
						if not patch:
												update_version_in_examples(_lowerCAmelCase						)

def  lowercase     ():
						__lowerCAmelCase     =  """🤗 Transformers currently provides the following architectures"""
						__lowerCAmelCase     =  """1. Want to contribute a new model?"""
						with open(_lowerCAmelCase ,    """r""" ,    encoding="""utf-8""" ,    newline="""\n"""						) as f:
												__lowerCAmelCase     =  f.readlines()

						# Find the start of the list.
						__lowerCAmelCase     =  0
						while not lines[start_index].startswith(_start_prompt						):
												start_index += 1
						start_index += 1

						__lowerCAmelCase     =  start_index
						# Update the lines in the model list.
						while not lines[index].startswith(_end_prompt						):
												if lines[index].startswith("""1."""						):
																		__lowerCAmelCase     =  lines[index].replace(
																		    """https://huggingface.co/docs/transformers/main/model_doc""" ,    """https://huggingface.co/docs/transformers/model_doc""" ,    )
												index += 1

						with open(_lowerCAmelCase ,    """w""" ,    encoding="""utf-8""" ,    newline="""\n"""						) as f:
												f.writelines(_lowerCAmelCase						)

def  lowercase     ():
						with open(REPLACE_FILES["""init"""] ,    """r"""						) as f:
												__lowerCAmelCase     =  f.read()
						__lowerCAmelCase     =  REPLACE_PATTERNS["""init"""][0].search(_lowerCAmelCase						).groups()[0]
						return packaging.version.parse(_lowerCAmelCase						)

def  lowercase     (_lowerCAmelCase=False						):
						__lowerCAmelCase     =  get_version()
						if patch and default_version.is_devrelease:
												raise ValueError("""Can't create a patch version from the dev branch, checkout a released version!"""						)
						if default_version.is_devrelease:
												__lowerCAmelCase     =  default_version.base_version
						elif patch:
												__lowerCAmelCase     =  f"""{default_version.major}.{default_version.minor}.{default_version.micro + 1}"""
						else:
												__lowerCAmelCase     =  f"""{default_version.major}.{default_version.minor + 1}.0"""

						# Now let's ask nicely if that's the right one.
						__lowerCAmelCase     =  input(f"""Which version are you releasing? [{default_version}]"""						)
						if len(_lowerCAmelCase						) == 0:
												__lowerCAmelCase     =  default_version

						print(f"""Updating version to {version}."""						)
						global_version_update(_lowerCAmelCase ,    patch=_lowerCAmelCase						)
						if not patch:
												print("""Cleaning main README, don't forget to run `make fix-copies`."""						)
												clean_main_ref_in_model_list()

def  lowercase     ():
						__lowerCAmelCase     =  get_version()
						__lowerCAmelCase     =  f"""{current_version.major}.{current_version.minor + 1}.0.dev0"""
						__lowerCAmelCase     =  current_version.base_version

						# Check with the user we got that right.
						__lowerCAmelCase     =  input(f"""Which version are we developing now? [{dev_version}]"""						)
						if len(_lowerCAmelCase						) == 0:
												__lowerCAmelCase     =  dev_version

						print(f"""Updating version to {version}."""						)
						global_version_update(_lowerCAmelCase						)
						print("""Cleaning main README, don't forget to run `make fix-copies`."""						)
						clean_main_ref_in_model_list()


if __name__ == "__main__":
			SCREAMING_SNAKE_CASE_					     =	argparse.ArgumentParser()
			parser.add_argument('''--post_release''', action='''store_true''', help='''Whether this is pre or post release.''')
			parser.add_argument('''--patch''', action='''store_true''', help='''Whether or not this is a patch release.''')
			SCREAMING_SNAKE_CASE_					     =	parser.parse_args()
			if not args.post_release:
						pre_release_work(patch=args.patch)
			elif args.patch:
						print('''Nothing to do after a patch :-)''')
			else:
						post_release_work()


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