



import argparse
import os
import re

import packaging.version


snake_case    :						int  =						'examples/'
snake_case    :						Union[str, Any]  =						{
    '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'),
}
snake_case    :						Tuple  =						{
    'init': 'src/transformers/__init__.py',
    'setup': 'setup.py',
}
snake_case    :						Tuple  =						'README.md'
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase       )		->		Dict:







						"""simple docstring"""

						with open(__lowercase							,     "r"							,     encoding="utf-8"							,     newline="\n"       ) as f:
												A__	:							List[Any]						    = f.read()
						A__    ,       A__	:							List[Any]						    = REPLACE_PATTERNS[pattern]
						A__	:							Optional[int]						    = replace.replace("VERSION"							,     __lowercase       )
						A__	:							Optional[Any]						    = re_pattern.sub(__lowercase							,     __lowercase       )
						with open(__lowercase							,     "w"							,     encoding="utf-8"							,     newline="\n"       ) as f:
												f.write(__lowercase       )
def 	snake_case__       (					__lowercase       )		->		Tuple:







						"""simple docstring"""

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







						"""simple docstring"""

						for pattern, fname in REPLACE_FILES.items():
												update_version_in_file(__lowercase							,     __lowercase							,     __lowercase       )
						if not patch:
												update_version_in_examples(__lowercase       )
def 	snake_case__       (					)		->		Optional[int]:







						"""simple docstring"""

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

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

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

						with open(__lowercase							,     "w"							,     encoding="utf-8"							,     newline="\n"       ) as f:
												f.writelines(__lowercase       )
def 	snake_case__       (					)		->		Any:







						"""simple docstring"""

						with open(REPLACE_FILES["init"]							,     "r"       ) as f:
												A__	:							str						    = f.read()
						A__	:							Union[str, Any]						    = REPLACE_PATTERNS["init"][0].search(__lowercase       ).groups()[0]
						return packaging.version.parse(__lowercase       )
def 	snake_case__       (					__lowercase=False       )		->		Optional[Any]:







						"""simple docstring"""

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

						# Now let's ask nicely if that's the right one.
						A__	:							Tuple						    = input(F'Which version are you releasing? [{default_version}]'       )
						if len(__lowercase       ) == 0:
												A__	:							Union[str, Any]						    = default_version

						print(F'Updating version to {version}.'       )
						global_version_update(__lowercase							,     patch=__lowercase       )
						if not patch:
												print("Cleaning main README, don't forget to run `make fix-copies`."       )
												clean_main_ref_in_model_list()
def 	snake_case__       (					)		->		Optional[int]:







						"""simple docstring"""

						A__	:							List[Any]						    = get_version()
						A__	:							List[str]						    = F'{current_version.major}.{current_version.minor + 1}.0.dev0'
						A__	:							Dict						    = current_version.base_version

						# Check with the user we got that right.
						A__	:							Tuple						    = input(F'Which version are we developing now? [{dev_version}]'       )
						if len(__lowercase       ) == 0:
												A__	:							Any						    = dev_version

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


if __name__ == "__main__":
		snake_case    :						Union[str, Any]  =						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.')
		snake_case    :						Union[str, Any]  =						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()




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case    :						str  =						{
    'configuration_albert': ['ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AlbertConfig', 'AlbertOnnxConfig'],
}

try:
		if not is_sentencepiece_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Any  =						['AlbertTokenizer']

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						List[str]  =						['AlbertTokenizerFast']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						List[str]  =						[
		    'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'AlbertForMaskedLM',
		    'AlbertForMultipleChoice',
		    'AlbertForPreTraining',
		    'AlbertForQuestionAnswering',
		    'AlbertForSequenceClassification',
		    'AlbertForTokenClassification',
		    'AlbertModel',
		    'AlbertPreTrainedModel',
		    'load_tf_weights_in_albert',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Union[str, Any]  =						[
		    'TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFAlbertForMaskedLM',
		    'TFAlbertForMultipleChoice',
		    'TFAlbertForPreTraining',
		    'TFAlbertForQuestionAnswering',
		    'TFAlbertForSequenceClassification',
		    'TFAlbertForTokenClassification',
		    'TFAlbertMainLayer',
		    'TFAlbertModel',
		    'TFAlbertPreTrainedModel',
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Any  =						[
		    'FlaxAlbertForMaskedLM',
		    'FlaxAlbertForMultipleChoice',
		    'FlaxAlbertForPreTraining',
		    'FlaxAlbertForQuestionAnswering',
		    'FlaxAlbertForSequenceClassification',
		    'FlaxAlbertForTokenClassification',
		    'FlaxAlbertModel',
		    'FlaxAlbertPreTrainedModel',
		]

if TYPE_CHECKING:
		from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, AlbertOnnxConfig

		try:
				if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_albert import AlbertTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_albert_fast import AlbertTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_albert import (
				    ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    AlbertForMaskedLM,
				    AlbertForMultipleChoice,
				    AlbertForPreTraining,
				    AlbertForQuestionAnswering,
				    AlbertForSequenceClassification,
				    AlbertForTokenClassification,
				    AlbertModel,
				    AlbertPreTrainedModel,
				    load_tf_weights_in_albert,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_albert import (
				    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFAlbertForMaskedLM,
				    TFAlbertForMultipleChoice,
				    TFAlbertForPreTraining,
				    TFAlbertForQuestionAnswering,
				    TFAlbertForSequenceClassification,
				    TFAlbertForTokenClassification,
				    TFAlbertMainLayer,
				    TFAlbertModel,
				    TFAlbertPreTrainedModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_albert import (
				    FlaxAlbertForMaskedLM,
				    FlaxAlbertForMultipleChoice,
				    FlaxAlbertForPreTraining,
				    FlaxAlbertForQuestionAnswering,
				    FlaxAlbertForSequenceClassification,
				    FlaxAlbertForTokenClassification,
				    FlaxAlbertModel,
				    FlaxAlbertPreTrainedModel,
				)
else:
		import sys

		snake_case    :						Any  =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)