






def   __lowercase       (			snake_case			):







				"""simple docstring"""






				if not all(char in '''01''' for char in bin_string			):
								raise ValueError('''Non-binary value was passed to the function'''			)
				if not bin_string:
								raise ValueError('''Empty string was passed to the function'''			)
				__magic_name__		:Optional[int]   =   ''''''
				while len(snake_case			) % 3 != 0:
								__magic_name__		:str   =   '''0''' + bin_string
				__magic_name__		:str   =   [
				    bin_string[index : index + 3]
				    for index in range(len(snake_case			)			)
				    if index % 3 == 0
				]
				for bin_group in bin_string_in_3_list:
								__magic_name__		:Tuple   =   0
								for index, val in enumerate(snake_case			):
												oct_val += int(2 ** (2 - index) * int(snake_case			)			)
								oct_string += str(snake_case			)
				return oct_string


if __name__ == "__main__":
					from doctest import testmod

					testmod()










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	(    a     , a     , a ):



		'''simple docstring'''




		with open(a     , "r"     , encoding="utf-8"     , newline="\n" ) as f:
				SCREAMING_SNAKE_CASE_				:Dict				     =						f.read()
		SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						REPLACE_PATTERNS[pattern]
		SCREAMING_SNAKE_CASE_				:List[str]				     =						replace.replace("VERSION"     , a )
		SCREAMING_SNAKE_CASE_				:str				     =						re_pattern.sub(a     , a )
		with open(a     , "w"     , encoding="utf-8"     , newline="\n" ) as f:
				f.write(a )


def     lowercase	(    a ):



		'''simple docstring'''




		for folder, directories, fnames in os.walk(a ):
				# 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(a     , a )     , a     , pattern="examples" )


def     lowercase	(    a     , a=False ):



		'''simple docstring'''




		for pattern, fname in REPLACE_FILES.items():
				update_version_in_file(a     , a     , a )
		if not patch:
				update_version_in_examples(a )


def     lowercase	(    ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:int				     =						"🤗 Transformers currently provides the following architectures"
		SCREAMING_SNAKE_CASE_				:Any				     =						"1. Want to contribute a new model?"
		with open(a     , "r"     , encoding="utf-8"     , newline="\n" ) as f:
				SCREAMING_SNAKE_CASE_				:List[str]				     =						f.readlines()

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

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

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


def     lowercase	(    ):



		'''simple docstring'''




		with open(REPLACE_FILES["init"]     , "r" ) as f:
				SCREAMING_SNAKE_CASE_				:str				     =						f.read()
		SCREAMING_SNAKE_CASE_				:Optional[int]				     =						REPLACE_PATTERNS["init"][0].search(a ).groups()[0]
		return packaging.version.parse(a )


def     lowercase	(    a=False ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:str				     =						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:
				SCREAMING_SNAKE_CASE_				:int				     =						default_version.base_version
		elif patch:
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						F"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
		else:
				SCREAMING_SNAKE_CASE_				:List[str]				     =						F"{default_version.major}.{default_version.minor + 1}.0"

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

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


def     lowercase	(    ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						get_version()
		SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						F"{current_version.major}.{current_version.minor + 1}.0.dev0"
		SCREAMING_SNAKE_CASE_				:str				     =						current_version.base_version

		# Check with the user we got that right.
		SCREAMING_SNAKE_CASE_				:Any				     =						input(F"Which version are we developing now? [{dev_version}]" )
		if len(a ) == 0:
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						dev_version

		print(F"Updating version to {version}." )
		global_version_update(a )
		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()






