

"""simple docstring"""


import itertools
from dataclasses import dataclass
from io import StringIO
from typing import Optional

import pyarrow as pa

import datasets
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


__A		     =    datasets.utils.logging.get_logger(__name__)





@dataclass
class 					snake_case			(       datasets.BuilderConfig						):
				SCREAMING_SNAKE_CASE_     :   Optional[datasets.Features]        =						None
				SCREAMING_SNAKE_CASE_     :   str        =						"utf-8"
				SCREAMING_SNAKE_CASE_     :   Optional[str]        =						None
				SCREAMING_SNAKE_CASE_     :   int        =						10 << 20  # 10MB
				SCREAMING_SNAKE_CASE_     :   bool        =						False
				SCREAMING_SNAKE_CASE_     :   str        =						"line"





class 					snake_case			(       datasets.ArrowBasedBuilder						):
				SCREAMING_SNAKE_CASE_     :   Optional[Any]        =						TextConfig

				def 							lowercase_  (			self							:       Optional[int])->     List[str]:



						'''simple docstring'''


						return datasets.DatasetInfo(features=self.config.features)

				def 							lowercase_  (			self							:       Optional[Any]  ,						UpperCamelCase__							:       List[str])->     List[Any]:



						'''simple docstring'''


						if not self.config.data_files:
								raise ValueError(f"At least one data file must be specified, but got data_files={self.config.data_files}")
						__lowerCAmelCase: Optional[Any]					   =    dl_manager.download_and_extract(self.config.data_files)
						if isinstance(UpperCamelCase__  ,						(str, list, tuple)):
								__lowerCAmelCase: Dict					   =    data_files
								if isinstance(UpperCamelCase__  ,						UpperCamelCase__):
										__lowerCAmelCase: Any					   =    [files]
								__lowerCAmelCase: Optional[int]					   =    [dl_manager.iter_files(UpperCamelCase__) for file in files]
								return [datasets.SplitGenerator(name=datasets.Split.TRAIN  ,						gen_kwargs={"files": files})]
						__lowerCAmelCase: Any					   =    []
						for split_name, files in data_files.items():
								if isinstance(UpperCamelCase__  ,						UpperCamelCase__):
										__lowerCAmelCase: int					   =    [files]
								__lowerCAmelCase: int					   =    [dl_manager.iter_files(UpperCamelCase__) for file in files]
								splits.append(datasets.SplitGenerator(name=UpperCamelCase__  ,						gen_kwargs={"files": files}))
						return splits

				def 							lowercase_  (			self							:       str  ,						UpperCamelCase__							:       pa.Table)->     pa.Table:



						'''simple docstring'''


						if self.config.features is not None:
								__lowerCAmelCase: Optional[Any]					   =    self.config.features.arrow_schema
								if all(not require_storage_cast(UpperCamelCase__) for feature in self.config.features.values()):
										# cheaper cast
										__lowerCAmelCase: Any					   =    pa_table.cast(UpperCamelCase__)
								else:
										# more expensive cast; allows str <-> int/float or str to Audio for example
										__lowerCAmelCase: Optional[int]					   =    table_cast(UpperCamelCase__  ,						UpperCamelCase__)
								return pa_table
						else:
								return pa_table.cast(pa.schema({"text": pa.string()}))




				def 							lowercase_  (			self							:       Any  ,						UpperCamelCase__							:       Optional[Any])->     List[str]:



						'''simple docstring'''


						__lowerCAmelCase: Union[str, Any]					   =    list(self.config.features) if self.config.features is not None else ["text"]
						for file_idx, file in enumerate(itertools.chain.from_iterable(UpperCamelCase__)):
								# open in text mode, by default translates universal newlines ("\n", "\r\n" and "\r") into "\n"
								with open(UpperCamelCase__  ,						encoding=self.config.encoding  ,						errors=self.config.errors) as f:
										if self.config.sample_by == "line":
												__lowerCAmelCase: List[str]					   =    0
												while True:
														__lowerCAmelCase: Dict					   =    f.read(self.config.chunksize)
														if not batch:
																break
														batch += f.readline()  # finish current line
														# StringIO.readlines, by default splits only on "\n" (and keeps line breaks)
														__lowerCAmelCase: Dict					   =    StringIO(UpperCamelCase__).readlines()
														if not self.config.keep_linebreaks:
																__lowerCAmelCase: Union[str, Any]					   =    [line.rstrip("\n") for line in batch]
														__lowerCAmelCase: Union[str, Any]					   =    pa.Table.from_arrays([pa.array(UpperCamelCase__)]  ,						names=UpperCamelCase__)
														# Uncomment for debugging (will print the Arrow table size and elements)
														# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
														# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
														yield (file_idx, batch_idx), self._cast_table(UpperCamelCase__)
														batch_idx += 1
										elif self.config.sample_by == "paragraph":
												__lowerCAmelCase: Tuple					   =    0
												__lowerCAmelCase: List[Any]					   =    ""
												while True:
														__lowerCAmelCase: int					   =    f.read(self.config.chunksize)
														if not new_batch:
																break
														batch += new_batch
														batch += f.readline()  # finish current line
														__lowerCAmelCase: Optional[Any]					   =    batch.split("\n\n")
														__lowerCAmelCase: int					   =    pa.Table.from_arrays(
														    [pa.array([example for example in batch[:-1] if example])]  ,						names=UpperCamelCase__)
														# Uncomment for debugging (will print the Arrow table size and elements)
														# logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
														# logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
														yield (file_idx, batch_idx), self._cast_table(UpperCamelCase__)
														batch_idx += 1
														__lowerCAmelCase: List[str]					   =    batch[-1]
												if batch:
														__lowerCAmelCase: int					   =    pa.Table.from_arrays([pa.array([batch])]  ,						names=UpperCamelCase__)
														yield (file_idx, batch_idx), self._cast_table(UpperCamelCase__)
										elif self.config.sample_by == "document":
												__lowerCAmelCase: Union[str, Any]					   =    f.read()
												__lowerCAmelCase: List[Any]					   =    pa.Table.from_arrays([pa.array([text])]  ,						names=UpperCamelCase__)
												yield file_idx, self._cast_table(UpperCamelCase__)





"""simple docstring"""


import math

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






def 					a__					(					__SCREAMING_SNAKE_CASE = 1      ,				__SCREAMING_SNAKE_CASE = 1				)			->			qiskit.result.counts.Counts:
		if isinstance(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				) or isinstance(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				):
				raise TypeError("inputs must be integers."				)
		if (bit_a < 0) or (bit_a < 0):
				raise ValueError("inputs must be positive."				)
		if (math.floor(__SCREAMING_SNAKE_CASE				) != bit_a) or (math.floor(__SCREAMING_SNAKE_CASE				) != 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: str					   =    QuantumRegister(2      ,				"qr"				)
		__lowerCAmelCase: Optional[Any]					   =    ClassicalRegister(2      ,				"cr"				)

		__lowerCAmelCase: Dict					   =    QuantumCircuit(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)

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

		# send the information
		__lowerCAmelCase: Dict					   =    str(__SCREAMING_SNAKE_CASE				) + str(__SCREAMING_SNAKE_CASE				)

		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(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE				)

		__lowerCAmelCase: List[str]					   =    Aer.get_backend("aer_simulator"				)
		__lowerCAmelCase: Dict					   =    execute(__SCREAMING_SNAKE_CASE      ,				__SCREAMING_SNAKE_CASE      ,				shots=1_0_0_0				)

		return job.result().get_counts(__SCREAMING_SNAKE_CASE				)


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


