


import argparse
import os
import re

import packaging.version


lowerCamelCase						=		'''examples/'''
lowerCamelCase						=		{
    '''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						=		{
    '''init''': '''src/transformers/__init__.py''',
    '''setup''': '''setup.py''',
}
lowerCamelCase						=		'''README.md'''






def 					lowerCamelCase_   (	_a     ,       _a     ,       _a	):




		"""simple docstring"""






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






def 					lowerCamelCase_   (	_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 					lowerCamelCase_   (	_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 					lowerCamelCase_   (	):




		"""simple docstring"""






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

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

		lowerCAmelCase__       :      Optional[int]   					= start_index
		# Update the lines in the model list.
		while not lines[index].startswith(_end_prompt	):
				if lines[index].startswith('''1.'''	):
						lowerCAmelCase__       :      Optional[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 					lowerCamelCase_   (	):




		"""simple docstring"""






		with open(REPLACE_FILES['''init''']     ,       '''r'''	) as f:
				lowerCAmelCase__       :      Tuple   					= f.read()
		lowerCAmelCase__       :      List[str]   					= REPLACE_PATTERNS['''init'''][0].search(_a	).groups()[0]
		return packaging.version.parse(_a	)






def 					lowerCamelCase_   (	_a=False	):




		"""simple docstring"""






		lowerCAmelCase__       :      Dict   					= 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__       :      int   					= default_version.base_version
		elif patch:
				lowerCAmelCase__       :      Optional[Any]   					= f'{default_version.major}.{default_version.minor}.{default_version.micro + 1}'
		else:
				lowerCAmelCase__       :      Optional[int]   					= f'{default_version.major}.{default_version.minor + 1}.0'

		# Now let's ask nicely if that's the right one.
		lowerCAmelCase__       :      Tuple   					= input(f'Which version are you releasing? [{default_version}]'	)
		if len(_a	) == 0:
				lowerCAmelCase__       :      Tuple   					= 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 					lowerCamelCase_   (	):




		"""simple docstring"""






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

		# Check with the user we got that right.
		lowerCAmelCase__       :      int   					= input(f'Which version are we developing now? [{dev_version}]'	)
		if len(_a	) == 0:
				lowerCAmelCase__       :      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						=		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						=		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 ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase						=		logging.get_logger(__name__)

lowerCamelCase						=		{
    '''facebook/dpr-ctx_encoder-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-question_encoder-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-reader-single-nq-base''': (
        '''https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-ctx_encoder-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-question_encoder-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json'''
    ),
    '''facebook/dpr-reader-multiset-base''': (
        '''https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json'''
    ),
}





class  _a							(    _lowercase):
	_a  :  List[Any]				   =							'''dpr'''




	def __init__( self						:		List[str]		, _SCREAMING_SNAKE_CASE						:		List[str]=3_0522		, _SCREAMING_SNAKE_CASE						:		Optional[int]=768		, _SCREAMING_SNAKE_CASE						:		List[str]=12		, _SCREAMING_SNAKE_CASE						:		Tuple=12		, _SCREAMING_SNAKE_CASE						:		str=3072		, _SCREAMING_SNAKE_CASE						:		Optional[Any]="gelu"		, _SCREAMING_SNAKE_CASE						:		Dict=0.1		, _SCREAMING_SNAKE_CASE						:		Optional[int]=0.1		, _SCREAMING_SNAKE_CASE						:		List[str]=512		, _SCREAMING_SNAKE_CASE						:		int=2		, _SCREAMING_SNAKE_CASE						:		Optional[Any]=0.02		, _SCREAMING_SNAKE_CASE						:		Tuple=1E-12		, _SCREAMING_SNAKE_CASE						:		Union[str, Any]=0		, _SCREAMING_SNAKE_CASE						:		List[str]="absolute"		, _SCREAMING_SNAKE_CASE						:		int = 0		, **_SCREAMING_SNAKE_CASE						:		Optional[Any]		, )->	Optional[int]:
			super().__init__(pad_token_id=_SCREAMING_SNAKE_CASE		, **_SCREAMING_SNAKE_CASE		)

			lowerCAmelCase__       :      Union[str, Any]   					= vocab_size
			lowerCAmelCase__       :      Tuple   					= hidden_size
			lowerCAmelCase__       :      Union[str, Any]   					= num_hidden_layers
			lowerCAmelCase__       :      List[Any]   					= num_attention_heads
			lowerCAmelCase__       :      Optional[int]   					= hidden_act
			lowerCAmelCase__       :      Optional[Any]   					= intermediate_size
			lowerCAmelCase__       :      Optional[Any]   					= hidden_dropout_prob
			lowerCAmelCase__       :      int   					= attention_probs_dropout_prob
			lowerCAmelCase__       :      str   					= max_position_embeddings
			lowerCAmelCase__       :      List[Any]   					= type_vocab_size
			lowerCAmelCase__       :      Optional[int]   					= initializer_range
			lowerCAmelCase__       :      List[str]   					= layer_norm_eps
			lowerCAmelCase__       :      Dict   					= projection_dim
			lowerCAmelCase__       :      int   					= position_embedding_type




