



'''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 (    ):
							SCREAMING_SNAKE_CASE       :   Dict         =      10
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      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'''					),
							    }					)
							SCREAMING_SNAKE_CASE       :   Optional[Any]         =      datasets.Dataset.from_dict(
							    {
							        '''tokens''': [['''foo'''] * 5] * n,
							        '''labels''': [[1] * 5] * n,
							        '''answers''': [{'''answer_start''': [97], '''text''': ['''1976''']}] * 10,
							        '''id''': list(range(A					)					),
							    }       ,		features=A       ,		)
							return dataset
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Any       ,		A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   List[str]         =      str(tmp_path_factory.mktemp('''data'''					) / '''file.arrow'''					)
							dataset.map(cache_file_name=A					)
							return filename


# FILE_CONTENT + files


lowerCAmelCase_  :							Dict             =    '\\n    Text data.\n    Second line of data.'
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[int]					):
							SCREAMING_SNAKE_CASE       :   Tuple         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt'''
							SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      FILE_CONTENT
							with open(A       ,		'''w'''					) as f:
														f.write(A					)
							return filename
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[str]					):
							import bza

							SCREAMING_SNAKE_CASE       :   Any         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.bz2'''
							SCREAMING_SNAKE_CASE       :   Any         =      bytes(A       ,		'''utf-8'''					)
							with bza.open(A       ,		'''wb'''					) as f:
														f.write(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					str					):
							import gzip

							SCREAMING_SNAKE_CASE       :   str         =      str(tmp_path_factory.mktemp('''data'''					) / '''file.txt.gz'''					)
							SCREAMING_SNAKE_CASE       :   List[Any]         =      bytes(A       ,		'''utf-8'''					)
							with gzip.open(A       ,		'''wb'''					) as f:
														f.write(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]					):
							if datasets.config.LZ4_AVAILABLE:
														import lza.frame

														SCREAMING_SNAKE_CASE       :   List[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.lz4'''
														SCREAMING_SNAKE_CASE       :   Tuple         =      bytes(A       ,		'''utf-8'''					)
														with lza.frame.open(A       ,		'''wb'''					) as f:
																					f.write(A					)
														return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					str       ,		A	:					Tuple					):
							if datasets.config.PY7ZR_AVAILABLE:
														import pyazr

														SCREAMING_SNAKE_CASE       :   Any         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.7z'''
														with pyazr.SevenZipFile(A       ,		'''w'''					) as archive:
																					archive.write(A       ,		arcname=os.path.basename(A					)					)
														return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					Tuple					):
							import tarfile

							SCREAMING_SNAKE_CASE       :   Dict         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.tar'''
							with tarfile.TarFile(A       ,		'''w'''					) as f:
														f.add(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					int					):
							import lzma

							SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.xz'''
							SCREAMING_SNAKE_CASE       :   List[Any]         =      bytes(A       ,		'''utf-8'''					)
							with lzma.open(A       ,		'''wb'''					) as f:
														f.write(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[Any]       ,		A	:					Optional[Any]					):
							import zipfile

							SCREAMING_SNAKE_CASE       :   Optional[int]         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]					):
							if datasets.config.ZSTANDARD_AVAILABLE:
														import zstandard as zstd

														SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      tmp_path_factory.mktemp('''data'''					) / '''file.txt.zst'''
														SCREAMING_SNAKE_CASE       :   int         =      bytes(A       ,		'''utf-8'''					)
														with zstd.open(A       ,		'''wb'''					) as f:
																					f.write(A					)
														return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]					):
							SCREAMING_SNAKE_CASE       :   str         =      tmp_path_factory.mktemp('''data'''					) / '''file.xml'''
							SCREAMING_SNAKE_CASE       :   List[Any]         =      textwrap.dedent(
							    '''\
    <?xml version="1.0" encoding="UTF-8" ?>
    <tmx version="1.4">
      <header segtype="sentence" srclang="ca" />
      <body>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 1</seg></tuv>
          <tuv xml:lang="en"><seg>Content 1</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 2</seg></tuv>
          <tuv xml:lang="en"><seg>Content 2</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 3</seg></tuv>
          <tuv xml:lang="en"><seg>Content 3</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 4</seg></tuv>
          <tuv xml:lang="en"><seg>Content 4</seg></tuv>
        </tu>
        <tu>
          <tuv xml:lang="ca"><seg>Contingut 5</seg></tuv>
          <tuv xml:lang="en"><seg>Content 5</seg></tuv>
        </tu>
      </body>
    </tmx>'''					)
							with open(A       ,		'''w'''					) as f:
														f.write(A					)
							return filename


lowerCAmelCase_  :							Any             =    [
    {'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},
]
lowerCAmelCase_  :							Any             =    [
    {'col_1': '4', 'col_2': 4, 'col_3': 4.0},
    {'col_1': '5', 'col_2': 5, 'col_3': 5.0},
]
lowerCAmelCase_  :							Union[str, Any]             =    {
    'col_1': ['0', '1', '2', '3'],
    'col_2': [0, 1, 2, 3],
    'col_3': [0.0, 1.0, 2.0, 3.0],
}

lowerCAmelCase_  :							int             =    [
    {'col_3': 0.0, 'col_1': '0', 'col_2': 0},
    {'col_3': 1.0, 'col_1': '1', 'col_2': 1},
]

lowerCAmelCase_  :							Dict             =    [
    {'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 (    ):
							return DATA_DICT_OF_LISTS
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[str]					):
							SCREAMING_SNAKE_CASE       :   Dict         =      datasets.Dataset.from_dict(A					)
							SCREAMING_SNAKE_CASE       :   Tuple         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.arrow'''					)
							dataset.map(cache_file_name=A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[int]					):
							SCREAMING_SNAKE_CASE       :   Any         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.sqlite'''					)
							with contextlib.closing(sqlitea.connect(A					)					) as con:
														SCREAMING_SNAKE_CASE       :   Dict         =      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 (    A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.csv'''					)
							with open(A       ,		'''w'''       ,		newline=''''''					) as f:
														SCREAMING_SNAKE_CASE       :   List[Any]         =      csv.DictWriter(A       ,		fieldnames=['''col_1''', '''col_2''', '''col_3''']					)
														writer.writeheader()
														for item in DATA:
																					writer.writerow(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Any					):
							SCREAMING_SNAKE_CASE       :   str         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset2.csv'''					)
							with open(A       ,		'''w'''       ,		newline=''''''					) as f:
														SCREAMING_SNAKE_CASE       :   List[str]         =      csv.DictWriter(A       ,		fieldnames=['''col_1''', '''col_2''', '''col_3''']					)
														writer.writeheader()
														for item in DATA:
																					writer.writerow(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					str       ,		A	:					Union[str, Any]					):
							import bza

							SCREAMING_SNAKE_CASE       :   int         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.csv.bz2'''
							with open(A       ,		'''rb'''					) as f:
														SCREAMING_SNAKE_CASE       :   Optional[Any]         =      f.read()
							# data = bytes(FILE_CONTENT, "utf-8")
							with bza.open(A       ,		'''wb'''					) as f:
														f.write(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[int]       ,		A	:					Dict       ,		A	:					Dict					):
							SCREAMING_SNAKE_CASE       :   Dict         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.csv.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(A					)					)
														f.write(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[int]       ,		A	:					List[str]       ,		A	:					Dict					):
							SCREAMING_SNAKE_CASE       :   Dict         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.csv.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(csv_path.replace('''.csv'''       ,		'''.CSV'''					)					)					)
														f.write(A       ,		arcname=os.path.basename(csva_path.replace('''.csv'''       ,		'''.CSV'''					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					Tuple       ,		A	:					Dict					):
							SCREAMING_SNAKE_CASE       :   int         =      tmp_path_factory.mktemp('''data'''					) / '''dataset_with_dir.csv.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]					):
							SCREAMING_SNAKE_CASE       :   int         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.parquet'''					)
							SCREAMING_SNAKE_CASE       :   List[str]         =      pa.schema(
							    {
							        '''col_1''': pa.string(),
							        '''col_2''': pa.intaa(),
							        '''col_3''': pa.floataa(),
							    }					)
							with open(A       ,		'''wb'''					) as f:
														SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      pq.ParquetWriter(A       ,		schema=A					)
														SCREAMING_SNAKE_CASE       :   Dict         =      pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(A					)					)] for k in DATA[0]}       ,		schema=A					)
														writer.write_table(A					)
														writer.close()
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Dict					):
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.json'''					)
							SCREAMING_SNAKE_CASE       :   Optional[Any]         =      {'''data''': DATA}
							with open(A       ,		'''w'''					) as f:
														json.dump(A       ,		A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					str					):
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.json'''					)
							SCREAMING_SNAKE_CASE       :   int         =      {'''data''': DATA_DICT_OF_LISTS}
							with open(A       ,		'''w'''					) as f:
														json.dump(A       ,		A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.jsonl'''					)
							with open(A       ,		'''w'''					) as f:
														for item in DATA:
																					f.write(json.dumps(A					) + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					int					):
							SCREAMING_SNAKE_CASE       :   Optional[Any]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset2.jsonl'''					)
							with open(A       ,		'''w'''					) as f:
														for item in DATA:
																					f.write(json.dumps(A					) + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[str]					):
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset_312.jsonl'''					)
							with open(A       ,		'''w'''					) as f:
														for item in DATA_312:
																					f.write(json.dumps(A					) + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset-str.jsonl'''					)
							with open(A       ,		'''w'''					) as f:
														for item in DATA_STR:
																					f.write(json.dumps(A					) + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[Any]       ,		A	:					Optional[int]					):
							import gzip

							SCREAMING_SNAKE_CASE       :   Tuple         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.txt.gz'''					)
							with open(A       ,		'''rb'''					) as orig_file:
														with gzip.open(A       ,		'''wb'''					) as zipped_file:
																					zipped_file.writelines(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Union[str, Any]       ,		A	:					int					):
							import gzip

							SCREAMING_SNAKE_CASE       :   List[str]         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.jsonl.gz'''					)
							with open(A       ,		'''rb'''					) as orig_file:
														with gzip.open(A       ,		'''wb'''					) as zipped_file:
																					zipped_file.writelines(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Any       ,		A	:					str       ,		A	:					List[Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.jsonl.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(A					)					)
														f.write(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					str       ,		A	:					int       ,		A	:					Any       ,		A	:					int					):
							SCREAMING_SNAKE_CASE       :   Optional[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset_nested.jsonl.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.join('''nested'''       ,		os.path.basename(A					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[Any]       ,		A	:					List[Any]       ,		A	:					Tuple					):
							SCREAMING_SNAKE_CASE       :   List[str]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset_with_dir.jsonl.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					List[Any]       ,		A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.jsonl.tar'''
							with tarfile.TarFile(A       ,		'''w'''					) as f:
														f.add(A       ,		arcname=os.path.basename(A					)					)
														f.add(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Dict       ,		A	:					List[str]       ,		A	:					Dict       ,		A	:					List[Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset_nested.jsonl.tar'''
							with tarfile.TarFile(A       ,		'''w'''					) as f:
														f.add(A       ,		arcname=os.path.join('''nested'''       ,		os.path.basename(A					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   List[Any]         =      ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE       :   int         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset.txt'''					)
							with open(A       ,		'''w'''					) as f:
														for item in data:
																					f.write(item + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Tuple					):
							SCREAMING_SNAKE_CASE       :   Optional[int]         =      ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE       :   Tuple         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset2.txt'''					)
							with open(A       ,		'''w'''					) as f:
														for item in data:
																					f.write(item + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]					):
							SCREAMING_SNAKE_CASE       :   Any         =      ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE       :   List[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.abc'''
							with open(A       ,		'''w'''					) as f:
														for item in data:
																					f.write(item + '''\n'''					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					Optional[int]       ,		A	:					Tuple					):
							SCREAMING_SNAKE_CASE       :   Optional[Any]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.text.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(A					)					)
														f.write(A       ,		arcname=os.path.basename(A					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Union[str, Any]       ,		A	:					str       ,		A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   Any         =      tmp_path_factory.mktemp('''data'''					) / '''dataset_with_dir.text.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
														f.write(A       ,		arcname=os.path.join('''main_dir'''       ,		os.path.basename(A					)					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Optional[Any]       ,		A	:					List[Any]       ,		A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   Dict         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.ext.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename('''unsupported.ext'''					)					)
														f.write(A       ,		arcname=os.path.basename('''unsupported_2.ext'''					)					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[str]					):
							SCREAMING_SNAKE_CASE       :   Union[str, Any]         =      '''\n'''.join(['''First''', '''Second\u2029with Unicode new line''', '''Third''']					)
							SCREAMING_SNAKE_CASE       :   str         =      str(tmp_path_factory.mktemp('''data'''					) / '''dataset_with_unicode_new_lines.txt'''					)
							with open(A       ,		'''w'''       ,		encoding='''utf-8'''					) as f:
														f.write(A					)
							return path
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    ):
							return os.path.join('''tests'''       ,		'''features'''       ,		'''data'''       ,		'''test_image_rgb.jpg'''					)
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    ):
							return os.path.join('''tests'''       ,		'''features'''       ,		'''data'''       ,		'''test_audio_44100.wav'''					)
@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					List[str]       ,		A	:					Dict					):
							SCREAMING_SNAKE_CASE       :   List[str]         =      tmp_path_factory.mktemp('''data'''					) / '''dataset.img.zip'''
							with zipfile.ZipFile(A       ,		'''w'''					) as f:
														f.write(A       ,		arcname=os.path.basename(A					)					)
														f.write(A       ,		arcname=os.path.basename(A					).replace('''.jpg'''       ,		'''2.jpg'''					)					)
							return path






@pytest.fixture(scope='''session'''					)
def        UpperCAmelCase (    A	:					Union[str, Any]					):
							SCREAMING_SNAKE_CASE       :   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'''



from math import pow
def        UpperCAmelCase (    A	:					int       ,		A	:					int       ,		A	:					int       ,		A	:					int       ,		A	:					int       ,		):
							if current_sum == needed_sum:
														# If the sum of the powers is equal to needed_sum, then we have a solution.
														solutions_count += 1
														return current_sum, solutions_count

							SCREAMING_SNAKE_CASE       :   Tuple         =      int(pow(A       ,		A					)					)
							if current_sum + i_to_n <= needed_sum:
														# If the sum of the powers is less than needed_sum, then continue adding powers.
														current_sum += i_to_n
														SCREAMING_SNAKE_CASE       ,SCREAMING_SNAKE_CASE       :   Dict         =      backtrack(
														    A       ,		A       ,		current_number + 1       ,		A       ,		A					)
														current_sum -= i_to_n
							if i_to_n < needed_sum:
														# If the power of i is less than needed_sum, then try with the next power.
														SCREAMING_SNAKE_CASE       ,SCREAMING_SNAKE_CASE       :   int         =      backtrack(
														    A       ,		A       ,		current_number + 1       ,		A       ,		A					)
							return current_sum, solutions_count
def        UpperCAmelCase (    A	:					int       ,		A	:					int					):
							if not (1 <= needed_sum <= 1000 and 2 <= power <= 10):
														raise ValueError(
														    '''Invalid input\n'''
														    '''needed_sum must be between 1 and 1000, power between 2 and 10.'''					)

							return backtrack(A       ,		A       ,		1       ,		0       ,		0					)[1]  # Return the solutions_count


if __name__ == "__main__":
							import doctest

							doctest.testmod()




