
'''simple docstring'''
import os
from pathlib import Path
from unittest.mock import patch

import pytest
import zstandard as zstd

from datasets.download.download_config import DownloadConfig
from datasets.utils.file_utils import (
    OfflineModeIsEnabled,
    cached_path,
    fsspec_get,
    fsspec_head,
    ftp_get,
    ftp_head,
    get_from_cache,
    http_get,
    http_head,
)


__lowerCAmelCase												=	'\\n    Text data.\n    Second line of data.'

__lowerCAmelCase												=	'file'






@pytest.fixture(scope="""session"""				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  tmp_path_factory.mktemp("""data"""				) / (FILE_PATH + """.zstd""")
							_snake_case       =  bytes(_SCREAMING_SNAKE_CASE							, """utf-8"""				)
							with zstd.open(_SCREAMING_SNAKE_CASE							, """wb"""				) as f:
														f.write(_SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							with open(os.path.join(tmpfs.local_root_dir							, _SCREAMING_SNAKE_CASE				)							, """w"""				) as f:
														f.write(_SCREAMING_SNAKE_CASE				)
							return FILE_PATH






@pytest.mark.parametrize("""compression_format"""							, ["""gzip""", """xz""", """zstd"""]				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE				):
							_snake_case       =  {"""gzip""": gz_file, """xz""": xz_file, """zstd""": zstd_path}
							_snake_case       =  input_paths[compression_format]
							_snake_case       =  tmp_path / """cache"""
							_snake_case       =  DownloadConfig(cache_dir=_SCREAMING_SNAKE_CASE							, extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							_snake_case       =  cached_path(_SCREAMING_SNAKE_CASE							, download_config=_SCREAMING_SNAKE_CASE				)
							with open(_SCREAMING_SNAKE_CASE				) as f:
														_snake_case       =  f.read()
							with open(_SCREAMING_SNAKE_CASE				) as f:
														_snake_case       =  f.read()
							assert extracted_file_content == expected_file_content






@pytest.mark.parametrize("""default_extracted"""							, [True, False]				)
@pytest.mark.parametrize("""default_cache_dir"""							, [True, False]				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE				):
							_snake_case       =  """custom_cache"""
							_snake_case       =  """custom_extracted_dir"""
							_snake_case       =  tmp_path / """custom_extracted_path"""
							if default_extracted:
														_snake_case       =  ("""downloads""" if default_cache_dir else custom_cache_dir, """extracted""")
							else:
														monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_DIR"""							, _SCREAMING_SNAKE_CASE				)
														monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""							, str(_SCREAMING_SNAKE_CASE				)				)
														_snake_case       =  custom_extracted_path.parts[-2:] if default_cache_dir else (custom_cache_dir, custom_extracted_dir)

							_snake_case       =  xz_file
							_snake_case       =  (
							    DownloadConfig(extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							    if default_cache_dir
							    else DownloadConfig(cache_dir=tmp_path / custom_cache_dir							, extract_compressed_file=_SCREAMING_SNAKE_CASE				)
							)
							_snake_case       =  cached_path(_SCREAMING_SNAKE_CASE							, download_config=_SCREAMING_SNAKE_CASE				)
							assert Path(_SCREAMING_SNAKE_CASE				).parent.parts[-2:] == expected






def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							# absolute path
							_snake_case       =  str(Path(_SCREAMING_SNAKE_CASE				).resolve()				)
							assert cached_path(_SCREAMING_SNAKE_CASE				) == text_file
							# relative path
							_snake_case       =  str(Path(_SCREAMING_SNAKE_CASE				).resolve().relative_to(Path(os.getcwd()				)				)				)
							assert cached_path(_SCREAMING_SNAKE_CASE				) == text_file






def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							# absolute path
							_snake_case       =  str(tmp_path.resolve() / """__missing_file__.txt"""				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path(_SCREAMING_SNAKE_CASE				)
							# relative path
							_snake_case       =  """./__missing_file__.txt"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path(_SCREAMING_SNAKE_CASE				)






def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  get_from_cache(f"""tmp://{tmpfs_file}"""				)
							with open(_SCREAMING_SNAKE_CASE				) as f:
														_snake_case       =  f.read()
							assert output_file_content == FILE_CONTENT






@patch("""datasets.config.HF_DATASETS_OFFLINE"""							, _SCREAMING_SNAKE_CASE				)
def  __SCREAMING_SNAKE_CASE				(  ):
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														cached_path("""https://huggingface.co"""				)






@patch("""datasets.config.HF_DATASETS_OFFLINE"""							, _SCREAMING_SNAKE_CASE				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														http_get("""https://huggingface.co"""							, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														http_head("""https://huggingface.co"""				)






@patch("""datasets.config.HF_DATASETS_OFFLINE"""							, _SCREAMING_SNAKE_CASE				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														ftp_get("""ftp://huggingface.co"""							, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														ftp_head("""ftp://huggingface.co"""				)






@patch("""datasets.config.HF_DATASETS_OFFLINE"""							, _SCREAMING_SNAKE_CASE				)
def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE				):
							_snake_case       =  tmp_path_factory.mktemp("""data"""				) / """file.html"""
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														fsspec_get("""s3://huggingface.co"""							, temp_file=_SCREAMING_SNAKE_CASE				)
							with pytest.raises(_SCREAMING_SNAKE_CASE				):
														fsspec_head("""s3://huggingface.co"""				)

'''simple docstring'''
import qiskit






def  __SCREAMING_SNAKE_CASE				(  _SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE				):
							_snake_case       =  qiskit.Aer.get_backend("""aer_simulator"""				)

							# Create a Quantum Circuit acting on the q register
							_snake_case       =  qiskit.QuantumCircuit(_SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE				)

							# Apply X (NOT) Gate to Qubits 0 & 1
							circuit.x(0				)
							circuit.x(1				)

							# Map the quantum measurement to the classical bits
							circuit.measure([0, 1]							, [0, 1]				)

							# Execute the circuit on the qasm simulator
							_snake_case       =  qiskit.execute(_SCREAMING_SNAKE_CASE							, _SCREAMING_SNAKE_CASE							, shots=1000				)

							# Return the histogram data of the results of the experiment.
							return job.result().get_counts(_SCREAMING_SNAKE_CASE				)


if __name__ == "__main__":
				__lowerCAmelCase												=	single_qubit_measure(2, 2)
				print(f'''Total count for various states are: {counts}''')