




import argparse
import os
import re

import packaging.version


__lowerCamelCase   :						List[Any]				=			'''examples/'''
__lowerCamelCase   :						Tuple				=			{
    '''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'''),
}
__lowerCamelCase   :						Union[str, Any]				=			{
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
__lowerCamelCase   :						Optional[Any]				=			'''README.md'''







def 		lowercase__   (		__A:	str							,__A:	str							,__A:	List[str]				):





					'''simple docstring'''






					with open(__A							,'''r'''							,encoding='''utf-8'''							,newline='''\n'''				) as f:
										__magic_name__							:	int    							=							f.read()
					__magic_name__							,    __magic_name__							:	Optional[Any]    							=							REPLACE_PATTERNS[pattern]
					__magic_name__							:	List[str]    							=							replace.replace('''VERSION'''							,__A				)
					__magic_name__							:	Tuple    							=							re_pattern.sub(__A							,__A				)
					with open(__A							,'''w'''							,encoding='''utf-8'''							,newline='''\n'''				) as f:
										f.write(__A				)







def 		lowercase__   (		__A:	int				):





					'''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:	Tuple							,__A:	str=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'''






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

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

					__magic_name__							:	Optional[int]    							=							start_index
					# Update the lines in the model list.
					while not lines[index].startswith(_end_prompt				):
										if lines[index].startswith('''1.'''				):
															__magic_name__							:	Tuple    							=							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:
										__magic_name__							:	Tuple    							=							f.read()
					__magic_name__							:	Tuple    							=							REPLACE_PATTERNS['''init'''][0].search(__A				).groups()[0]
					return packaging.version.parse(__A				)







def 		lowercase__   (		__A:	Union[str, Any]=False				):





					'''simple docstring'''






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

					# Now let's ask nicely if that's the right one.
					__magic_name__							:	Union[str, Any]    							=							input(F'''Which version are you releasing? [{default_version}]'''				)
					if len(__A				) == 0:
										__magic_name__							:	List[str]    							=							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'''






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

					# Check with the user we got that right.
					__magic_name__							:	Dict    							=							input(F'''Which version are we developing now? [{dev_version}]'''				)
					if len(__A				) == 0:
										__magic_name__							:	str    							=							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__":
	__lowerCamelCase   :						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.''')
	__lowerCamelCase   :						Tuple				=			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_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


__lowerCamelCase   :						List[Any]				=			{
    '''configuration_speech_to_text''': ['''SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Speech2TextConfig'''],
    '''processing_speech_to_text''': ['''Speech2TextProcessor'''],
}

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

try:
	if not is_speech_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Optional[Any]				=			['''Speech2TextFeatureExtractor''']

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Any				=			[
	    '''TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''TFSpeech2TextForConditionalGeneration''',
	    '''TFSpeech2TextModel''',
	    '''TFSpeech2TextPreTrainedModel''',
	]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Any				=			[
	    '''SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''Speech2TextForConditionalGeneration''',
	    '''Speech2TextModel''',
	    '''Speech2TextPreTrainedModel''',
	]


if TYPE_CHECKING:
	from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
	from .processing_speech_to_text import SpeechaTextProcessor

	try:
		if not is_sentencepiece_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_speech_to_text import SpeechaTextTokenizer

	try:
		if not is_speech_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_speech_to_text import (
		    TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFSpeechaTextForConditionalGeneration,
		    TFSpeechaTextModel,
		    TFSpeechaTextPreTrainedModel,
		)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_speech_to_text import (
		    SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    SpeechaTextForConditionalGeneration,
		    SpeechaTextModel,
		    SpeechaTextPreTrainedModel,
		)

else:
	import sys

	__lowerCamelCase   :						List[str]				=			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



