





import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.text import TextDatasetReader

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases




def    __UpperCAmelCase(      lowercase_ ,    lowercase_      ):
       assert isinstance(lowercase_ ,    lowercase_      )
       assert dataset.num_rows == 4
       assert dataset.num_columns == 1
       assert dataset.column_names == ["text"]
       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(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     Optional[int]	=		tmp_path / '''cache'''
       _lowerCamelCase							:     Union[str, Any]	=		{'''text''': '''string'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              _lowerCamelCase							:     Optional[int]	=		TextDatasetReader(lowercase_ ,    cache_dir=lowercase_ ,    keep_in_memory=lowercase_      ).read()
       _check_text_dataset(lowercase_ ,    lowercase_      )




@pytest.mark.parametrize(
    '''features''' ,    [
        None,
        {'''text''': '''string'''},
        {'''text''': '''int32'''},
        {'''text''': '''float32'''},
    ] ,    )
def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     List[str]	=		tmp_path / '''cache'''
       _lowerCamelCase							:     int	=		{'''text''': '''string'''}
       _lowerCamelCase							:     Optional[Any]	=		features.copy() if features else default_expected_features
       _lowerCamelCase							:     str	=		(
           Features({feature: Value(lowercase_      ) for feature, dtype in features.items()}      ) if features is not None else None
       )
       _lowerCamelCase							:     Any	=		TextDatasetReader(lowercase_ ,    features=lowercase_ ,    cache_dir=lowercase_      ).read()
       _check_text_dataset(lowercase_ ,    lowercase_      )




@pytest.mark.parametrize('''split''' ,    [None, NamedSplit('''train'''      ), '''train''', '''test''']      )
def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     List[str]	=		tmp_path / '''cache'''
       _lowerCamelCase							:     Tuple	=		{'''text''': '''string'''}
       _lowerCamelCase							:     Tuple	=		TextDatasetReader(lowercase_ ,    cache_dir=lowercase_ ,    split=lowercase_      ).read()
       _check_text_dataset(lowercase_ ,    lowercase_      )
       assert dataset.split == split if split else "train"




@pytest.mark.parametrize('''path_type''' ,    [str, list]      )
def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       if issubclass(lowercase_ ,    lowercase_      ):
              _lowerCamelCase							:     Union[str, Any]	=		text_path
       elif issubclass(lowercase_ ,    lowercase_      ):
              _lowerCamelCase							:     Dict	=		[text_path]
       _lowerCamelCase							:     int	=		tmp_path / '''cache'''
       _lowerCamelCase							:     Union[str, Any]	=		{'''text''': '''string'''}
       _lowerCamelCase							:     List[Any]	=		TextDatasetReader(lowercase_ ,    cache_dir=lowercase_      ).read()
       _check_text_dataset(lowercase_ ,    lowercase_      )




def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_=("train",)      ):
       assert isinstance(lowercase_ ,    lowercase_      )
       for split in splits:
              _lowerCamelCase							:     Dict	=		dataset_dict[split]
              assert dataset.num_rows == 4
              assert dataset.num_columns == 1
              assert dataset.column_names == ["text"]
              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(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     Any	=		tmp_path / '''cache'''
       _lowerCamelCase							:     List[Any]	=		{'''text''': '''string'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              _lowerCamelCase							:     Dict	=		TextDatasetReader({'''train''': text_path} ,    cache_dir=lowercase_ ,    keep_in_memory=lowercase_      ).read()
       _check_text_datasetdict(lowercase_ ,    lowercase_      )




@pytest.mark.parametrize(
    '''features''' ,    [
        None,
        {'''text''': '''string'''},
        {'''text''': '''int32'''},
        {'''text''': '''float32'''},
    ] ,    )
def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       _lowerCamelCase							:     List[Any]	=		tmp_path / '''cache'''
       # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
       _lowerCamelCase							:     Dict	=		{'''text''': '''string'''}
       _lowerCamelCase							:     str	=		features.copy() if features else default_expected_features
       _lowerCamelCase							:     List[Any]	=		(
           Features({feature: Value(lowercase_      ) for feature, dtype in features.items()}      ) if features is not None else None
       )
       _lowerCamelCase							:     List[str]	=		TextDatasetReader({'''train''': text_path} ,    features=lowercase_ ,    cache_dir=lowercase_      ).read()
       _check_text_datasetdict(lowercase_ ,    lowercase_      )




@pytest.mark.parametrize('''split''' ,    [None, NamedSplit('''train'''      ), '''train''', '''test''']      )
def    __UpperCAmelCase(      lowercase_ ,    lowercase_ ,    lowercase_      ):
       if split:
              _lowerCamelCase							:     Any	=		{split: text_path}
       else:
              _lowerCamelCase							:     Union[str, Any]	=		'''train'''
              _lowerCamelCase							:     Optional[Any]	=		{'''train''': text_path, '''test''': text_path}
       _lowerCamelCase							:     List[str]	=		tmp_path / '''cache'''
       _lowerCamelCase							:     Dict	=		{'''text''': '''string'''}
       _lowerCamelCase							:     str	=		TextDatasetReader(lowercase_ ,    cache_dir=lowercase_      ).read()
       _check_text_datasetdict(lowercase_ ,    lowercase_ ,    splits=list(path.keys()      )      )
       assert all(dataset[split].split == split for split in path.keys()      )








import qiskit




def    __UpperCAmelCase(      lowercase_ = 2      ):
       _lowerCamelCase							:     Optional[Any]	=		qubits

       # Using Aer's simulator
       _lowerCamelCase							:     Optional[int]	=		qiskit.Aer.get_backend('''aer_simulator'''      )

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

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

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

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

       # 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
       _lowerCamelCase							:     str	=		qiskit.execute(lowercase_ ,    lowercase_ ,    shots=10_00      )

       return job.result().get_counts(lowercase_      )


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

