'''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 :						List[Any]							= logging.get_logger(__name__)

_a :						Union[str, Any]							= {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

_a :						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 :						Union[str, Any]							= {
    "junnyu/roformer_chinese_small": 1536,
    "junnyu/roformer_chinese_base": 1536,
    "junnyu/roformer_chinese_char_small": 512,
    "junnyu/roformer_chinese_char_base": 512,
    "junnyu/roformer_small_discriminator": 128,
    "junnyu/roformer_small_generator": 128,
}


_a :						Optional[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 		__A							(A_ ):
       snake_case							:Any					     =       VOCAB_FILES_NAMES
       snake_case							:List[Any]					     =       PRETRAINED_VOCAB_FILES_MAP
       snake_case							:Optional[Any]					     =       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       snake_case							:Optional[Any]					     =       PRETRAINED_INIT_CONFIGURATION
       snake_case							:Dict					     =       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	:					Tuple												=		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	:					str												=		getattr(UpperCamelCase_					,  pre_tok_state.pop("type"   )   )
                     __UpperCAmelCase	:					List[str]												=		do_lower_case
                     __UpperCAmelCase	:					str												=		strip_accents
                     __UpperCAmelCase	:					Optional[Any]												=		pre_tok_class(**UpperCamelCase_   )

              __UpperCAmelCase	:					Any												=		do_lower_case






       def __getstate__(   self   ):
              __UpperCAmelCase	:					Any												=		self.__dict__.copy()
              __UpperCAmelCase	:					Dict												=		BertPreTokenizer()
              return state






       def __setstate__(   self					,  UpperCamelCase_   ):
              __UpperCAmelCase	:					Tuple												=		d
              __UpperCAmelCase	:					List[Any]												=		self.__dict__["""_tokenizer"""].get_vocab()
              __UpperCAmelCase	:					Optional[int]												=		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	:					List[Any]												=		[self.sep_token_id]
              __UpperCAmelCase	:					Optional[Any]												=		[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	:					Dict												=		self._tokenizer.model.save(UpperCamelCase_					,  name=UpperCamelCase_   )
              return tuple(UpperCamelCase_   )







       def       _snake_case    (   self					,  UpperCamelCase_					,  UpperCamelCase_=None					,  UpperCamelCase_=None					,  UpperCamelCase_=False					,  **UpperCamelCase_					,  ):
              __UpperCAmelCase	:					List[Any]												=		BertPreTokenizer()
              return super().save_pretrained(UpperCamelCase_					,  UpperCamelCase_					,  UpperCamelCase_					,  UpperCamelCase_					,  **UpperCamelCase_   )










"""simple docstring"""
def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      int						, __snake_case							:      int						, __snake_case							:      list[int]   ):




   """simple docstring"""







   if graph[path[curr_ind - 1]][next_ver] == 0:
      return False

   # 2. Validate that next vertex is not already in path
   return not any(vertex == next_ver for vertex in path   )

def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      list[int]						, __snake_case							:      int   ):




   """simple docstring"""







   if curr_ind == len(__snake_case   ):
      # return whether path exists between current and starting vertices
      return graph[path[curr_ind - 1]][path[0]] == 1

   # Recursive Step
   for next_ver in range(0						, len(__snake_case   )   ):
      if valid_connection(__snake_case						, __snake_case						, __snake_case						, __snake_case   ):
         # Insert current vertex  into path as next transition
         _lowerCamelCase	:					List[str]   =		next_ver
         # Validate created path
         if util_hamilton_cycle(__snake_case						, __snake_case						, curr_ind + 1   ):
            return True
         # Backtrack
         _lowerCamelCase	:					Tuple   =		-1
   return False





def 				_snake_case      (   __snake_case							:      list[list[int]]						, __snake_case							:      int = 0   ):




   """simple docstring"""







   _lowerCamelCase	:					Any   =		[-1] * (len(__snake_case   ) + 1)
   # initialize start and end of path with starting index
   _lowerCamelCase	:					Optional[int]   =		start_index
   # evaluate and if we find answer return path either return empty array
   return path if util_hamilton_cycle(__snake_case						, __snake_case						, 1   ) else []

