


import os
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils_fast import AddedToken, PreTrainedTokenizerFast
from ...utils import logging


_snake_case				=			logging.get_logger(__name__)

_snake_case				=			{"vocab_file": "spiece.model", "tokenizer_file": "tokenizer.json"}

_snake_case				=			{
    "vocab_file": {
        "TsinghuaAI/CPM-Generate": "https://huggingface.co/TsinghuaAI/CPM-Generate/resolve/main/spiece.model",
    },
    "tokenizer_file": {
        "TsinghuaAI/CPM-Generate": "https://huggingface.co/TsinghuaAI/CPM-Generate/resolve/main/tokenizer.json",
    },
}




class  A_ (			a_  ):







 """simple docstring"""





 def __init__(      self       :			Tuple							,     _a       :			int=None							,     _a       :			int=None							,     _a       :			Dict=False							,     _a       :			Any=True							,     _a       :			str=False							,     _a       :			str="<s>"							,     _a       :			str="</s>"							,     _a       :			Optional[int]="<unk>"							,     _a       :			List[Any]="<sep>"							,     _a       :			Optional[int]="<pad>"							,     _a       :			Optional[Any]="<cls>"							,     _a       :			List[str]="<mask>"							,     _a       :			Tuple=["<eop>", "<eod>"]							,     **_a       :			Optional[Any]							,     )     ->      Optional[int]:
      UpperCAmelCase    :					Union[str, Any]			=      AddedToken(_a							,     lstrip=_a							,     rstrip=_a					) if isinstance(_a							,     _a					) else mask_token

      super().__init__(
          vocab_file=_a							,     tokenizer_file=_a							,     do_lower_case=_a							,     remove_space=_a							,     keep_accents=_a							,     bos_token=_a							,     eos_token=_a							,     unk_token=_a							,     sep_token=_a							,     pad_token=_a							,     cls_token=_a							,     mask_token=_a							,     additional_special_tokens=_a							,     **_a							,     )

      UpperCAmelCase    :					Dict			=      3
      UpperCAmelCase    :					int			=      do_lower_case
      UpperCAmelCase    :					Union[str, Any]			=      remove_space
      UpperCAmelCase    :					str			=      keep_accents
      UpperCAmelCase    :					Union[str, Any]			=      vocab_file
      UpperCAmelCase    :					Union[str, Any]			=      False if not self.vocab_file else True

      try:
           import jieba
      except ModuleNotFoundError as error:
           raise error.__class__(
               "You need to install jieba to use CpmTokenizer or CpmTokenizerFast. "
               "See https://pypi.org/project/jieba/ for installation."					)
      UpperCAmelCase    :					int			=      jieba
      UpperCAmelCase    :					str			=      str.maketrans(" \n"							,     "\u2582\u2583"					)
 def 	_UpperCamelCase     (      self       :			List[Any]							,     _a       :			List[int]							,     _a       :			Optional[List[int]] = None					)     ->      List[int]:
      UpperCAmelCase    :					List[Any]			=      [self.sep_token_id]
      UpperCAmelCase    :					Optional[Any]			=      [self.cls_token_id]
      if token_ids_a is None:
           return token_ids_a + sep + cls
      return token_ids_a + sep + token_ids_a + sep + cls
 def 	_UpperCamelCase     (      self       :			int							,     _a       :			List[int]							,     _a       :			Optional[List[int]] = None					)     ->      List[int]:
      UpperCAmelCase    :					Union[str, Any]			=      [self.sep_token_id]
      UpperCAmelCase    :					Union[str, Any]			=      [2]

      if token_ids_a is None:
           return len(token_ids_a + sep					) * [0] + cls_segment_id
      return len(token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1] + cls_segment_id
 def 	_UpperCamelCase     (      self       :			Union[str, Any]							,     _a       :			str							,     _a       :			Optional[str] = None					)     ->      Tuple[str]:
      if not self.can_save_slow_tokenizer:
           raise ValueError(
               "Your fast tokenizer does not have the necessary information to save the vocabulary for a slow "
               "tokenizer."					)

      if not os.path.isdir(_a					):
           logger.error(f'Vocabulary path ({save_directory}) should be a directory'					)
           return
      UpperCAmelCase    :					Optional[Any]			=      os.path.join(
          _a							,     (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]					)

      if os.path.abspath(self.vocab_file					) != os.path.abspath(_a					):
           copyfile(self.vocab_file							,     _a					)

      return (out_vocab_file,)
 def 	_UpperCamelCase     (      self       :			Dict							,     _a       :			int							,     *_a       :			int							,     **_a       :			Optional[Any]					)     ->      Union[str, Any]:
      UpperCAmelCase    :					Optional[int]			=      [
          " ".join([x.translate(self.translator					) for x in self.jieba.cut(_a							,     cut_all=_a					)]					)
          for text in batch_text_or_text_pairs
      ]
      return super()._batch_encode_plus(_a							,     *_a							,     **_a					)

 def 	_UpperCamelCase     (      self       :			Optional[Any]							,     *_a       :			Optional[Any]							,     **_a       :			List[str]					)     ->      Tuple:
      UpperCAmelCase    :					str			=      super()._decode(*_a							,     **_a					)
      UpperCAmelCase    :					str			=      text.replace(" "							,     ""					).replace("\u2582"							,     " "					).replace("\u2583"							,     "\n"					)
      return text







from __future__ import annotations

import sys







def 	A (		A__		,		A__			):
     # base cases
     if abs(A__			) == 1:
          return a, 0
     elif abs(A__			) == 1:
          return 0, b

     UpperCAmelCase	,			UpperCAmelCase    :					Any			=      a, b
     UpperCAmelCase	,			UpperCAmelCase    :					List[Any]			=      1, 0
     UpperCAmelCase	,			UpperCAmelCase    :					Union[str, Any]			=      0, 1

     while remainder != 0:
          UpperCAmelCase    :					Union[str, Any]			=      old_remainder // remainder
          UpperCAmelCase	,			UpperCAmelCase    :					Dict			=      remainder, old_remainder - quotient * remainder
          UpperCAmelCase	,			UpperCAmelCase    :					int			=      coeff_a, old_coeff_a - quotient * coeff_a
          UpperCAmelCase	,			UpperCAmelCase    :					Optional[Any]			=      coeff_b, old_coeff_b - quotient * coeff_b

     # sign correction for negative numbers
     if a < 0:
          UpperCAmelCase    :					Union[str, Any]			=      -old_coeff_a
     if b < 0:
          UpperCAmelCase    :					int			=      -old_coeff_b

     return old_coeff_a, old_coeff_b







def 	A (		):
     if len(sys.argv			) < 3:
          print("2 integer arguments required"			)
          return 1
     UpperCAmelCase    :					Union[str, Any]			=      int(sys.argv[1]			)
     UpperCAmelCase    :					Any			=      int(sys.argv[2]			)
     print(extended_euclidean_algorithm(A__		,		A__			)			)
     return 0


if __name__ == "__main__":
      raise SystemExit(main())



