



'''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


UpperCamelCase__ :			Tuple												=				logging.get_logger(__name__)

UpperCamelCase__ :			Tuple												=				"""▁"""

UpperCamelCase__ :			Optional[Any]												=				{"""vocab_file""": """sentencepiece.bpe.model""", """monolingual_vocab_file""": """dict.txt"""}

UpperCamelCase__ :			List[Any]												=				{
    """vocab_file""": {
        """vinai/bartpho-syllable""": """https://huggingface.co/vinai/bartpho-syllable/resolve/main/sentencepiece.bpe.model""",
    },
    """monolingual_vocab_file""": {
        """vinai/bartpho-syllable""": """https://huggingface.co/vinai/bartpho-syllable/resolve/main/dict.txt""",
    },
}

UpperCamelCase__ :			Dict												=				{"""vinai/bartpho-syllable""": 10_24}






class 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Tuple    					=	VOCAB_FILES_NAMES
			_A   :	Optional[Any]    					=	PRETRAINED_VOCAB_FILES_MAP
			_A   :	Optional[Any]    					=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_A   :	Optional[int]    					=	["input_ids", "attention_mask"]

			def __init__(							self  :				Optional[int]							,  lowerCAmelCase__  :				int							,  lowerCAmelCase__  :				Optional[int]							,  lowerCAmelCase__  :				Optional[int]="<s>"							,  lowerCAmelCase__  :				Optional[Any]="</s>"							,  lowerCAmelCase__  :				Dict="</s>"							,  lowerCAmelCase__  :				Dict="<s>"							,  lowerCAmelCase__  :				Dict="<unk>"							,  lowerCAmelCase__  :				Dict="<pad>"							,  lowerCAmelCase__  :				Union[str, Any]="<mask>"							,  lowerCAmelCase__  :				Any = None							,  **lowerCAmelCase__  :				str							,  ):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	str					 =	AddedToken(UpperCamelCase__							,  lstrip=UpperCamelCase__							,  rstrip=UpperCamelCase__		) if isinstance(UpperCamelCase__							,  UpperCamelCase__		) else mask_token

					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	{} if sp_model_kwargs is None else sp_model_kwargs

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

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

					# Load the reduced vocab

					# Keep order of special tokens for backward compatibility
					__SCREAMING_SNAKE_CASE :	Any					 =	{}
					__SCREAMING_SNAKE_CASE :	Any					 =	0
					for token in [bos_token, pad_token, eos_token, unk_token, sep_token, cls_token]:
							if str(UpperCamelCase__		) not in self.fairseq_tokens_to_ids:
									__SCREAMING_SNAKE_CASE :	str					 =	cnt
									cnt += 1
					with open(UpperCamelCase__							,  """r"""							,  encoding="""utf-8"""		) as f:
							for line in f.readlines():
									__SCREAMING_SNAKE_CASE :	List[Any]					 =	line.strip().split()[0]
									__SCREAMING_SNAKE_CASE :	str					 =	len(self.fairseq_tokens_to_ids		)
					if str(UpperCamelCase__		) not in self.fairseq_tokens_to_ids:
							__SCREAMING_SNAKE_CASE :	str					 =	len(self.fairseq_tokens_to_ids		)

					__SCREAMING_SNAKE_CASE :	int					 =	{v: k for k, v in self.fairseq_tokens_to_ids.items()}

			def __getstate__(							self  :				Any		):





					"""simple docstring"""






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

			def __setstate__(							self  :				Optional[Any]							,  lowerCAmelCase__  :				Dict		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	d

					# for backward compatibility
					if not hasattr(self							,  """sp_model_kwargs"""		):
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	{}

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

			def UpperCamelCase__      (							self  :				Tuple							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				Any = None		):





					"""simple docstring"""






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

			def UpperCamelCase__      (							self  :				Optional[Any]							,  lowerCAmelCase__  :				Tuple							,  lowerCAmelCase__  :				str = None							,  lowerCAmelCase__  :				Union[str, Any] = 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 None:
							return [1] + ([0] * len(UpperCamelCase__		)) + [1]
					return [1] + ([0] * len(UpperCamelCase__		)) + [1, 1] + ([0] * len(UpperCamelCase__		)) + [1]

			def UpperCamelCase__      (							self  :				Dict							,  lowerCAmelCase__  :				str							,  lowerCAmelCase__  :				List[Any] = None		):





					"""simple docstring"""






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

			@property
			def UpperCamelCase__      (							self  :				Dict		):





					"""simple docstring"""






					return len(self.fairseq_ids_to_tokens		)

			def UpperCamelCase__      (							self  :				Union[str, Any]		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	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 UpperCamelCase__      (							self  :				str							,  lowerCAmelCase__  :				List[Any]		):





					"""simple docstring"""






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

			def UpperCamelCase__      (							self  :				Tuple							,  lowerCAmelCase__  :				int		):





					"""simple docstring"""






					if token in self.fairseq_tokens_to_ids:
							return self.fairseq_tokens_to_ids[token]
					else:
							return self.unk_token_id

			def UpperCamelCase__      (							self  :				Union[str, Any]							,  lowerCAmelCase__  :				Union[str, Any]		):





					"""simple docstring"""






					return self.fairseq_ids_to_tokens[index]

			def UpperCamelCase__      (							self  :				Tuple							,  lowerCAmelCase__  :				Tuple		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	"""""".join(UpperCamelCase__		).replace(UpperCamelCase__							,  """ """		).strip()
					return out_string



			def UpperCamelCase__      (							self  :				str							,  lowerCAmelCase__  :				List[Any]							,  lowerCAmelCase__  :				List[str] = None		):





					"""simple docstring"""






					if not os.path.isdir(UpperCamelCase__		):
							logger.error(F"Vocabulary path ({save_directory}) should be a directory"		)
							return
					__SCREAMING_SNAKE_CASE :	List[Any]					 =	os.path.join(
					    UpperCamelCase__							,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]		)
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	os.path.join(
					    UpperCamelCase__							,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""monolingual_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:
									__SCREAMING_SNAKE_CASE :	List[Any]					 =	self.sp_model.serialized_model_proto()
									fi.write(UpperCamelCase__		)

					if os.path.abspath(self.monolingual_vocab_file		) != os.path.abspath(
					    UpperCamelCase__		) and os.path.isfile(self.monolingual_vocab_file		):
							copyfile(self.monolingual_vocab_file							,  UpperCamelCase__		)
					elif not os.path.isfile(self.monolingual_vocab_file		):
							with open(UpperCamelCase__							,  """w"""							,  encoding="""utf-8"""		) as fp:
									for token in self.fairseq_tokens_to_ids:
											if token not in self.all_special_tokens:
													fp.write(F"{str(UpperCamelCase__		)} \n"		)

					return out_vocab_file, out_monolingual_vocab_file




'''simple docstring'''




import qiskit


def        lowerCAmelCase_     (			_lowerCamelCase:     int = 2      ):
		__SCREAMING_SNAKE_CASE :	Dict					 =	qubits

		# Using Aer's simulator
		__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	qiskit.Aer.get_backend("""aer_simulator"""      )

		# Creating a Quantum Circuit acting on the q register
		__SCREAMING_SNAKE_CASE :	str					 =	qiskit.QuantumCircuit(_lowerCamelCase ,   _lowerCamelCase      )

		# Adding a H gate on qubit 0 (now q0 in superposition)
		circuit.h(0      )

		for i in range(1 ,   _lowerCamelCase      ):
				# Adding CX (CNOT) gate
				circuit.cx(i - 1 ,   _lowerCamelCase      )

		# Mapping the quantum measurement to the classical bits
		circuit.measure(list(range(_lowerCamelCase      )      ) ,   list(range(_lowerCamelCase      )      )      )

		# Now measuring any one qubit would affect other qubits to collapse
		# their super position and have same state as the measured one.

		# Executing the circuit on the simulator
		__SCREAMING_SNAKE_CASE :	str					 =	qiskit.execute(_lowerCamelCase ,   _lowerCamelCase ,   shots=10_00      )

		return job.result().get_counts(_lowerCamelCase      )


if __name__ == "__main__":
						print(f"Total count for various states are: {quantum_entanglement(3)}")