

"""simple docstring"""





import argparse
import os
import re

import packaging.version


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




def   _A  (  UpperCamelCase_					:	Any,      UpperCamelCase_					:	Dict,      UpperCamelCase_					:	Union[str, Any])     ->						Tuple:
   '''simple docstring'''


   with open(UpperCamelCase_,      "r",      encoding="utf-8",      newline="\n") as f:
      __lowercase								=						f.read()
   __lowercase		,__lowercase								=						REPLACE_PATTERNS[pattern]
   __lowercase								=						replace.replace("VERSION",      UpperCamelCase_)
   __lowercase								=						re_pattern.sub(UpperCamelCase_,      UpperCamelCase_)
   with open(UpperCamelCase_,      "w",      encoding="utf-8",      newline="\n") as f:
      f.write(UpperCamelCase_)




def   _A  (  UpperCamelCase_					:	List[str])     ->						List[Any]:
   '''simple docstring'''


   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   _A  (  UpperCamelCase_					:	List[Any],      UpperCamelCase_					:	List[Any]=False)     ->						Optional[Any]:
   '''simple docstring'''


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




def   _A  (  )     ->						Any:
   '''simple docstring'''


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

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

   __lowercase								=						start_index
   # Update the lines in the model list.
   while not lines[index].startswith(_end_prompt):
      if lines[index].startswith("1."):
         __lowercase								=						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   _A  (  )     ->						Tuple:
   '''simple docstring'''


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




def   _A  (  UpperCamelCase_					:	Tuple=False)     ->						str:
   '''simple docstring'''


   __lowercase								=						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:
      __lowercase								=						default_version.base_version
   elif patch:
      __lowercase								=						F"""{default_version.major}.{default_version.minor}.{default_version.micro + 1}"""
   else:
      __lowercase								=						F"""{default_version.major}.{default_version.minor + 1}.0"""

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

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




def   _A  (  )     ->						Any:
   '''simple docstring'''


   __lowercase								=						get_version()
   __lowercase								=						F"""{current_version.major}.{current_version.minor + 1}.0.dev0"""
   __lowercase								=						current_version.base_version

   # Check with the user we got that right.
   __lowercase								=						input(F"""Which version are we developing now? [{dev_version}]""")
   if len(UpperCamelCase_) == 0:
      __lowercase								=						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							=							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							=							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"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


_a							=							logging.get_logger(__name__)

_a							=							{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

_a							=							[
    'small',
    'small-base',
    'medium',
    'medium-base',
    'intermediate',
    'intermediate-base',
    'large',
    'large-base',
    'xlarge',
    'xlarge-base',
]

_a							=							{
    'vocab_file': {
        'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt',
        'funnel-transformer/small-base': 'https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt',
        'funnel-transformer/medium': 'https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt',
        'funnel-transformer/medium-base': (
            'https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'
        ),
        'funnel-transformer/intermediate': (
            'https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'
        ),
        'funnel-transformer/intermediate-base': (
            'https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'
        ),
        'funnel-transformer/large': 'https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt',
        'funnel-transformer/large-base': 'https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt',
        'funnel-transformer/xlarge': 'https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt',
        'funnel-transformer/xlarge-base': (
            'https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json',
        'funnel-transformer/small-base': (
            'https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'
        ),
        'funnel-transformer/medium': 'https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json',
        'funnel-transformer/medium-base': (
            'https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'
        ),
        'funnel-transformer/intermediate': (
            'https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'
        ),
        'funnel-transformer/intermediate-base': (
            'https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'
        ),
        'funnel-transformer/large': 'https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json',
        'funnel-transformer/large-base': (
            'https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'
        ),
        'funnel-transformer/xlarge': 'https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json',
        'funnel-transformer/xlarge-base': (
            'https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'
        ),
    },
}
_a							=							{F"funnel-transformer/{name}": 5_12 for name in _model_names}
_a							=							{F"funnel-transformer/{name}": {'do_lower_case': True} for name in _model_names}




class  _lowerCAmelCase  (     lowercase       ):







 """simple docstring"""







 __UpperCAmelCase     : Optional[Any]       		=     VOCAB_FILES_NAMES
 __UpperCAmelCase     : Tuple       		=     PRETRAINED_VOCAB_FILES_MAP
 __UpperCAmelCase     : Union[str, Any]       		=     PRETRAINED_INIT_CONFIGURATION
 __UpperCAmelCase     : Optional[Any]       		=     FunnelTokenizer
 __UpperCAmelCase     : List[str]       		=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 __UpperCAmelCase     : int       		=     2


 def __init__(      self							:      Dict, UpperCAmelCase__							:      Dict=None, UpperCAmelCase__							:      Optional[int]=None, UpperCAmelCase__							:      Dict=True, UpperCAmelCase__							:      List[str]="<unk>", UpperCAmelCase__							:      Optional[Any]="<sep>", UpperCAmelCase__							:      Optional[Any]="<pad>", UpperCAmelCase__							:      Union[str, Any]="<cls>", UpperCAmelCase__							:      str="<mask>", UpperCAmelCase__							:      Optional[Any]="<s>", UpperCAmelCase__							:      Tuple="</s>", UpperCAmelCase__							:      Union[str, Any]=True, UpperCAmelCase__							:      Optional[int]=True, UpperCAmelCase__							:      Optional[Any]=None, UpperCAmelCase__							:      Dict="##", **UpperCAmelCase__							:      List[str], ):
    super().__init__(
        UpperCAmelCase__, tokenizer_file=UpperCAmelCase__, do_lower_case=UpperCAmelCase__, unk_token=UpperCAmelCase__, sep_token=UpperCAmelCase__, pad_token=UpperCAmelCase__, cls_token=UpperCAmelCase__, mask_token=UpperCAmelCase__, bos_token=UpperCAmelCase__, eos_token=UpperCAmelCase__, clean_text=UpperCAmelCase__, tokenize_chinese_chars=UpperCAmelCase__, strip_accents=UpperCAmelCase__, wordpieces_prefix=UpperCAmelCase__, **UpperCAmelCase__, )

    __lowercase								=						json.loads(self.backend_tokenizer.normalizer.__getstate__()     )
    if (
        normalizer_state.get("lowercase", UpperCAmelCase__     ) != do_lower_case
        or normalizer_state.get("strip_accents", UpperCAmelCase__     ) != strip_accents
        or normalizer_state.get("handle_chinese_chars", UpperCAmelCase__     ) != tokenize_chinese_chars
    ):
       __lowercase								=						getattr(UpperCAmelCase__, normalizer_state.pop("type"     )     )
       __lowercase								=						do_lower_case
       __lowercase								=						strip_accents
       __lowercase								=						tokenize_chinese_chars
       __lowercase								=						normalizer_class(**UpperCAmelCase__     )

    __lowercase								=						do_lower_case


 def  _lowercase			(      self							:      Tuple, UpperCAmelCase__							:      Any, UpperCAmelCase__							:      Any=None     ):
    __lowercase								=						[self.cls_token_id] + token_ids_a + [self.sep_token_id]

    if token_ids_a:
       output += token_ids_a + [self.sep_token_id]

    return output


 def  _lowercase			(      self							:      str, UpperCAmelCase__							:      List[int], UpperCAmelCase__							:      Optional[List[int]] = None     ):
    __lowercase								=						[self.sep_token_id]
    __lowercase								=						[self.cls_token_id]
    if token_ids_a is None:
       return len(cls     ) * [self.cls_token_type_id] + len(token_ids_a + sep     ) * [0]
    return len(cls     ) * [self.cls_token_type_id] + len(token_ids_a + sep     ) * [0] + len(token_ids_a + sep     ) * [1]



 def  _lowercase			(      self							:      Optional[Any], UpperCAmelCase__							:      str, UpperCAmelCase__							:      Optional[str] = None     ):
    __lowercase								=						self._tokenizer.model.save(UpperCAmelCase__, name=UpperCAmelCase__     )
    return tuple(UpperCAmelCase__     )




