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

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


if is_sentencepiece_available():
   from .tokenization_big_bird import BigBirdTokenizer
else:
   __lowerCamelCase				=			None

__lowerCamelCase				=			logging.get_logger(__name__)
__lowerCamelCase				=			{"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

__lowerCamelCase				=			{
    """vocab_file""": {
        """google/bigbird-roberta-base""": """https://huggingface.co/google/bigbird-roberta-base/resolve/main/spiece.model""",
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/spiece.model"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/spiece.model"""
        ),
    },
    """tokenizer_file""": {
        """google/bigbird-roberta-base""": (
            """https://huggingface.co/google/bigbird-roberta-base/resolve/main/tokenizer.json"""
        ),
        """google/bigbird-roberta-large""": (
            """https://huggingface.co/google/bigbird-roberta-large/resolve/main/tokenizer.json"""
        ),
        """google/bigbird-base-trivia-itc""": (
            """https://huggingface.co/google/bigbird-base-trivia-itc/resolve/main/tokenizer.json"""
        ),
    },
}

__lowerCamelCase				=			{
    """google/bigbird-roberta-base""": 40_96,
    """google/bigbird-roberta-large""": 40_96,
    """google/bigbird-base-trivia-itc""": 40_96,
}


__lowerCamelCase				=			"""▁"""






class     UpperCAmelCase						(		A_					):
   A__   :						List[Any]			=	VOCAB_FILES_NAMES
   A__   :						List[str]			=	PRETRAINED_VOCAB_FILES_MAP
   A__   :						Any			=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   A__   :						Union[str, Any]			=	BigBirdTokenizer
   A__   :						Optional[int]			=	["input_ids", "attention_mask"]
   A__   :						List[int]			=	[]



   def __init__(self						:   int       ,		snake_case__						:   str=None       ,		snake_case__						:   Optional[int]=None       ,		snake_case__						:   Dict="<unk>"       ,		snake_case__						:   Union[str, Any]="<s>"       ,		snake_case__						:   str="</s>"       ,		snake_case__						:   Optional[Any]="<pad>"       ,		snake_case__						:   Union[str, Any]="[SEP]"       ,		snake_case__						:   Optional[int]="[MASK]"       ,		snake_case__						:   Dict="[CLS]"       ,		**snake_case__						:   Optional[int]       ,		)						->      List[Any]:


          '''simple docstring'''


          snake_case			:  Dict     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else bos_token
          snake_case			:  Dict     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else eos_token
          snake_case			:  Dict     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else unk_token
          snake_case			:  Union[str, Any]     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else pad_token
          snake_case			:  Union[str, Any]     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else cls_token
          snake_case			:  List[Any]     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else sep_token

          # Mask token behave like a normal word, i.e. include the space before it
          snake_case			:  Optional[int]     							= AddedToken(snake_case__       ,		lstrip=snake_case__       ,		rstrip=snake_case__					) if isinstance(snake_case__       ,		snake_case__					) else mask_token

          super().__init__(
              snake_case__       ,		tokenizer_file=snake_case__       ,		bos_token=snake_case__       ,		eos_token=snake_case__       ,		unk_token=snake_case__       ,		sep_token=snake_case__       ,		pad_token=snake_case__       ,		cls_token=snake_case__       ,		mask_token=snake_case__       ,		**snake_case__       ,		)

          snake_case			:  Dict     							= vocab_file
          snake_case			:  Dict     							= False if not self.vocab_file else True



   def 							_SCREAMING_SNAKE_CASE  (self						:   int       ,		snake_case__						:   List[int]       ,		snake_case__						:   Optional[List[int]] = None					)						->      List[int]:


          '''simple docstring'''


          snake_case			:  Optional[int]     							= [self.sep_token_id]
          snake_case			:  str     							= [self.cls_token_id]
          if token_ids_a is None:
                 return cls + token_ids_a + sep
          return cls + token_ids_a + sep + token_ids_a + sep



   def 							_SCREAMING_SNAKE_CASE  (self						:   int       ,		snake_case__						:   List[int]       ,		snake_case__						:   Optional[List[int]] = None       ,		snake_case__						:   bool = False					)						->      List[int]:


          '''simple docstring'''


          if already_has_special_tokens:
                 if token_ids_a is not None:
                        raise ValueError(
                            "You should not supply a second sequence if the provided sequence of "
                            "ids is already formatted with special tokens for the model."					)
                 return [1 if x in [self.sep_token_id, self.cls_token_id] else 0 for x in token_ids_a]

          if token_ids_a is None:
                 return [1] + ([0] * len(snake_case__					)) + [1]
          return [1] + ([0] * len(snake_case__					)) + [1] + ([0] * len(snake_case__					)) + [1]



   def 							_SCREAMING_SNAKE_CASE  (self						:   Any       ,		snake_case__						:   List[int]       ,		snake_case__						:   Optional[List[int]] = None					)						->      List[int]:


          '''simple docstring'''


          snake_case			:  Optional[int]     							= [self.sep_token_id]
          snake_case			:  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 							_SCREAMING_SNAKE_CASE  (self						:   Union[str, Any]       ,		snake_case__						:   str       ,		snake_case__						:   Optional[str] = None					)						->      Tuple[str]:


          '''simple docstring'''


          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(snake_case__					):
                 logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""					)
                 return
          snake_case			:  Tuple     							= os.path.join(
              snake_case__       ,		(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]					)

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

          return (out_vocab_file,)







import qiskit


def      UpperCamelCase   (       __lowerCamelCase	:					int							,   __lowerCamelCase	:					int       ):
       snake_case			:  int     							= qiskit.Aer.get_backend("aer_simulator"       )

       # Create a Quantum Circuit acting on the q register
       snake_case			:  Dict     							= qiskit.QuantumCircuit(__lowerCamelCase							,   __lowerCamelCase       )

       # Apply X (NOT) Gate to Qubits 0 & 1
       circuit.x(0       )
       circuit.x(1       )

       # Map the quantum measurement to the classical bits
       circuit.measure([0, 1]							,   [0, 1]       )

       # Execute the circuit on the qasm simulator
       snake_case			:  Dict     							= qiskit.execute(__lowerCamelCase							,   __lowerCamelCase							,   shots=1000       )

       # Return the histogram data of the results of the experiment.
       return job.result().get_counts(__lowerCamelCase       )


if __name__ == "__main__":
   __lowerCamelCase				=			single_qubit_measure(2, 2)
   print(F'Total count for various states are: {counts}')





