






import argparse
import os
import re

import packaging.version


_a     : List[Any]   	=      """examples/"""
_a     : str   	=      {
    """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     : int   	=      {
    """init""": """src/transformers/__init__.py""",
    """setup""": """setup.py""",
}
_a     : str   	=      """README.md"""


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


def 					snake_case__				(				UpperCAmelCase				:	str							):
    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 					snake_case__				(				UpperCAmelCase				:	Optional[Any]     ,      UpperCAmelCase				:	Union[str, Any]=False							):
    for pattern, fname in REPLACE_FILES.items():
        update_version_in_file(UpperCAmelCase     ,      UpperCAmelCase     ,      UpperCAmelCase							)
    if not patch:
        update_version_in_examples(UpperCAmelCase							)


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

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

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

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


def 					snake_case__				(				):
    with open(REPLACE_FILES["init"]     ,      "r"							) as f:
        lowerCAmelCase__ :List[str]   				=					f.read()
    lowerCAmelCase__ :int   				=					REPLACE_PATTERNS["""init"""][0].search(UpperCAmelCase							).groups()[0]
    return packaging.version.parse(UpperCAmelCase							)


def 					snake_case__				(				UpperCAmelCase				:	Optional[Any]=False							):
    lowerCAmelCase__ :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:
        lowerCAmelCase__ :Any   				=					default_version.base_version
    elif patch:
        lowerCAmelCase__ :str   				=					F'''{default_version.major}.{default_version.minor}.{default_version.micro + 1}'''
    else:
        lowerCAmelCase__ :List[Any]   				=					F'''{default_version.major}.{default_version.minor + 1}.0'''

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

    print(F'''Updating version to {version}.'''							)
    global_version_update(UpperCAmelCase     ,      patch=UpperCAmelCase							)
    if not patch:
        print("Cleaning main README, don't forget to run `make fix-copies`."							)
        clean_main_ref_in_model_list()


def 					snake_case__				(				):
    lowerCAmelCase__ :Union[str, Any]   				=					get_version()
    lowerCAmelCase__ :Tuple   				=					F'''{current_version.major}.{current_version.minor + 1}.0.dev0'''
    lowerCAmelCase__ :Any   				=					current_version.base_version

    # Check with the user we got that right.
    lowerCAmelCase__ :Tuple   				=					input(F'''Which version are we developing now? [{dev_version}]'''							)
    if len(UpperCAmelCase							) == 0:
        lowerCAmelCase__ :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__":
 _a     : Tuple   	=      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     : Dict   	=      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"""
_A							=  """ABCDEFGHIJKLMNOPQRSTUVWXYZ"""




def 					a__						(						)	-> None:
      UpperCAmelCase__			:							Optional[Any]							=    input("""Enter message: """    )
      UpperCAmelCase__			:							Optional[Any]							=    input("""Enter key [alphanumeric]: """    )
      UpperCAmelCase__			:							Optional[Any]							=    input("""Encrypt/Decrypt [e/d]: """    )

      if mode.lower().startswith("""e"""    ):
            UpperCAmelCase__			:							Optional[Any]							=    """encrypt"""
            UpperCAmelCase__			:							List[Any]							=    encrypt_message(lowerCAmelCase			,	lowerCAmelCase    )
      elif mode.lower().startswith("""d"""    ):
            UpperCAmelCase__			:							Optional[Any]							=    """decrypt"""
            UpperCAmelCase__			:							Dict							=    decrypt_message(lowerCAmelCase			,	lowerCAmelCase    )

      print(F"""\n{mode.title()}ed message:"""    )
      print(lowerCAmelCase    )




def 					a__						(						lowerCAmelCase			,	lowerCAmelCase    )	-> str:
      return translate_message(lowerCAmelCase			,	lowerCAmelCase			,	"""encrypt"""    )




def 					a__						(						lowerCAmelCase			,	lowerCAmelCase    )	-> str:
      return translate_message(lowerCAmelCase			,	lowerCAmelCase			,	"""decrypt"""    )




def 					a__						(						lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase    )	-> str:
      UpperCAmelCase__			:							Optional[Any]							=    []
      UpperCAmelCase__			:							int							=    0
      UpperCAmelCase__			:							str							=    key.upper()

      for symbol in message:
            UpperCAmelCase__			:							Optional[Any]							=    LETTERS.find(symbol.upper()    )
            if num != -1:
                  if mode == "encrypt":
                        num += LETTERS.find(key[key_index]    )
                  elif mode == "decrypt":
                        num -= LETTERS.find(key[key_index]    )

                  num %= len(lowerCAmelCase    )

                  if symbol.isupper():
                        translated.append(LETTERS[num]    )
                  elif symbol.islower():
                        translated.append(LETTERS[num].lower()    )

                  key_index += 1
                  if key_index == len(lowerCAmelCase    ):
                        UpperCAmelCase__			:							List[str]							=    0
            else:
                  translated.append(lowerCAmelCase    )
      return "".join(lowerCAmelCase    )


if __name__ == "__main__":
    main()

