




import math

import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute





def      UpperCAmelCase  (						UpperCamelCase__ = 1						,			UpperCamelCase__ = 1   )     ->     qiskit.result.counts.Counts:







				'''simple docstring'''


				if isinstance(UpperCamelCase__						,			UpperCamelCase__   ) or isinstance(UpperCamelCase__						,			UpperCamelCase__   ):
								raise TypeError("""inputs must be integers."""   )
				if (bit_a < 0) or (bit_a < 0):
								raise ValueError("""inputs must be positive."""   )
				if (math.floor(UpperCamelCase__   ) != bit_a) or (math.floor(UpperCamelCase__   ) != bit_a):
								raise ValueError("""inputs must be exact integers."""   )
				if (bit_a > 1) or (bit_a > 1):
								raise ValueError("""inputs must be less or equal to 1."""   )

				# build registers
				__lowerCAmelCase					=  QuantumRegister(2						,			"""qr"""   )
				__lowerCAmelCase					=  ClassicalRegister(2						,			"""cr"""   )

				__lowerCAmelCase					=  QuantumCircuit(UpperCamelCase__						,			UpperCamelCase__   )

				# entanglement the qubits
				quantum_circuit.h(1   )
				quantum_circuit.cx(1						,			0   )

				# send the information
				__lowerCAmelCase					=  str(UpperCamelCase__   ) + str(UpperCamelCase__   )

				if c_information == "11":
								quantum_circuit.x(1   )
								quantum_circuit.z(1   )
				elif c_information == "10":
								quantum_circuit.z(1   )
				elif c_information == "01":
								quantum_circuit.x(1   )
				else:
								quantum_circuit.i(1   )

				# unentangled the circuit
				quantum_circuit.cx(1						,			0   )
				quantum_circuit.h(1   )

				# measure the circuit
				quantum_circuit.measure(UpperCamelCase__						,			UpperCamelCase__   )

				__lowerCAmelCase					=  Aer.get_backend("""aer_simulator"""   )
				__lowerCAmelCase					=  execute(UpperCamelCase__						,			UpperCamelCase__						,			shots=10_00   )

				return job.result().get_counts(UpperCamelCase__   )


if __name__ == "__main__":
	print(f"""Counts for classical state send: {superdense_coding(1,1)}""")











import csv
import os

import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.csv import CsvDatasetReader, CsvDatasetWriter

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases





def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     Tuple:







				'''simple docstring'''


				assert isinstance(UpperCamelCase__						,			UpperCamelCase__   )
				assert dataset.num_rows == 4
				assert dataset.num_columns == 3
				assert dataset.column_names == ["col_1", "col_2", "col_3"]
				for feature, expected_dtype in expected_features.items():
								assert dataset.features[feature].dtype == expected_dtype





@pytest.mark.parametrize("""keep_in_memory"""						,			[False, True]   )
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     Union[str, Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
								__lowerCAmelCase					=  CsvDatasetReader(UpperCamelCase__						,			cache_dir=UpperCamelCase__						,			keep_in_memory=UpperCamelCase__   ).read()
				_check_csv_dataset(UpperCamelCase__						,			UpperCamelCase__   )





@pytest.mark.parametrize(
    """features"""						,			[
        None,
        {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
        {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
        {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
        {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
    ]						,			)
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     Tuple:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				# CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				__lowerCAmelCase					=  features.copy() if features else default_expected_features
				__lowerCAmelCase					=  (
				    Features({feature: Value(UpperCamelCase__   ) for feature, dtype in features.items()}   ) if features is not None else None
				)
				__lowerCAmelCase					=  CsvDatasetReader(UpperCamelCase__						,			features=UpperCamelCase__						,			cache_dir=UpperCamelCase__   ).read()
				_check_csv_dataset(UpperCamelCase__						,			UpperCamelCase__   )





@pytest.mark.parametrize("""split"""						,			[None, NamedSplit("""train"""   ), """train""", """test"""]   )
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     Optional[Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				__lowerCAmelCase					=  CsvDatasetReader(UpperCamelCase__						,			cache_dir=UpperCamelCase__						,			split=UpperCamelCase__   ).read()
				_check_csv_dataset(UpperCamelCase__						,			UpperCamelCase__   )
				assert dataset.split == split if split else "train"





@pytest.mark.parametrize("""path_type"""						,			[str, list]   )
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     List[Any]:







				'''simple docstring'''


				if issubclass(UpperCamelCase__						,			UpperCamelCase__   ):
								__lowerCAmelCase					=  csv_path
				elif issubclass(UpperCamelCase__						,			UpperCamelCase__   ):
								__lowerCAmelCase					=  [csv_path]
				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				__lowerCAmelCase					=  CsvDatasetReader(UpperCamelCase__						,			cache_dir=UpperCamelCase__   ).read()
				_check_csv_dataset(UpperCamelCase__						,			UpperCamelCase__   )





def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__=("train",)   )     ->     Optional[int]:







				'''simple docstring'''


				assert isinstance(UpperCamelCase__						,			UpperCamelCase__   )
				for split in splits:
								__lowerCAmelCase					=  dataset_dict[split]
								assert dataset.num_rows == 4
								assert dataset.num_columns == 3
								assert dataset.column_names == ["col_1", "col_2", "col_3"]
								for feature, expected_dtype in expected_features.items():
												assert dataset.features[feature].dtype == expected_dtype





@pytest.mark.parametrize("""keep_in_memory"""						,			[False, True]   )
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     List[Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
								__lowerCAmelCase					=  CsvDatasetReader({"""train""": csv_path}						,			cache_dir=UpperCamelCase__						,			keep_in_memory=UpperCamelCase__   ).read()
				_check_csv_datasetdict(UpperCamelCase__						,			UpperCamelCase__   )





@pytest.mark.parametrize(
    """features"""						,			[
        None,
        {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
        {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
        {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
        {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
    ]						,			)
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     List[Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				# CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				__lowerCAmelCase					=  features.copy() if features else default_expected_features
				__lowerCAmelCase					=  (
				    Features({feature: Value(UpperCamelCase__   ) for feature, dtype in features.items()}   ) if features is not None else None
				)
				__lowerCAmelCase					=  CsvDatasetReader({"""train""": csv_path}						,			features=UpperCamelCase__						,			cache_dir=UpperCamelCase__   ).read()
				_check_csv_datasetdict(UpperCamelCase__						,			UpperCamelCase__   )





@pytest.mark.parametrize("""split"""						,			[None, NamedSplit("""train"""   ), """train""", """test"""]   )
def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__						,			UpperCamelCase__   )     ->     Tuple:







				'''simple docstring'''


				if split:
								__lowerCAmelCase					=  {split: csv_path}
				else:
								__lowerCAmelCase					=  {"""train""": csv_path, """test""": csv_path}
				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  {"""col_1""": """int64""", """col_2""": """int64""", """col_3""": """float64"""}
				__lowerCAmelCase					=  CsvDatasetReader(UpperCamelCase__						,			cache_dir=UpperCamelCase__   ).read()
				_check_csv_datasetdict(UpperCamelCase__						,			UpperCamelCase__						,			splits=list(path.keys()   )   )
				assert all(dataset[split].split == split for split in path.keys()   )





def      UpperCAmelCase  (						UpperCamelCase__   )     ->     str:







				'''simple docstring'''


				with open(UpperCamelCase__						,			encoding="""utf-8"""   ) as csvfile:
								yield from csv.reader(UpperCamelCase__   )





def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     List[Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  os.path.join(UpperCamelCase__						,			"""tmp.csv"""   )
				__lowerCAmelCase					=  CsvDatasetReader({"""train""": csv_path}						,			cache_dir=UpperCamelCase__   ).read()
				CsvDatasetWriter(dataset["""train"""]						,			UpperCamelCase__						,			num_proc=1   ).write()

				__lowerCAmelCase					=  iter_csv_file(UpperCamelCase__   )
				__lowerCAmelCase					=  iter_csv_file(UpperCamelCase__   )

				for rowa, rowa in zip(UpperCamelCase__						,			UpperCamelCase__   ):
								assert rowa == rowa





def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     Union[str, Any]:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  os.path.join(UpperCamelCase__						,			"""tmp.csv"""   )
				__lowerCAmelCase					=  CsvDatasetReader({"""train""": csv_path}						,			cache_dir=UpperCamelCase__   ).read()
				CsvDatasetWriter(dataset["""train"""]						,			UpperCamelCase__						,			num_proc=2   ).write()

				__lowerCAmelCase					=  iter_csv_file(UpperCamelCase__   )
				__lowerCAmelCase					=  iter_csv_file(UpperCamelCase__   )

				for rowa, rowa in zip(UpperCamelCase__						,			UpperCamelCase__   ):
								assert rowa == rowa





def      UpperCAmelCase  (						UpperCamelCase__						,			UpperCamelCase__   )     ->     Dict:







				'''simple docstring'''


				__lowerCAmelCase					=  tmp_path / """cache"""
				__lowerCAmelCase					=  os.path.join(UpperCamelCase__						,			"""tmp.csv"""   )
				__lowerCAmelCase					=  CsvDatasetReader({"""train""": csv_path}						,			cache_dir=UpperCamelCase__   ).read()
				with pytest.raises(UpperCamelCase__   ):
								CsvDatasetWriter(dataset["""train"""]						,			UpperCamelCase__						,			num_proc=0   )





