



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_			=					logging.get_logger(__name__)

a_			=					{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

a_			=					{
    """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_			=					{
    """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_			=					{
    """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  __lowerCAmelCase     (	lowerCAmelCase__   ):
 lowerCAmelCase__       					=  VOCAB_FILES_NAMES
 lowerCAmelCase__       					=  PRETRAINED_VOCAB_FILES_MAP
 lowerCAmelCase__       					=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
 lowerCAmelCase__       					=  PRETRAINED_INIT_CONFIGURATION
 lowerCAmelCase__       					=  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	,				):



    '''simple docstring'''
    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	,				)

    __lowerCamelCase													=    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
    ):
       __lowerCamelCase													=    getattr(__UpperCAmelCase	,				pre_tok_state.pop('''type'''				)				)
       __lowerCamelCase													=    do_lower_case
       __lowerCamelCase													=    strip_accents
       __lowerCamelCase													=    pre_tok_class(**__UpperCAmelCase				)

    __lowerCamelCase													=    do_lower_case




 def __getstate__(						self				):



    '''simple docstring'''
    __lowerCamelCase													=    self.__dict__.copy()
    __lowerCamelCase													=    BertPreTokenizer()
    return state




 def __setstate__(						self	,				__UpperCAmelCase				):



    '''simple docstring'''
    __lowerCamelCase													=    d
    __lowerCamelCase													=    self.__dict__['''_tokenizer'''].get_vocab()
    __lowerCamelCase													=    PreTokenizer.custom(JiebaPreTokenizer(__UpperCAmelCase				)				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase=None				):



    '''simple docstring'''
    __lowerCamelCase													=    [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        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None				):



    '''simple docstring'''
    __lowerCamelCase													=    [self.sep_token_id]
    __lowerCamelCase													=    [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        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase = None				):



    '''simple docstring'''
    __lowerCamelCase													=    self._tokenizer.model.save(__UpperCAmelCase	,				name=__UpperCAmelCase				)
    return tuple(__UpperCAmelCase				)




 def        lowerCamelCase      (						self	,				__UpperCAmelCase	,				__UpperCAmelCase=None	,				__UpperCAmelCase=None	,				__UpperCAmelCase=False	,				**__UpperCAmelCase	,				):



    '''simple docstring'''
    __lowerCamelCase													=    BertPreTokenizer()
    return super().save_pretrained(__UpperCAmelCase	,				__UpperCAmelCase	,				__UpperCAmelCase	,				__UpperCAmelCase	,				**__UpperCAmelCase				)











from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


a_			=					logging.get_logger(__name__)

a_			=					{
    """sail/poolformer_s12""": """https://huggingface.co/sail/poolformer_s12/resolve/main/config.json""",
    # See all PoolFormer models at https://huggingface.co/models?filter=poolformer
}



class  __lowerCAmelCase     (	lowerCAmelCase__   ):
 lowerCAmelCase__       					=  """poolformer"""




 def __init__(						self	,				__UpperCAmelCase=3	,				__UpperCAmelCase=16	,				__UpperCAmelCase=16	,				__UpperCAmelCase=3	,				__UpperCAmelCase=4.0	,				__UpperCAmelCase=[2, 2, 6, 2]	,				__UpperCAmelCase=[64, 128, 320, 512]	,				__UpperCAmelCase=[7, 3, 3, 3]	,				__UpperCAmelCase=[4, 2, 2, 2]	,				__UpperCAmelCase=[2, 1, 1, 1]	,				__UpperCAmelCase=4	,				__UpperCAmelCase=0.0	,				__UpperCAmelCase="gelu"	,				__UpperCAmelCase=True	,				__UpperCAmelCase=1E-5	,				__UpperCAmelCase=0.02	,				**__UpperCAmelCase	,				):



    '''simple docstring'''
    __lowerCamelCase													=    num_channels
    __lowerCamelCase													=    patch_size
    __lowerCamelCase													=    stride
    __lowerCamelCase													=    padding
    __lowerCamelCase													=    pool_size
    __lowerCamelCase													=    hidden_sizes
    __lowerCamelCase													=    mlp_ratio
    __lowerCamelCase													=    depths
    __lowerCamelCase													=    patch_sizes
    __lowerCamelCase													=    strides
    __lowerCamelCase													=    num_encoder_blocks
    __lowerCamelCase													=    drop_path_rate
    __lowerCamelCase													=    hidden_act
    __lowerCamelCase													=    use_layer_scale
    __lowerCamelCase													=    layer_scale_init_value
    __lowerCamelCase													=    initializer_range
    super().__init__(**__UpperCAmelCase				)



class  __lowerCAmelCase     (	lowerCAmelCase__   ):
 lowerCAmelCase__       					=  version.parse("""1.11"""   )




 @property
 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    return OrderedDict(
        [
            ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
        ]				)




 @property
 def        lowerCamelCase      (						self				):



    '''simple docstring'''
    return 2E-3






