
'''simple docstring'''
import argparse
import os
import re

import packaging.version


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







def        A_     (						__SCREAMING_SNAKE_CASE						:  Dict			,     __SCREAMING_SNAKE_CASE						:  Any			,     __SCREAMING_SNAKE_CASE						:  Tuple )				->       Union[str, Any]:





  """simple docstring"""

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







def        A_     (						__SCREAMING_SNAKE_CASE						:  str )				->       Optional[int]:





  """simple docstring"""

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







def        A_     (						__SCREAMING_SNAKE_CASE						:  str			,     __SCREAMING_SNAKE_CASE						:  Dict=False )				->       Dict:





  """simple docstring"""

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







def        A_     (						)				->       List[str]:





  """simple docstring"""

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

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

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

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







def        A_     (						)				->       Optional[int]:





  """simple docstring"""

  with open(REPLACE_FILES["""init"""]			,     """r""" ) as f:
    __A		:     str												=		f.read()
  __A		:     Any												=		REPLACE_PATTERNS["""init"""][0].search(__SCREAMING_SNAKE_CASE ).groups()[0]
  return packaging.version.parse(__SCREAMING_SNAKE_CASE )







def        A_     (						__SCREAMING_SNAKE_CASE						:  Union[str, Any]=False )				->       List[str]:





  """simple docstring"""

  __A		:     List[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		:     Tuple												=		default_version.base_version
  elif patch:
    __A		:     Tuple												=		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		:     str												=		input(F"Which version are you releasing? [{default_version}]" )
  if len(__SCREAMING_SNAKE_CASE ) == 0:
    __A		:     List[Any]												=		default_version

  print(F"Updating version to {version}." )
  global_version_update(__SCREAMING_SNAKE_CASE			,     patch=__SCREAMING_SNAKE_CASE )







def        A_     (						)				->       List[Any]:





  """simple docstring"""

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

  # Check with the user we got that right.
  __A		:     int												=		input(F"Which version are we developing now? [{dev_version}]" )
  if len(__SCREAMING_SNAKE_CASE ) == 0:
    __A		:     Union[str, Any]												=		dev_version

  print(F"Updating version to {version}." )
  global_version_update(__SCREAMING_SNAKE_CASE )


#    print("Cleaning main README, don't forget to run `make fix-copies`.")
#    clean_main_ref_in_model_list()


if __name__ == "__main__":
     A__   :		List[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.')
     A__   :		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()





'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


A__   :		int 		=logging.get_logger(__name__)

A__   :		Union[str, Any] 		={
    '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				( _SCREAMING_SNAKE_CASE			):
 lowerCamelCase				       ='''dpr'''
 def __init__(   self			:    Optional[int]				,   lowerCamelCase			:    Tuple=3_05_22				,   lowerCamelCase			:    List[str]=7_68				,   lowerCamelCase			:    Union[str, Any]=12				,   lowerCamelCase			:    Tuple=12				,   lowerCamelCase			:    Dict=30_72				,   lowerCamelCase			:    List[Any]="gelu"				,   lowerCamelCase			:    List[Any]=0.1				,   lowerCamelCase			:    Union[str, Any]=0.1				,   lowerCamelCase			:    Optional[Any]=5_12				,   lowerCamelCase			:    List[Any]=2				,   lowerCamelCase			:    int=0.02				,   lowerCamelCase			:    Union[str, Any]=1e-1_2				,   lowerCamelCase			:    int=0				,   lowerCamelCase			:    List[str]="absolute"				,   lowerCamelCase			:    int = 0				,   **lowerCamelCase			:    List[Any]				,   ):



   """simple docstring"""





   super().__init__(pad_token_id=lowerCamelCase				,   **lowerCamelCase       )

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



