





import argparse
import os
import re

import packaging.version


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




def 		lowerCAmelCase_    (  __UpperCAmelCase:			str		,   __UpperCAmelCase:			Union[str, Any]		,   __UpperCAmelCase:			int      )      ->	str:
    with open(__UpperCAmelCase		,   '''r'''		,   encoding='''utf-8'''		,   newline='''\n'''      ) as f:
        UpperCamelCase__							:				List[Any]          =      f.read()
    UpperCamelCase__   ,UpperCamelCase__							:				List[Any]          =      REPLACE_PATTERNS[pattern]
    UpperCamelCase__							:				str          =      replace.replace('''VERSION'''		,   __UpperCAmelCase      )
    UpperCamelCase__							:				List[Any]          =      re_pattern.sub(__UpperCAmelCase		,   __UpperCAmelCase      )
    with open(__UpperCAmelCase		,   '''w'''		,   encoding='''utf-8'''		,   newline='''\n'''      ) as f:
        f.write(__UpperCAmelCase      )




def 		lowerCAmelCase_    (  __UpperCAmelCase:			int      )      ->	Union[str, Any]:
    for folder, directories, fnames in os.walk(__UpperCAmelCase      ):
        # 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(__UpperCAmelCase		,   __UpperCAmelCase      )		,   __UpperCAmelCase		,   pattern='''examples'''      )




def 		lowerCAmelCase_    (  __UpperCAmelCase:			Optional[Any]		,   __UpperCAmelCase:			Optional[int]=False      )      ->	Optional[int]:
    for pattern, fname in REPLACE_FILES.items():
        update_version_in_file(__UpperCAmelCase		,   __UpperCAmelCase		,   __UpperCAmelCase      )
    if not patch:
        update_version_in_examples(__UpperCAmelCase      )




def 		lowerCAmelCase_    (  )      ->	List[str]:
    UpperCamelCase__							:				Tuple          =      '''🤗 Transformers currently provides the following architectures'''
    UpperCamelCase__							:				List[str]          =      '''1. Want to contribute a new model?'''
    with open(__UpperCAmelCase		,   '''r'''		,   encoding='''utf-8'''		,   newline='''\n'''      ) as f:
        UpperCamelCase__							:				int          =      f.readlines()

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

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

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




def 		lowerCAmelCase_    (  )      ->	List[Any]:
    with open(REPLACE_FILES['''init''']		,   '''r'''      ) as f:
        UpperCamelCase__							:				int          =      f.read()
    UpperCamelCase__							:				List[Any]          =      REPLACE_PATTERNS['''init'''][0].search(__UpperCAmelCase      ).groups()[0]
    return packaging.version.parse(__UpperCAmelCase      )




def 		lowerCAmelCase_    (  __UpperCAmelCase:			str=False      )      ->	Union[str, Any]:
    UpperCamelCase__							:				Union[str, 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:
        UpperCamelCase__							:				List[str]          =      default_version.base_version
    elif patch:
        UpperCamelCase__							:				Optional[Any]          =      f"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
    else:
        UpperCamelCase__							:				Optional[int]          =      f"{default_version.major}.{default_version.minor + 1}.0"

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

    print(f"Updating version to {version}."      )
    global_version_update(__UpperCAmelCase		,   patch=__UpperCAmelCase      )




def 		lowerCAmelCase_    (  )      ->	str:
    UpperCamelCase__							:				Dict          =      get_version()
    UpperCamelCase__							:				Tuple          =      f"{current_version.major}.{current_version.minor + 1}.0.dev0"
    UpperCamelCase__							:				Optional[int]          =      current_version.base_version

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

    print(f"Updating version to {version}."      )
    global_version_update(__UpperCAmelCase      )


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


if __name__ == "__main__":
  UpperCAmelCase_     							= 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.')
  UpperCAmelCase_     							= 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 __future__ import annotations




def 		lowerCAmelCase_    (  __UpperCAmelCase:			list[int]		,   __UpperCAmelCase:			int      )      ->	list[int]:
    UpperCamelCase__							:				Optional[int]          =      0
    UpperCamelCase__							:				Tuple          =      len(__UpperCAmelCase      ) - 1

    while i < j:
        if nums[i] + nums[j] == target:
            return [i, j]
        elif nums[i] + nums[j] < target:
            UpperCamelCase__							:				Tuple          =      i + 1
        else:
            UpperCamelCase__							:				str          =      j - 1

    return []


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  print(F'''{two_pointer([2, 7, 11, 15], 9) = }''')

