
"""simple docstring"""



import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


UpperCamelCase__          =	logging.get_logger(__name__)

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

UpperCamelCase__          =	{
    'vocab_file': {
        'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt',
        'junnyu/roformer_chinese_base': 'https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt',
        'junnyu/roformer_chinese_char_small': (
            'https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_chinese_char_base': (
            'https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_small_discriminator': (
            'https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt'
        ),
        'junnyu/roformer_small_generator': (
            'https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt'
        ),
    }
}

UpperCamelCase__          =	{
    'junnyu/roformer_chinese_small': 15_36,
    'junnyu/roformer_chinese_base': 15_36,
    'junnyu/roformer_chinese_char_small': 5_12,
    'junnyu/roformer_chinese_char_base': 5_12,
    'junnyu/roformer_small_discriminator': 1_28,
    'junnyu/roformer_small_generator': 1_28,
}


UpperCamelCase__          =	{
    'junnyu/roformer_chinese_small': {'do_lower_case': True},
    'junnyu/roformer_chinese_base': {'do_lower_case': True},
    'junnyu/roformer_chinese_char_small': {'do_lower_case': True},
    'junnyu/roformer_chinese_char_base': {'do_lower_case': True},
    'junnyu/roformer_small_discriminator': {'do_lower_case': True},
    'junnyu/roformer_small_generator': {'do_lower_case': True},
}





class 				a			(					lowercase      ):
      UpperCamelCase							:   int           =     VOCAB_FILES_NAMES
      UpperCamelCase							:   Dict           =     PRETRAINED_VOCAB_FILES_MAP
      UpperCamelCase							:   Union[str, Any]           =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
      UpperCamelCase							:   Tuple           =     PRETRAINED_INIT_CONFIGURATION
      UpperCamelCase							:   Optional[int]           =     RoFormerTokenizer



      def __init__(   self     ,	UpperCamelCase_=None     ,	UpperCamelCase_=None     ,	UpperCamelCase_=True     ,	UpperCamelCase_="[UNK]"     ,	UpperCamelCase_="[SEP]"     ,	UpperCamelCase_="[PAD]"     ,	UpperCamelCase_="[CLS]"     ,	UpperCamelCase_="[MASK]"     ,	UpperCamelCase_=True     ,	UpperCamelCase_=None     ,	**UpperCamelCase_     ,	):
          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_     ,	tokenize_chinese_chars=UpperCamelCase_     ,	strip_accents=UpperCamelCase_     ,	**UpperCamelCase_     ,	)

          UpperCAmelCase__	:      Union[str, Any]     							=					json.loads(self.backend_tokenizer.normalizer.__getstate__()      )
          if (
              pre_tok_state.get('lowercase'     ,	UpperCamelCase_      ) != do_lower_case
              or pre_tok_state.get('strip_accents'     ,	UpperCamelCase_      ) != strip_accents
          ):
              UpperCAmelCase__	:      Any     							=					getattr(UpperCamelCase_     ,	pre_tok_state.pop('type'      )      )
              UpperCAmelCase__	:      str     							=					do_lower_case
              UpperCAmelCase__	:      Union[str, Any]     							=					strip_accents
              UpperCAmelCase__	:      Dict     							=					pre_tok_class(**UpperCamelCase_      )

          UpperCAmelCase__	:      Union[str, Any]     							=					do_lower_case



      def __getstate__(   self      ):
          UpperCAmelCase__	:      int     							=					self.__dict__.copy()
          UpperCAmelCase__	:      int     							=					BertPreTokenizer()
          return state



      def __setstate__(   self     ,	UpperCamelCase_      ):
          UpperCAmelCase__	:      Union[str, Any]     							=					d
          UpperCAmelCase__	:      List[str]     							=					self.__dict__['_tokenizer'].get_vocab()
          UpperCAmelCase__	:      List[Any]     							=					PreTokenizer.custom(JiebaPreTokenizer(UpperCamelCase_      )      )



      def  __snake_case							(   self     ,	UpperCamelCase_     ,	UpperCamelCase_=None      ):
          UpperCAmelCase__	:      List[Any]     							=					[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  __snake_case							(   self     ,	UpperCamelCase_     ,	UpperCamelCase_ = None      ):
          UpperCAmelCase__	:      int     							=					[self.sep_token_id]
          UpperCAmelCase__	:      Dict     							=					[self.cls_token_id]
          if token_ids_a is None:
              return len(cls + token_ids_a + sep      ) * [0]
          return len(cls + token_ids_a + sep      ) * [0] + len(token_ids_a + sep      ) * [1]



      def  __snake_case							(   self     ,	UpperCamelCase_     ,	UpperCamelCase_ = None      ):
          UpperCAmelCase__	:      Any     							=					self._tokenizer.model.save(UpperCamelCase_     ,	name=UpperCamelCase_      )
          return tuple(UpperCamelCase_      )



      def  __snake_case							(   self     ,	UpperCamelCase_     ,	UpperCamelCase_=None     ,	UpperCamelCase_=None     ,	UpperCamelCase_=False     ,	**UpperCamelCase_     ,	):
          UpperCAmelCase__	:      int     							=					BertPreTokenizer()
          return super().save_pretrained(UpperCamelCase_     ,	UpperCamelCase_     ,	UpperCamelCase_     ,	UpperCamelCase_     ,	**UpperCamelCase_      )





'''simple docstring'''






# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


__UpperCAmelCase       							=				[
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]


def    _snake_case  (	A					,       A=None					,       A=None					,       A=None			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      True
							while ask_again:
														lowerCAmelCase__			  =      input(A			)
														try:
																					if default is not None and len(A			) == 0:
																												return default
																					return convert_value(A			) if convert_value is not None else result
														except Exception:
																					if error_message is not None:
																												print(A			)


def    _snake_case  (	A					,       A=[]					,       A=None					,       A=0			)		->       List[Any]:
							lowerCAmelCase__			  =      BulletMenu(A					,       A			)
							lowerCAmelCase__			  =      menu.run(default_choice=A			)
							return convert_value(A			) if convert_value is not None else result


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]			)


def    _snake_case  (	A			)		->       str:
							lowerCAmelCase__			  =      int(A			)
							return DynamoBackend(DYNAMO_BACKENDS[value]			).value


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]			)


def    _snake_case  (	A			)		->       List[str]:
							return {"yes": True, "no": False}[value.lower()]






class 						a__							(				argparse.RawDescriptionHelpFormatter    ):





							'''simple docstring'''






							def     __SCREAMING_SNAKE_CASE				(						self   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )			->				Dict:
														lowerCAmelCase__			  =      super()._format_usage(lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )
														lowerCAmelCase__			  =      usage.replace('''<command> [<args>] '''   ,       ''''''  )
														return usage