





"""simple docstring"""
import os
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 logging


lowerCamelCase_								=		logging.get_logger(__name__)

lowerCamelCase_								=		"▁"

lowerCamelCase_								=		{"vocab_file": "sentencepiece.bpe.model"}

lowerCamelCase_								=		{
    "vocab_file": {
        "xlm-roberta-base": "https://huggingface.co/xlm-roberta-base/resolve/main/sentencepiece.bpe.model",
        "xlm-roberta-large": "https://huggingface.co/xlm-roberta-large/resolve/main/sentencepiece.bpe.model",
        "xlm-roberta-large-finetuned-conll02-dutch": (
            "https://huggingface.co/xlm-roberta-large-finetuned-conll02-dutch/resolve/main/sentencepiece.bpe.model"
        ),
        "xlm-roberta-large-finetuned-conll02-spanish": (
            "https://huggingface.co/xlm-roberta-large-finetuned-conll02-spanish/resolve/main/sentencepiece.bpe.model"
        ),
        "xlm-roberta-large-finetuned-conll03-english": (
            "https://huggingface.co/xlm-roberta-large-finetuned-conll03-english/resolve/main/sentencepiece.bpe.model"
        ),
        "xlm-roberta-large-finetuned-conll03-german": (
            "https://huggingface.co/xlm-roberta-large-finetuned-conll03-german/resolve/main/sentencepiece.bpe.model"
        ),
    }
}

lowerCamelCase_								=		{
    "xlm-roberta-base": 5_1_2,
    "xlm-roberta-large": 5_1_2,
    "xlm-roberta-large-finetuned-conll02-dutch": 5_1_2,
    "xlm-roberta-large-finetuned-conll02-spanish": 5_1_2,
    "xlm-roberta-large-finetuned-conll03-english": 5_1_2,
    "xlm-roberta-large-finetuned-conll03-german": 5_1_2,
}






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Any							=  VOCAB_FILES_NAMES
       SCREAMING_SNAKE_CASE_   :      Union[str, Any]							=  PRETRAINED_VOCAB_FILES_MAP
       SCREAMING_SNAKE_CASE_   :      List[str]							=  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       SCREAMING_SNAKE_CASE_   :      List[str]							=  ['''input_ids''', '''attention_mask''']




       def __init__(						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__="<s>"		,SCREAMING_SNAKE_CASE__="</s>"		,SCREAMING_SNAKE_CASE__="</s>"		,SCREAMING_SNAKE_CASE__="<s>"		,SCREAMING_SNAKE_CASE__="<unk>"		,SCREAMING_SNAKE_CASE__="<pad>"		,SCREAMING_SNAKE_CASE__="<mask>"		,SCREAMING_SNAKE_CASE__ = None		,**SCREAMING_SNAKE_CASE__		,)			->      None:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Tuple						=  AddedToken(SCREAMING_SNAKE_CASE__		,lstrip=SCREAMING_SNAKE_CASE__		,rstrip=SCREAMING_SNAKE_CASE__							) if isinstance(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							) else mask_token

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

             super().__init__(
                 bos_token=SCREAMING_SNAKE_CASE__		,eos_token=SCREAMING_SNAKE_CASE__		,unk_token=SCREAMING_SNAKE_CASE__		,sep_token=SCREAMING_SNAKE_CASE__		,cls_token=SCREAMING_SNAKE_CASE__		,pad_token=SCREAMING_SNAKE_CASE__		,mask_token=SCREAMING_SNAKE_CASE__		,sp_model_kwargs=self.sp_model_kwargs		,**SCREAMING_SNAKE_CASE__		,)

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  spm.SentencePieceProcessor(**self.sp_model_kwargs							)
             self.sp_model.Load(str(SCREAMING_SNAKE_CASE__							)							)
             __SCREAMING_SNAKE_CASE   :int						=  vocab_file

             # Original fairseq vocab and spm vocab must be "aligned":
             # Vocab    |    0    |    1    |   2    |    3    |  4  |  5  |  6  |   7   |   8   |  9
             # -------- | ------- | ------- | ------ | ------- | --- | --- | --- | ----- | ----- | ----
             # fairseq  | '<s>'   | '<pad>' | '</s>' | '<unk>' | ',' | '.' | '▁' | 's'   | '▁de' | '-'
             # spm      | '<unk>' | '<s>'   | '</s>' | ','     | '.' | '▁' | 's' | '▁de' | '-'   | '▁a'

             # Mimic fairseq token-to-id alignment for the first 4 token
             __SCREAMING_SNAKE_CASE   :Any						=  {'''<s>''': 0, '''<pad>''': 1, '''</s>''': 2, '''<unk>''': 3}

             # The first "real" token "," has position 4 in the original fairseq vocab and position 3 in the spm vocab
             __SCREAMING_SNAKE_CASE   :Any						=  1

             __SCREAMING_SNAKE_CASE   :Dict						=  len(self.sp_model							) + self.fairseq_offset
             __SCREAMING_SNAKE_CASE   :int						=  {v: k for k, v in self.fairseq_tokens_to_ids.items()}




       def __getstate__(						self							)			->      str:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Dict						=  self.__dict__.copy()
             __SCREAMING_SNAKE_CASE   :str						=  None
             __SCREAMING_SNAKE_CASE   :List[str]						=  self.sp_model.serialized_model_proto()
             return state




       def __setstate__(						self		,SCREAMING_SNAKE_CASE__							)			->      int:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  d

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

             __SCREAMING_SNAKE_CASE   :str						=  spm.SentencePieceProcessor(**self.sp_model_kwargs							)
             self.sp_model.LoadFromSerializedProto(self.sp_model_proto							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = None							)			->      List[int]:





             """simple docstring"""






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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = None		,SCREAMING_SNAKE_CASE__ = False							)			->      List[int]:





             """simple docstring"""






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

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




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = None							)			->      List[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  [self.sep_token_id]
             __SCREAMING_SNAKE_CASE   :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 + sep + token_ids_a + sep							) * [0]




       @property
       def     _UpperCamelCase     (						self							)			->      str:





             """simple docstring"""






             return len(self.sp_model							) + self.fairseq_offset + 1  # Add the <mask> token




       def     _UpperCamelCase     (						self							)			->      Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  {self.convert_ids_to_tokens(SCREAMING_SNAKE_CASE__							): i for i in range(self.vocab_size							)}
             vocab.update(self.added_tokens_encoder							)
             return vocab




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__							)			->      List[str]:





             """simple docstring"""






             return self.sp_model.encode(SCREAMING_SNAKE_CASE__		,out_type=SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__							)			->      Optional[Any]:





             """simple docstring"""






             if token in self.fairseq_tokens_to_ids:
                   return self.fairseq_tokens_to_ids[token]
             __SCREAMING_SNAKE_CASE   :Tuple						=  self.sp_model.PieceToId(SCREAMING_SNAKE_CASE__							)

             # Need to return unknown token if the SP model returned 0
             return spm_id + self.fairseq_offset if spm_id else self.unk_token_id




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__							)			->      int:





             """simple docstring"""






             if index in self.fairseq_ids_to_tokens:
                   return self.fairseq_ids_to_tokens[index]
             return self.sp_model.IdToPiece(index - self.fairseq_offset							)




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__							)			->      Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :List[Any]						=  ''''''.join(SCREAMING_SNAKE_CASE__							).replace(SCREAMING_SNAKE_CASE__		,''' '''							).strip()
             return out_string




       def     _UpperCamelCase     (						self		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__ = None							)			->      Tuple[str]:





             """simple docstring"""






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

             if os.path.abspath(self.vocab_file							) != os.path.abspath(SCREAMING_SNAKE_CASE__							) and os.path.isfile(self.vocab_file							):
                   copyfile(self.vocab_file		,SCREAMING_SNAKE_CASE__							)
             elif not os.path.isfile(self.vocab_file							):
                   with open(SCREAMING_SNAKE_CASE__		,'''wb'''							) as fi:
                         __SCREAMING_SNAKE_CASE   :Any						=  self.sp_model.serialized_model_proto()
                         fi.write(SCREAMING_SNAKE_CASE__							)

             return (out_vocab_file,)






"""simple docstring"""
import qiskit



def      __lowerCamelCase   (							a_     :		int ,   a_     :		int							)			->      qiskit.result.counts.Counts:
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.Aer.get_backend('''aer_simulator'''							)

      # Create a Quantum Circuit acting on the q register
      __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  qiskit.QuantumCircuit(a_ ,   a_							)

      # 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
      __SCREAMING_SNAKE_CASE   :Tuple						=  qiskit.execute(a_ ,   a_ ,   shots=10_00							)

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


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