





'''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


_a   :					Dict           =       logging.get_logger(__name__)

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

_a   :					Optional[int]           =       {
    """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   :					List[str]           =       {
    """junnyu/roformer_chinese_small""": 1_5_3_6,
    """junnyu/roformer_chinese_base""": 1_5_3_6,
    """junnyu/roformer_chinese_char_small""": 5_1_2,
    """junnyu/roformer_chinese_char_base""": 5_1_2,
    """junnyu/roformer_small_discriminator""": 1_2_8,
    """junnyu/roformer_small_generator""": 1_2_8,
}


_a   :					Union[str, Any]           =       {
    """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        _UpperCAmelCase				(		lowerCAmelCase_  ):
		a  :  Optional[int]      =VOCAB_FILES_NAMES
		a  :  Optional[Any]      =PRETRAINED_VOCAB_FILES_MAP
		a  :  int      =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		a  :  Union[str, Any]      =PRETRAINED_INIT_CONFIGURATION
		a  :  List[Any]      =RoFormerTokenizer
		def __init__(    self,__SCREAMING_SNAKE_CASE=None,__SCREAMING_SNAKE_CASE=None,__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE="[UNK]",__SCREAMING_SNAKE_CASE="[SEP]",__SCREAMING_SNAKE_CASE="[PAD]",__SCREAMING_SNAKE_CASE="[CLS]",__SCREAMING_SNAKE_CASE="[MASK]",__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE=None,**__SCREAMING_SNAKE_CASE,):



					'''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,__SCREAMING_SNAKE_CASE     ):



					'''simple docstring'''

					__lowerCAmelCase   		=							d
					__lowerCAmelCase   		=							self.__dict__["""_tokenizer"""].get_vocab()
					__lowerCAmelCase   		=							PreTokenizer.custom(JiebaPreTokenizer(UpperCAmelCase_     )     )
		def     lowerCamelCase__     (    self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE=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,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE = 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,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE = None     ):



					'''simple docstring'''

					__lowerCAmelCase   		=							self._tokenizer.model.save(UpperCAmelCase_,name=UpperCAmelCase_     )
					return tuple(UpperCAmelCase_     )







		def     lowerCamelCase__     (    self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE=None,__SCREAMING_SNAKE_CASE=None,__SCREAMING_SNAKE_CASE=False,**__SCREAMING_SNAKE_CASE,):



					'''simple docstring'''

					__lowerCAmelCase   		=							BertPreTokenizer()
					return super().save_pretrained(UpperCAmelCase_,UpperCAmelCase_,UpperCAmelCase_,UpperCAmelCase_,**UpperCAmelCase_     )






'''simple docstring'''





def 							lowerCamelCase	(					_snake_case	:    list							):





    '''simple docstring'''


    if not isinstance(_snake_case  ,_snake_case							):
        raise ValueError("Input series is not valid, valid series - [2, 4, 6]"							)
    if len(_snake_case							) == 0:
        raise ValueError("Input list must be a non empty list"							)
    if len(_snake_case							) == 1:
        return True
    lowercase__									=    series[1] - series[0]
    for index in range(len(_snake_case							) - 1							):
        if series[index + 1] - series[index] != common_diff:
            return False
    return True




def 							lowerCamelCase	(					_snake_case	:    list							):





    '''simple docstring'''


    if not isinstance(_snake_case  ,_snake_case							):
        raise ValueError("Input series is not valid, valid series - [2, 4, 6]"							)
    if len(_snake_case							) == 0:
        raise ValueError("Input list must be a non empty list"							)
    lowercase__									=    0
    for val in series:
        answer += val
    return answer / len(_snake_case							)


if __name__ == "__main__":
 import doctest

 doctest.testmod()




