





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


a__: Dict							   =						logging.get_logger(__name__)

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

a__: Tuple							   =						{
    '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'
        ),
    }
}

a__: Union[str, Any]							   =						{
    'junnyu/roformer_chinese_small': 1_536,
    'junnyu/roformer_chinese_base': 1_536,
    'junnyu/roformer_chinese_char_small': 512,
    'junnyu/roformer_chinese_char_base': 512,
    'junnyu/roformer_small_discriminator': 128,
    'junnyu/roformer_small_generator': 128,
}


a__: int							   =						{
    '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        SCREAMING_SNAKE_CASE__					(		UpperCamelCase__ ):
 __SCREAMING_SNAKE_CASE							=      VOCAB_FILES_NAMES
 __SCREAMING_SNAKE_CASE							=      PRETRAINED_VOCAB_FILES_MAP
 __SCREAMING_SNAKE_CASE							=      PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 __SCREAMING_SNAKE_CASE							=      PRETRAINED_INIT_CONFIGURATION
 __SCREAMING_SNAKE_CASE							=      RoFormerTokenizer



 def __init__(				self,__lowerCamelCase=None,__lowerCamelCase=None,__lowerCamelCase=True,__lowerCamelCase="[UNK]",__lowerCamelCase="[SEP]",__lowerCamelCase="[PAD]",__lowerCamelCase="[CLS]",__lowerCamelCase="[MASK]",__lowerCamelCase=True,__lowerCamelCase=None,**__lowerCamelCase,):
        super().__init__(
            __lowerCamelCase,tokenizer_file=__lowerCamelCase,do_lower_case=__lowerCamelCase,unk_token=__lowerCamelCase,sep_token=__lowerCamelCase,pad_token=__lowerCamelCase,cls_token=__lowerCamelCase,mask_token=__lowerCamelCase,tokenize_chinese_chars=__lowerCamelCase,strip_accents=__lowerCamelCase,**__lowerCamelCase,)

        A__		   =		json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
        if (
            pre_tok_state.get('''lowercase''',__lowerCamelCase					) != do_lower_case
            or pre_tok_state.get('''strip_accents''',__lowerCamelCase					) != strip_accents
        ):
               A__		   =		getattr(__lowerCamelCase,pre_tok_state.pop('''type'''					)					)
               A__		   =		do_lower_case
               A__		   =		strip_accents
               A__		   =		pre_tok_class(**__lowerCamelCase					)

        A__		   =		do_lower_case



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



 def __setstate__(				self,__lowerCamelCase					):
        A__		   =		d
        A__		   =		self.__dict__['''_tokenizer'''].get_vocab()
        A__		   =		PreTokenizer.custom(JiebaPreTokenizer(__lowerCamelCase					)					)



 def 							UpperCamelCase     (				self,__lowerCamelCase,__lowerCamelCase=None					):
        A__		   =		[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 							UpperCamelCase     (				self,__lowerCamelCase,__lowerCamelCase = None					):
        A__		   =		[self.sep_token_id]
        A__		   =		[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 							UpperCamelCase     (				self,__lowerCamelCase,__lowerCamelCase = None					):
        A__		   =		self._tokenizer.model.save(__lowerCamelCase,name=__lowerCamelCase					)
        return tuple(__lowerCamelCase					)




 def 							UpperCamelCase     (				self,__lowerCamelCase,__lowerCamelCase=None,__lowerCamelCase=None,__lowerCamelCase=False,**__lowerCamelCase,):
        A__		   =		BertPreTokenizer()
        return super().save_pretrained(__lowerCamelCase,__lowerCamelCase,__lowerCamelCase,__lowerCamelCase,**__lowerCamelCase					)












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


a__: str							   =						{
    'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a__: Union[str, Any]							   =						[
           'MEGA_PRETRAINED_MODEL_ARCHIVE_LIST',
           'MegaForCausalLM',
           'MegaForMaskedLM',
           'MegaForMultipleChoice',
           'MegaForQuestionAnswering',
           'MegaForSequenceClassification',
           'MegaForTokenClassification',
           'MegaModel',
           'MegaPreTrainedModel',
       ]

if TYPE_CHECKING:
       from .configuration_mega import MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP, MegaConfig, MegaOnnxConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_mega import (
                  MEGA_PRETRAINED_MODEL_ARCHIVE_LIST,
                  MegaForCausalLM,
                  MegaForMaskedLM,
                  MegaForMultipleChoice,
                  MegaForQuestionAnswering,
                  MegaForSequenceClassification,
                  MegaForTokenClassification,
                  MegaModel,
                  MegaPreTrainedModel,
              )

else:
       import sys

       a__: Union[str, Any]							   =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





