




"""simple docstring"""





import contextlib
import csv
import json
import os
import sqlitea
import tarfile
import textwrap
import zipfile

import pyarrow as pa
import pyarrow.parquet as pq
import pytest

import datasets
import datasets.config

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: List[str]		=					10
			__UpperCAmelCase	: List[str]		=					datasets.Features(
			    {
			        "tokens": datasets.Sequence(datasets.Value("string"							)							),
			        "labels": datasets.Sequence(datasets.ClassLabel(names=["negative", "positive"]							)							),
			        "answers": datasets.Sequence(
			            {
			                "text": datasets.Value("string"							),
			                "answer_start": datasets.Value("int32"							),
			            }							),
			        "id": datasets.Value("int64"							),
			    }							)
			__UpperCAmelCase	: int		=					datasets.Dataset.from_dict(
			    {
			        "tokens": [["foo"] * 5] * n,
			        "labels": [[1] * 5] * n,
			        "answers": [{"answer_start": [97], "text": ["1976"]}] * 10,
			        "id": list(range(UpperCamelCase							)							),
			    }				,       features=UpperCamelCase				,       )
			return dataset

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			Optional[int]:


			"""simple docstring"""
			__UpperCAmelCase	: int		=					str(tmp_path_factory.mktemp("data"							) / "file.arrow"							)
			dataset.map(cache_file_name=UpperCamelCase							)
			return filename


# FILE_CONTENT + files


A   =       """\
    Text data.
    Second line of data."""

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Union[str, Any]:


			"""simple docstring"""
			__UpperCAmelCase	: Tuple		=					tmp_path_factory.mktemp("data"							) / "file.txt"
			__UpperCAmelCase	: int		=					FILE_CONTENT
			with open(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase							)
			return filename

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Any:


			"""simple docstring"""
			import bza

			__UpperCAmelCase	: Tuple		=					tmp_path_factory.mktemp("data"							) / "file.txt.bz2"
			__UpperCAmelCase	: Dict		=					bytes(UpperCamelCase				,       "utf-8"							)
			with bza.open(UpperCamelCase				,       "wb"							) as f:
						f.write(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""
			import gzip

			__UpperCAmelCase	: Dict		=					str(tmp_path_factory.mktemp("data"							) / "file.txt.gz"							)
			__UpperCAmelCase	: Tuple		=					bytes(UpperCamelCase				,       "utf-8"							)
			with gzip.open(UpperCamelCase				,       "wb"							) as f:
						f.write(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			if datasets.config.LZ4_AVAILABLE:
						import lza.frame

						__UpperCAmelCase	: Optional[Any]		=					tmp_path_factory.mktemp("data"							) / "file.txt.lz4"
						__UpperCAmelCase	: Tuple		=					bytes(UpperCamelCase				,       "utf-8"							)
						with lza.frame.open(UpperCamelCase				,       "wb"							) as f:
									f.write(UpperCamelCase							)
						return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			List[Any]:


			"""simple docstring"""
			if datasets.config.PY7ZR_AVAILABLE:
						import pyazr

						__UpperCAmelCase	: int		=					tmp_path_factory.mktemp("data"							) / "file.txt.7z"
						with pyazr.SevenZipFile(UpperCamelCase				,       "w"							) as archive:
									archive.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			Optional[int]:


			"""simple docstring"""
			import tarfile

			__UpperCAmelCase	: Optional[Any]		=					tmp_path_factory.mktemp("data"							) / "file.txt.tar"
			with tarfile.TarFile(UpperCamelCase				,       "w"							) as f:
						f.add(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Optional[int]:


			"""simple docstring"""
			import lzma

			__UpperCAmelCase	: Dict		=					tmp_path_factory.mktemp("data"							) / "file.txt.xz"
			__UpperCAmelCase	: Optional[int]		=					bytes(UpperCamelCase				,       "utf-8"							)
			with lzma.open(UpperCamelCase				,       "wb"							) as f:
						f.write(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			int:


			"""simple docstring"""
			import zipfile

			__UpperCAmelCase	: Dict		=					tmp_path_factory.mktemp("data"							) / "file.txt.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""
			if datasets.config.ZSTANDARD_AVAILABLE:
						import zstandard as zstd

						__UpperCAmelCase	: int		=					tmp_path_factory.mktemp("data"							) / "file.txt.zst"
						__UpperCAmelCase	: Dict		=					bytes(UpperCamelCase				,       "utf-8"							)
						with zstd.open(UpperCamelCase				,       "wb"							) as f:
									f.write(UpperCamelCase							)
						return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Dict:


			"""simple docstring"""
			__UpperCAmelCase	: Tuple		=					tmp_path_factory.mktemp("data"							) / "file.xml"
			__UpperCAmelCase	: str		=					textwrap.dedent(
			    "\\n    <?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n    <tmx version=\"1.4\">\n      <header segtype=\"sentence\" srclang=\"ca\" />\n      <body>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 1</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 1</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 2</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 2</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 3</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 3</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 4</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 4</seg></tuv>\n        </tu>\n        <tu>\n          <tuv xml:lang=\"ca\"><seg>Contingut 5</seg></tuv>\n          <tuv xml:lang=\"en\"><seg>Content 5</seg></tuv>\n        </tu>\n      </body>\n    </tmx>"							)
			with open(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase							)
			return filename


A   =       [
    {"""col_1""": """0""", """col_2""": 0, """col_3""": 0.0},
    {"""col_1""": """1""", """col_2""": 1, """col_3""": 1.0},
    {"""col_1""": """2""", """col_2""": 2, """col_3""": 2.0},
    {"""col_1""": """3""", """col_2""": 3, """col_3""": 3.0},
]
A   =       [
    {"""col_1""": """4""", """col_2""": 4, """col_3""": 4.0},
    {"""col_1""": """5""", """col_2""": 5, """col_3""": 5.0},
]
A   =       {
    """col_1""": ["""0""", """1""", """2""", """3"""],
    """col_2""": [0, 1, 2, 3],
    """col_3""": [0.0, 1.0, 2.0, 3.0],
}

A   =       [
    {"""col_3""": 0.0, """col_1""": """0""", """col_2""": 0},
    {"""col_3""": 1.0, """col_1""": """1""", """col_2""": 1},
]

A   =       [
    {"""col_1""": """s0""", """col_2""": 0, """col_3""": 0.0},
    {"""col_1""": """s1""", """col_2""": 1, """col_3""": 1.0},
    {"""col_1""": """s2""", """col_2""": 2, """col_3""": 2.0},
    {"""col_1""": """s3""", """col_2""": 3, """col_3""": 3.0},
]

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			)			->			List[str]:


			"""simple docstring"""
			return DATA_DICT_OF_LISTS

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			str:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					datasets.Dataset.from_dict(UpperCamelCase							)
			__UpperCAmelCase	: List[str]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.arrow"							)
			dataset.map(cache_file_name=UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.sqlite"							)
			with contextlib.closing(sqlitea.connect(UpperCamelCase							)							) as con:
						__UpperCAmelCase	: Optional[Any]		=					con.cursor()
						cur.execute("CREATE TABLE dataset(col_1 text, col_2 int, col_3 real)"							)
						for item in DATA:
									cur.execute("INSERT INTO dataset(col_1, col_2, col_3) VALUES (?, ?, ?)"				,       tuple(item.values()							)							)
						con.commit()
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: List[str]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.csv"							)
			with open(UpperCamelCase				,       "w"				,       newline=""							) as f:
						__UpperCAmelCase	: Dict		=					csv.DictWriter(UpperCamelCase				,       fieldnames=["col_1", "col_2", "col_3"]							)
						writer.writeheader()
						for item in DATA:
									writer.writerow(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			List[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: int		=					str(tmp_path_factory.mktemp("data"							) / "dataset2.csv"							)
			with open(UpperCamelCase				,       "w"				,       newline=""							) as f:
						__UpperCAmelCase	: str		=					csv.DictWriter(UpperCamelCase				,       fieldnames=["col_1", "col_2", "col_3"]							)
						writer.writeheader()
						for item in DATA:
									writer.writerow(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			Any:


			"""simple docstring"""
			import bza

			__UpperCAmelCase	: List[str]		=					tmp_path_factory.mktemp("data"							) / "dataset.csv.bz2"
			with open(UpperCamelCase				,       "rb"							) as f:
						__UpperCAmelCase	: Any		=					f.read()
			# data = bytes(FILE_CONTENT, "utf-8")
			with bza.open(UpperCamelCase				,       "wb"							) as f:
						f.write(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: Union[str, Any]		=					tmp_path_factory.mktemp("data"							) / "dataset.csv.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					tmp_path_factory.mktemp("data"							) / "dataset.csv.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(csv_path.replace(".csv"				,       ".CSV"							)							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename(csva_path.replace(".csv"				,       ".CSV"							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: Union[str, Any]		=					tmp_path_factory.mktemp("data"							) / "dataset_with_dir.csv.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Tuple:


			"""simple docstring"""
			__UpperCAmelCase	: Tuple		=					str(tmp_path_factory.mktemp("data"							) / "dataset.parquet"							)
			__UpperCAmelCase	: Tuple		=					pa.schema(
			    {
			        "col_1": pa.string(),
			        "col_2": pa.intaa(),
			        "col_3": pa.floataa(),
			    }							)
			with open(UpperCamelCase				,       "wb"							) as f:
						__UpperCAmelCase	: str		=					pq.ParquetWriter(UpperCamelCase				,       schema=UpperCamelCase							)
						__UpperCAmelCase	: Union[str, Any]		=					pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(UpperCamelCase							)							)] for k in DATA[0]}				,       schema=UpperCamelCase							)
						writer.write_table(UpperCamelCase							)
						writer.close()
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			str:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.json"							)
			__UpperCAmelCase	: int		=					{"data": DATA}
			with open(UpperCamelCase				,       "w"							) as f:
						json.dump(UpperCamelCase				,       UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.json"							)
			__UpperCAmelCase	: List[Any]		=					{"data": DATA_DICT_OF_LISTS}
			with open(UpperCamelCase				,       "w"							) as f:
						json.dump(UpperCamelCase				,       UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					str(tmp_path_factory.mktemp("data"							) / "dataset.jsonl"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in DATA:
									f.write(json.dumps(UpperCamelCase							) + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			List[str]:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					str(tmp_path_factory.mktemp("data"							) / "dataset2.jsonl"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in DATA:
									f.write(json.dumps(UpperCamelCase							) + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Any:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					str(tmp_path_factory.mktemp("data"							) / "dataset_312.jsonl"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in DATA_312:
									f.write(json.dumps(UpperCamelCase							) + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Dict:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset-str.jsonl"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in DATA_STR:
									f.write(json.dumps(UpperCamelCase							) + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			Dict:


			"""simple docstring"""
			import gzip

			__UpperCAmelCase	: Optional[Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.txt.gz"							)
			with open(UpperCamelCase				,       "rb"							) as orig_file:
						with gzip.open(UpperCamelCase				,       "wb"							) as zipped_file:
									zipped_file.writelines(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			str:


			"""simple docstring"""
			import gzip

			__UpperCAmelCase	: List[Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.jsonl.gz"							)
			with open(UpperCamelCase				,       "rb"							) as orig_file:
						with gzip.open(UpperCamelCase				,       "wb"							) as zipped_file:
									zipped_file.writelines(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: List[str]		=					tmp_path_factory.mktemp("data"							) / "dataset.jsonl.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Any:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					tmp_path_factory.mktemp("data"							) / "dataset_nested.jsonl.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.join("nested"				,       os.path.basename(UpperCamelCase							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Any:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					tmp_path_factory.mktemp("data"							) / "dataset_with_dir.jsonl.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			str:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					tmp_path_factory.mktemp("data"							) / "dataset.jsonl.tar"
			with tarfile.TarFile(UpperCamelCase				,       "w"							) as f:
						f.add(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						f.add(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					tmp_path_factory.mktemp("data"							) / "dataset_nested.jsonl.tar"
			with tarfile.TarFile(UpperCamelCase				,       "w"							) as f:
						f.add(UpperCamelCase				,       arcname=os.path.join("nested"				,       os.path.basename(UpperCamelCase							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Tuple:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					["0", "1", "2", "3"]
			__UpperCAmelCase	: Union[str, Any]		=					str(tmp_path_factory.mktemp("data"							) / "dataset.txt"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in data:
									f.write(item + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Union[str, Any]:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					["0", "1", "2", "3"]
			__UpperCAmelCase	: Any		=					str(tmp_path_factory.mktemp("data"							) / "dataset2.txt"							)
			with open(UpperCamelCase				,       "w"							) as f:
						for item in data:
									f.write(item + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			str:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					["0", "1", "2", "3"]
			__UpperCAmelCase	: List[Any]		=					tmp_path_factory.mktemp("data"							) / "dataset.abc"
			with open(UpperCamelCase				,       "w"							) as f:
						for item in data:
									f.write(item + "\n"							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Optional[int]:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					tmp_path_factory.mktemp("data"							) / "dataset.text.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			Dict:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					tmp_path_factory.mktemp("data"							) / "dataset_with_dir.text.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
						f.write(UpperCamelCase				,       arcname=os.path.join("main_dir"				,       os.path.basename(UpperCamelCase							)							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							)			->			str:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					tmp_path_factory.mktemp("data"							) / "dataset.ext.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename("unsupported.ext"							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename("unsupported_2.ext"							)							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[Any]		=					"\n".join(["First", "Second\u2029with Unicode new line", "Third"]							)
			__UpperCAmelCase	: int		=					str(tmp_path_factory.mktemp("data"							) / "dataset_with_unicode_new_lines.txt"							)
			with open(UpperCamelCase				,       "w"				,       encoding="utf-8"							) as f:
						f.write(UpperCamelCase							)
			return path

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			)			->			Dict:


			"""simple docstring"""
			return os.path.join("tests"				,       "features"				,       "data"				,       "test_image_rgb.jpg"							)

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			)			->			Optional[Any]:


			"""simple docstring"""
			return os.path.join("tests"				,       "features"				,       "data"				,       "test_audio_44100.wav"							)

@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			List[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					tmp_path_factory.mktemp("data"							) / "dataset.img.zip"
			with zipfile.ZipFile(UpperCamelCase				,       "w"							) as f:
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							)							)
						f.write(UpperCamelCase				,       arcname=os.path.basename(UpperCamelCase							).replace(".jpg"				,       "2.jpg"							)							)
			return path





@pytest.fixture(scope="session"							)
def 					_UpperCamelCase    (			UpperCamelCase							)			->			Optional[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: List[Any]		=					tmp_path_factory.mktemp("data_dir"							)

			(data_dir / "subdir").mkdir()
			with open(data_dir / "subdir" / "train.txt"				,       "w"							) as f:
						f.write("foo\n" * 10							)
			with open(data_dir / "subdir" / "test.txt"				,       "w"							) as f:
						f.write("bar\n" * 10							)
			# hidden file
			with open(data_dir / "subdir" / ".test.txt"				,       "w"							) as f:
						f.write("bar\n" * 10							)

			# hidden directory
			(data_dir / ".subdir").mkdir()
			with open(data_dir / ".subdir" / "train.txt"				,       "w"							) as f:
						f.write("foo\n" * 10							)
			with open(data_dir / ".subdir" / "test.txt"				,       "w"							) as f:
						f.write("bar\n" * 10							)

			return data_dir








"""simple docstring"""





def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase = False							)			->			bool:


			"""simple docstring"""
			if n == 2:
						return True
			if not n % 2 or n < 2:
						return False
			if n > 5 and n % 10 not in (1, 3, 7, 9):  # can quickly check last digit
						return False
			if n > 3_3170_4406_4679_8873_8596_1981 and not allow_probable:
						raise ValueError(
						    "Warning: upper bound of deterministic test is exceeded. "
						    "Pass allow_probable=True to allow probabilistic test. "
						    "A return value of True indicates a probable prime."							)
			# array bounds provided by analysis
			__UpperCAmelCase	: List[str]		=					[
			    2047,
			    137_3653,
			    2532_6001,
			    32_1503_1751,
			    2_1523_0289_8747,
			    3_4747_4966_0383,
			    341_5500_7172_8321,
			    1,
			    382_5123_0565_4641_3051,
			    1,
			    1,
			    3186_6585_7834_0311_5116_7461,
			    3_3170_4406_4679_8873_8596_1981,
			]

			__UpperCAmelCase	: Tuple		=					[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]
			for idx, _p in enumerate(UpperCamelCase				,       1							):
						if n < _p:
									# then we have our last prime to check
									__UpperCAmelCase	: Tuple		=					primes[:idx]
									break
			__UpperCAmelCase	,     __UpperCAmelCase	: List[str]		=					n - 1, 0
			# break up n -1 into a power of 2 (s) and
			# remaining odd component
			# essentially, solve for d * 2 ** s == n - 1
			while d % 2 == 0:
						d //= 2
						s += 1
			for prime in plist:
						__UpperCAmelCase	: Optional[int]		=					False
						for r in range(UpperCamelCase							):
									__UpperCAmelCase	: Dict		=					pow(UpperCamelCase				,       d * 2**r				,       UpperCamelCase							)
									# see article for analysis explanation for m
									if (r == 0 and m == 1) or ((m + 1) % n == 0):
												__UpperCAmelCase	: Optional[int]		=					True
												# this loop will not determine compositeness
												break
						if pr:
									continue
						# if pr is False, then the above loop never evaluated to true,
						# and the n MUST be composite
						return False
			return True

def 					_UpperCamelCase    (			)			->			None:


			"""simple docstring"""
			assert not miller_rabin(561							)
			assert miller_rabin(563							)
			# 2047

			assert not miller_rabin(83_8201							)
			assert miller_rabin(83_8207							)
			# 1_373_653

			assert not miller_rabin(1731_6001							)
			assert miller_rabin(1731_6017							)
			# 25_326_001

			assert not miller_rabin(30_7838_6641							)
			assert miller_rabin(30_7838_6653							)
			# 3_215_031_751

			assert not miller_rabin(1_7130_4557_4801							)
			assert miller_rabin(1_7130_4557_4819							)
			# 2_152_302_898_747

			assert not miller_rabin(2_7797_9972_8307							)
			assert miller_rabin(2_7797_9972_8327							)
			# 3_474_749_660_383

			assert not miller_rabin(113_8500_2390_9441							)
			assert miller_rabin(113_8500_2390_9527							)
			# 341_550_071_728_321

			assert not miller_rabin(127_5041_0188_4880_4351							)
			assert miller_rabin(127_5041_0188_4880_4391							)
			# 3_825_123_056_546_413_051

			assert not miller_rabin(796_6646_4458_5077_8779_1867							)
			assert miller_rabin(796_6646_4458_5077_8779_1951							)
			# 318_665_857_834_031_151_167_461

			assert not miller_rabin(5528_4067_7446_6478_9766_0333							)
			assert miller_rabin(5528_4067_7446_6478_9766_0359							)
			# 3_317_044_064_679_887_385_961_981
			# upper limit for probabilistic test


if __name__ == "__main__":
					test_miller_rabin()


