






import numpy as np
import qiskit







def 	SCREAMING_SNAKE_CASE							(					snake_case_   :				int = 8	,    snake_case_   :				int | None = None  ):
	snake_case__					: int  =    np.random.default_rng(seed=A__  )

	# Roughly 25% of the qubits will contribute to the key.
	# So we take more than we need.
	snake_case__					: Optional[Any]  =    6 * key_len
	# Measurement basis for Alice's qubits.
	snake_case__					: Dict  =    rng.integers(2	,    size=A__  )
	# The set of states Alice will prepare.
	snake_case__					: Tuple  =    rng.integers(2	,    size=A__  )
	# Measurement basis for Bob's qubits.
	snake_case__					: Any  =    rng.integers(2	,    size=A__  )

	# Quantum Circuit to simulate BB84
	snake_case__					: int  =    qiskit.QuantumCircuit(A__	,    name="BB84"  )

	# Alice prepares her qubits according to rules above.
	for index, _ in enumerate(A__  ):
		if alice_state[index] == 1:
			bbaa_circ.x(A__  )
		if alice_basis[index] == 1:
			bbaa_circ.h(A__  )
	bbaa_circ.barrier()

	# Bob measures the received qubits according to rules above.
	for index, _ in enumerate(A__  ):
		if bob_basis[index] == 1:
			bbaa_circ.h(A__  )

	bbaa_circ.barrier()
	bbaa_circ.measure_all()

	# Simulate the quantum circuit.
	snake_case__					: List[Any]  =    qiskit.Aer.get_backend("aer_simulator"  )
	# We only need to run one shot because the key is unique.
	# Multiple shots will produce the same key.
	snake_case__					: List[str]  =    qiskit.execute(A__	,    A__	,    shots=1	,    seed_simulator=A__  )
	# Returns the result of measurement.
	snake_case__					: Dict  =    job.result().get_counts(A__  ).most_frequent()

	# Extracting the generated key from the simulation results.
	# Only keep measurement results where Alice and Bob chose the same basis.
	snake_case__					: int  =    "".join(
	    [
	        result_bit
	        for alice_basis_bit, bob_basis_bit, result_bit in zip(
	            A__	,    A__	,    A__  )
	        if alice_basis_bit == bob_basis_bit
	    ]  )

	# Get final key. Pad with 0 if too short, otherwise truncate.
	snake_case__					: str  =    gen_key[:key_len] if len(A__  ) >= key_len else gen_key.ljust(A__	,    "0"  )
	return key


if __name__ == "__main__":
	print(f"The generated key is : {bbaa(8, seed=0)}")
	from doctest import testmod

	testmod()






from typing import List

import datasets
from datasets.tasks import AudioClassification

from ..folder_based_builder import folder_based_builder


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





class 					__lowerCAmelCase	(   folder_based_builder.FolderBasedBuilderConfig				):
  _a		     =    None
  _a		     =    None





class 					__lowerCAmelCase	(   folder_based_builder.FolderBasedBuilder				):
  _a		     =    datasets.Audio()
  _a		     =    """audio"""
  _a		     =    AudioFolderConfig
  _a		     =    42  # definition at the bottom of the script
  _a		     =    AudioClassification(audio_column="""audio"""     ,     label_column="""label"""				)
lowercase_   							=  [
    '.aiff',
    '.au',
    '.avr',
    '.caf',
    '.flac',
    '.htk',
    '.svx',
    '.mat4',
    '.mat5',
    '.mpc2k',
    '.ogg',
    '.paf',
    '.pvf',
    '.raw',
    '.rf64',
    '.sd2',
    '.sds',
    '.ircam',
    '.voc',
    '.w64',
    '.wav',
    '.nist',
    '.wavex',
    '.wve',
    '.xi',
    '.mp3',
    '.opus',
]
lowercase_   							=  AUDIO_EXTENSIONS


