





'''simple docstring'''




import os
import unicodedata
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import SPIECE_UNDERLINE, logging


lowercase__    :      Tuple						=    logging.get_logger(__name__)

lowercase__    :      int						=    {'''vocab_file''': '''spiece.model'''}

lowercase__    :      List[Any]						=    {
    '''vocab_file''': {
        '''TsinghuaAI/CPM-Generate''': '''https://huggingface.co/TsinghuaAI/CPM-Generate/resolve/main/spiece.model''',
    }
}


class  SCREAMING_SNAKE_CASE    (a__							):


     def __init__(						self						,	_UpperCAmelCase						,	_UpperCAmelCase=False						,	_UpperCAmelCase=True						,	_UpperCAmelCase=False						,	_UpperCAmelCase="<s>"						,	_UpperCAmelCase="</s>"						,	_UpperCAmelCase="<unk>"						,	_UpperCAmelCase="<sep>"						,	_UpperCAmelCase="<pad>"						,	_UpperCAmelCase="<cls>"						,	_UpperCAmelCase="<mask>"						,	_UpperCAmelCase=["<eop>", "<eod>"]						,	_UpperCAmelCase = None						,	**_UpperCAmelCase						,	):

          '''simple docstring'''






          __A						: List[Any]      =       AddedToken(_UpperCAmelCase						,	lstrip=_UpperCAmelCase						,	rstrip=_UpperCAmelCase) if isinstance(_UpperCAmelCase						,	_UpperCAmelCase) else mask_token

          __A						: int      =       {} if sp_model_kwargs is None else sp_model_kwargs

          super().__init__(
              do_lower_case=_UpperCAmelCase						,	remove_space=_UpperCAmelCase						,	keep_accents=_UpperCAmelCase						,	bos_token=_UpperCAmelCase						,	eos_token=_UpperCAmelCase						,	unk_token=_UpperCAmelCase						,	sep_token=_UpperCAmelCase						,	pad_token=_UpperCAmelCase						,	cls_token=_UpperCAmelCase						,	mask_token=_UpperCAmelCase						,	additional_special_tokens=_UpperCAmelCase						,	sp_model_kwargs=self.sp_model_kwargs						,	**_UpperCAmelCase						,	)

          __A						: int      =       3

          __A						: int      =       do_lower_case
          __A						: Union[str, Any]      =       remove_space
          __A						: Optional[Any]      =       keep_accents
          __A						: Dict      =       vocab_file

          __A						: List[Any]      =       spm.SentencePieceProcessor(**self.sp_model_kwargs)
          self.sp_model.Load(_UpperCAmelCase)

          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.')
          __A						: Optional[Any]      =       jieba
          __A						: str      =       str.maketrans(' \n'						,	'\u2582\u2583')


     @property
     # Copied from transformers.models.xlnet.tokenization_xlnet.XLNetTokenizer.vocab_size
     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          return len(self.sp_model)


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          __A						: Optional[int]      =       {self.convert_ids_to_tokens(_UpperCAmelCase): i for i in range(self.vocab_size)}
          vocab.update(self.added_tokens_encoder)
          return vocab


     def __getstate__(						self):

          '''simple docstring'''






          __A						: Optional[Any]      =       self.__dict__.copy()
          __A						: Optional[int]      =       None
          return state


     def __setstate__(						self						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: str      =       d

          # for backward compatibility
          if not hasattr(self						,	'sp_model_kwargs'):
               __A						: Optional[int]      =       {}

          __A						: Any      =       spm.SentencePieceProcessor(**self.sp_model_kwargs)
          self.sp_model.Load(self.vocab_file)


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase):

          '''simple docstring'''






          if self.remove_space:
               __A						: Any      =       ' '.join(inputs.strip().split())
          else:
               __A						: Dict      =       inputs
          __A						: Any      =       outputs.replace('``'						,	'"').replace('\'\''						,	'"')

          if not self.keep_accents:
               __A						: List[str]      =       unicodedata.normalize('NFKD'						,	_UpperCAmelCase)
               __A						: Optional[Any]      =       ''.join([c for c in outputs if not unicodedata.combining(_UpperCAmelCase)])
          if self.do_lower_case:
               __A						: Optional[int]      =       outputs.lower()

          return outputs


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: List[str]      =       self.preprocess_text(_UpperCAmelCase)
          __A						: Optional[Any]      =       self.sp_model.encode(_UpperCAmelCase						,	out_type=_UpperCAmelCase)
          __A						: List[str]      =       []
          for piece in pieces:
               if len(_UpperCAmelCase) > 1 and piece[-1] == str(',') and piece[-2].isdigit():
                    __A						: str      =       self.sp_model.EncodeAsPieces(piece[:-1].replace(_UpperCAmelCase						,	''))
                    if piece[0] != SPIECE_UNDERLINE and cur_pieces[0][0] == SPIECE_UNDERLINE:
                         if len(cur_pieces[0]) == 1:
                              __A						: Tuple      =       cur_pieces[1:]
                         else:
                              __A						: List[Any]      =       cur_pieces[0][1:]
                    cur_pieces.append(piece[-1])
                    new_pieces.extend(_UpperCAmelCase)
               else:
                    new_pieces.append(_UpperCAmelCase)

          return new_pieces


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase):

          '''simple docstring'''






          return self.sp_model.PieceToId(_UpperCAmelCase)


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase):

          '''simple docstring'''






          return self.sp_model.IdToPiece(_UpperCAmelCase)


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase):

          '''simple docstring'''






          __A						: Any      =       ''.join(_UpperCAmelCase).replace(_UpperCAmelCase						,	' ').strip()
          return out_string


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase = None):

          '''simple docstring'''






          __A						: int      =       [self.sep_token_id]
          __A						: str      =       [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 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase = None						,	_UpperCAmelCase = False):

          '''simple docstring'''






          if already_has_special_tokens:
               return super().get_special_tokens_mask(
                   token_ids_a=_UpperCAmelCase						,	token_ids_a=_UpperCAmelCase						,	already_has_special_tokens=_UpperCAmelCase)

          if token_ids_a is not None:
               return ([0] * len(_UpperCAmelCase)) + [1] + ([0] * len(_UpperCAmelCase)) + [1, 1]
          return ([0] * len(_UpperCAmelCase)) + [1, 1]


     def 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase = None):

          '''simple docstring'''






          __A						: Optional[Any]      =       [self.sep_token_id]
          __A						: Tuple      =       [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 							SCREAMING_SNAKE_CASE  (						self						,	_UpperCAmelCase						,	_UpperCAmelCase = None):

          '''simple docstring'''






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

          if os.path.abspath(self.vocab_file) != os.path.abspath(_UpperCAmelCase) and os.path.isfile(self.vocab_file):
               copyfile(self.vocab_file						,	_UpperCAmelCase)
          elif not os.path.isfile(self.vocab_file):
               with open(_UpperCAmelCase						,	'wb') as fi:
                    __A						: List[str]      =       self.sp_model.serialized_model_proto()
                    fi.write(_UpperCAmelCase)

          return (out_vocab_file,)


     def 							SCREAMING_SNAKE_CASE  (						self						,	*_UpperCAmelCase						,	**_UpperCAmelCase):

          '''simple docstring'''






          __A						: str      =       super()._decode(*_UpperCAmelCase						,	**_UpperCAmelCase)
          __A						: Optional[Any]      =       text.replace(' '						,	'').replace('\u2582'						,	' ').replace('\u2583'						,	'\n')
          return text






'''simple docstring'''




import math

import qiskit






def        _lowerCAmelCase			(  __snake_case  : int = 1 ,							__snake_case  : int = 1 ,							__snake_case  : int = 1			)     ->     qiskit.result.counts.Counts:
     if (
         isinstance(__snake_case ,							__snake_case			)
         or isinstance(__snake_case ,							__snake_case			)
         or isinstance(__snake_case ,							__snake_case			)
     ):
          raise TypeError('inputs must be integers.'			)

     if (input_a < 0) or (input_a < 0) or (carry_in < 0):
          raise ValueError('inputs must be positive.'			)

     if (
         (math.floor(__snake_case			) != input_a)
         or (math.floor(__snake_case			) != input_a)
         or (math.floor(__snake_case			) != carry_in)
     ):
          raise ValueError('inputs must be exact integers.'			)

     if (input_a > 2) or (input_a > 2) or (carry_in > 2):
          raise ValueError('inputs must be less or equal to 2.'			)

     # build registers
     __A						: int      =       qiskit.QuantumRegister(4 ,							'qr'			)
     __A						: Optional[int]      =       qiskit.ClassicalRegister(2 ,							'cr'			)
     # list the entries
     __A						: Union[str, Any]      =       [input_a, input_a, carry_in]

     __A						: Dict      =       qiskit.QuantumCircuit(__snake_case ,							__snake_case			)

     for i in range(0 ,							3			):
          if entry[i] == 2:
               quantum_circuit.h(__snake_case			)  # for hadamard entries
          elif entry[i] == 1:
               quantum_circuit.x(__snake_case			)  # for 1 entries
          elif entry[i] == 0:
               quantum_circuit.i(__snake_case			)  # for 0 entries

    # build the circuit
     quantum_circuit.ccx(0 ,							1 ,							3			)  # ccx = toffoli gate
     quantum_circuit.cx(0 ,							1			)
     quantum_circuit.ccx(1 ,							2 ,							3			)
     quantum_circuit.cx(1 ,							2			)
     quantum_circuit.cx(0 ,							1			)

     quantum_circuit.measure([2, 3] ,							__snake_case			)  # measure the last two qbits

     __A						: str      =       qiskit.Aer.get_backend('aer_simulator'			)
     __A						: Any      =       qiskit.execute(__snake_case ,							__snake_case ,							shots=10_00			)

     return job.result().get_counts(__snake_case			)


if __name__ == "__main__":
  print(f"""Total sum count for state is: {quantum_full_adder(1, 1, 1)}""")