




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 			a   ():
							SCREAMING_SNAKE_CASE_   	=    1_0
							SCREAMING_SNAKE_CASE_   	=    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_   	=    datasets.Dataset.from_dict(
							    {
							        '''tokens''': [['''foo'''] * 5] * n,
							        '''labels''': [[1] * 5] * n,
							        '''answers''': [{'''answer_start''': [9_7], '''text''': ['''1976''']}] * 1_0,
							        '''id''': list(range(_lowerCAmelCase     )     ),
							    }  ,    features=_lowerCAmelCase  ,    )
							return dataset

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''file.arrow'''     )
							dataset.map(cache_file_name=_lowerCAmelCase     )
							return filename


# FILE_CONTENT + files


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

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt'''
							SCREAMING_SNAKE_CASE_   	=    FILE_CONTENT
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase     )
							return filename

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							import bza

							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.bz2'''
							SCREAMING_SNAKE_CASE_   	=    bytes(_lowerCAmelCase  ,    '''utf-8'''     )
							with bza.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
														f.write(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							import gzip

							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''file.txt.gz'''     )
							SCREAMING_SNAKE_CASE_   	=    bytes(_lowerCAmelCase  ,    '''utf-8'''     )
							with gzip.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
														f.write(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							if datasets.config.LZ4_AVAILABLE:
														import lza.frame

														SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.lz4'''
														SCREAMING_SNAKE_CASE_   	=    bytes(_lowerCAmelCase  ,    '''utf-8'''     )
														with lza.frame.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
																					f.write(_lowerCAmelCase     )
														return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							if datasets.config.PY7ZR_AVAILABLE:
														import pyazr

														SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.7z'''
														with pyazr.SevenZipFile(_lowerCAmelCase  ,    '''w'''     ) as archive:
																					archive.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							import tarfile

							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.tar'''
							with tarfile.TarFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.add(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							import lzma

							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.xz'''
							SCREAMING_SNAKE_CASE_   	=    bytes(_lowerCAmelCase  ,    '''utf-8'''     )
							with lzma.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
														f.write(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							import zipfile

							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							if datasets.config.ZSTANDARD_AVAILABLE:
														import zstandard as zstd

														SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.txt.zst'''
														SCREAMING_SNAKE_CASE_   	=    bytes(_lowerCAmelCase  ,    '''utf-8'''     )
														with zstd.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
																					f.write(_lowerCAmelCase     )
														return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''file.xml'''
							SCREAMING_SNAKE_CASE_   	=    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(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase     )
							return filename


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

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

__SCREAMING_SNAKE_CASE 						=[
    {"""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 			a   ():
							return DATA_DICT_OF_LISTS

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    datasets.Dataset.from_dict(_lowerCAmelCase     )
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.arrow'''     )
							dataset.map(cache_file_name=_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.sqlite'''     )
							with contextlib.closing(sqlitea.connect(_lowerCAmelCase     )     ) as con:
														SCREAMING_SNAKE_CASE_   	=    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 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.csv'''     )
							with open(_lowerCAmelCase  ,    '''w'''  ,    newline=''''''     ) as f:
														SCREAMING_SNAKE_CASE_   	=    csv.DictWriter(_lowerCAmelCase  ,    fieldnames=['''col_1''', '''col_2''', '''col_3''']     )
														writer.writeheader()
														for item in DATA:
																					writer.writerow(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset2.csv'''     )
							with open(_lowerCAmelCase  ,    '''w'''  ,    newline=''''''     ) as f:
														SCREAMING_SNAKE_CASE_   	=    csv.DictWriter(_lowerCAmelCase  ,    fieldnames=['''col_1''', '''col_2''', '''col_3''']     )
														writer.writeheader()
														for item in DATA:
																					writer.writerow(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							import bza

							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.csv.bz2'''
							with open(_lowerCAmelCase  ,    '''rb'''     ) as f:
														SCREAMING_SNAKE_CASE_   	=    f.read()
							# data = bytes(FILE_CONTENT, "utf-8")
							with bza.open(_lowerCAmelCase  ,    '''wb'''     ) as f:
														f.write(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.csv.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.csv.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(csv_path.replace('''.csv'''  ,    '''.CSV'''     )     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(csva_path.replace('''.csv'''  ,    '''.CSV'''     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset_with_dir.csv.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.parquet'''     )
							SCREAMING_SNAKE_CASE_   	=    pa.schema(
							    {
							        '''col_1''': pa.string(),
							        '''col_2''': pa.intaa(),
							        '''col_3''': pa.floataa(),
							    }     )
							with open(_lowerCAmelCase  ,    '''wb'''     ) as f:
														SCREAMING_SNAKE_CASE_   	=    pq.ParquetWriter(_lowerCAmelCase  ,    schema=_lowerCAmelCase     )
														SCREAMING_SNAKE_CASE_   	=    pa.Table.from_pydict({k: [DATA[i][k] for i in range(len(_lowerCAmelCase     )     )] for k in DATA[0]}  ,    schema=_lowerCAmelCase     )
														writer.write_table(_lowerCAmelCase     )
														writer.close()
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.json'''     )
							SCREAMING_SNAKE_CASE_   	=    {'''data''': DATA}
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														json.dump(_lowerCAmelCase  ,    _lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.json'''     )
							SCREAMING_SNAKE_CASE_   	=    {'''data''': DATA_DICT_OF_LISTS}
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														json.dump(_lowerCAmelCase  ,    _lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.jsonl'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in DATA:
																					f.write(json.dumps(_lowerCAmelCase     ) + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset2.jsonl'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in DATA:
																					f.write(json.dumps(_lowerCAmelCase     ) + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset_312.jsonl'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in DATA_312:
																					f.write(json.dumps(_lowerCAmelCase     ) + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset-str.jsonl'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in DATA_STR:
																					f.write(json.dumps(_lowerCAmelCase     ) + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							import gzip

							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.txt.gz'''     )
							with open(_lowerCAmelCase  ,    '''rb'''     ) as orig_file:
														with gzip.open(_lowerCAmelCase  ,    '''wb'''     ) as zipped_file:
																					zipped_file.writelines(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							import gzip

							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.jsonl.gz'''     )
							with open(_lowerCAmelCase  ,    '''rb'''     ) as orig_file:
														with gzip.open(_lowerCAmelCase  ,    '''wb'''     ) as zipped_file:
																					zipped_file.writelines(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.jsonl.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset_nested.jsonl.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''nested'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset_with_dir.jsonl.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.jsonl.tar'''
							with tarfile.TarFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.add(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														f.add(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset_nested.jsonl.tar'''
							with tarfile.TarFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.add(_lowerCAmelCase  ,    arcname=os.path.join('''nested'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset.txt'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in data:
																					f.write(item + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset2.txt'''     )
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in data:
																					f.write(item + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    ['''0''', '''1''', '''2''', '''3''']
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.abc'''
							with open(_lowerCAmelCase  ,    '''w'''     ) as f:
														for item in data:
																					f.write(item + '''\n'''     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.text.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset_with_dir.text.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.join('''main_dir'''  ,    os.path.basename(_lowerCAmelCase     )     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.ext.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename('''unsupported.ext'''     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename('''unsupported_2.ext'''     )     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    '''\n'''.join(['''First''', '''Second\u2029with Unicode new line''', '''Third''']     )
							SCREAMING_SNAKE_CASE_   	=    str(tmp_path_factory.mktemp('''data'''     ) / '''dataset_with_unicode_new_lines.txt'''     )
							with open(_lowerCAmelCase  ,    '''w'''  ,    encoding='''utf-8'''     ) as f:
														f.write(_lowerCAmelCase     )
							return path

@pytest.fixture(scope='''session'''     )
def 			a   ():
							return os.path.join('''tests'''  ,    '''features'''  ,    '''data'''  ,    '''test_image_rgb.jpg'''     )

@pytest.fixture(scope='''session'''     )
def 			a   ():
							return os.path.join('''tests'''  ,    '''features'''  ,    '''data'''  ,    '''test_audio_44100.wav'''     )

@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase  ,    _lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data'''     ) / '''dataset.img.zip'''
							with zipfile.ZipFile(_lowerCAmelCase  ,    '''w'''     ) as f:
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     )     )
														f.write(_lowerCAmelCase  ,    arcname=os.path.basename(_lowerCAmelCase     ).replace('''.jpg'''  ,    '''2.jpg'''     )     )
							return path






@pytest.fixture(scope='''session'''     )
def 			a   (_lowerCAmelCase     ):
							SCREAMING_SNAKE_CASE_   	=    tmp_path_factory.mktemp('''data_dir'''     )

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

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

							return data_dir








import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
from .feature_extraction_wavaveca import WavaVecaFeatureExtractor
from .tokenization_wavaveca import WavaVecaCTCTokenizer






class  __magic_name__						(  __UpperCAmelCase):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							List[str]	      =					"Wav2Vec2FeatureExtractor"
				SCREAMING_SNAKE_CASE__					:							List[Any]	      =					"AutoTokenizer"


				def __init__(							self:   Tuple		,					_lowerCamelCase:   str		,					_lowerCamelCase:   Optional[Any]		):
											super().__init__(_lowerCamelCase		,					_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    self.feature_extractor
											SCREAMING_SNAKE_CASE_   	=    False


				@classmethod
				def     _A							(							cls:   List[Any]		,					_lowerCamelCase:   Tuple		,					**_lowerCamelCase:   List[str]		):
											try:
																		return super().from_pretrained(_lowerCamelCase		,					**_lowerCamelCase		)
											except OSError:
																		warnings.warn(
																		    f"Loading a tokenizer inside {cls.__name__} from a config that does not"
																		    ''' include a `tokenizer_class` attribute is deprecated and will be '''
																		    '''removed in v5. Please add `\'tokenizer_class\': \'Wav2Vec2CTCTokenizer\'`'''
																		    ''' attribute to either your `config.json` or `tokenizer_config.json` '''
																		    '''file to suppress this warning: '''		,					_lowerCamelCase		,					)

																		SCREAMING_SNAKE_CASE_   	=    WavaVecaFeatureExtractor.from_pretrained(_lowerCamelCase		,					**_lowerCamelCase		)
																		SCREAMING_SNAKE_CASE_   	=    WavaVecaCTCTokenizer.from_pretrained(_lowerCamelCase		,					**_lowerCamelCase		)

																		return cls(feature_extractor=_lowerCamelCase		,					tokenizer=_lowerCamelCase		)


				def __call__(							self:   Union[str, Any]		,					*_lowerCamelCase:   List[Any]		,					**_lowerCamelCase:   str		):
											# For backward compatibility
											if self._in_target_context_manager:
																		return self.current_processor(*_lowerCamelCase		,					**_lowerCamelCase		)

											if "raw_speech" in kwargs:
																		warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''		)
																		SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''raw_speech'''		)
											else:
																		SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''audio'''		,					_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''sampling_rate'''		,					_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''text'''		,					_lowerCamelCase		)
											if len(_lowerCamelCase		) > 0:
																		SCREAMING_SNAKE_CASE_   	=    args[0]
																		SCREAMING_SNAKE_CASE_   	=    args[1:]

											if audio is None and text is None:
																		raise ValueError('''You need to specify either an `audio` or `text` input to process.'''		)

											if audio is not None:
																		SCREAMING_SNAKE_CASE_   	=    self.feature_extractor(_lowerCamelCase		,					*_lowerCamelCase		,					sampling_rate=_lowerCamelCase		,					**_lowerCamelCase		)
											if text is not None:
																		SCREAMING_SNAKE_CASE_   	=    self.tokenizer(_lowerCamelCase		,					**_lowerCamelCase		)

											if text is None:
																		return inputs
											elif audio is None:
																		return encodings
											else:
																		SCREAMING_SNAKE_CASE_   	=    encodings['''input_ids''']
																		return inputs


				def     _A							(							self:   Optional[int]		,					*_lowerCamelCase:   str		,					**_lowerCamelCase:   List[Any]		):
											# For backward compatibility
											if self._in_target_context_manager:
																		return self.current_processor.pad(*_lowerCamelCase		,					**_lowerCamelCase		)

											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''input_features'''		,					_lowerCamelCase		)
											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''labels'''		,					_lowerCamelCase		)
											if len(_lowerCamelCase		) > 0:
																		SCREAMING_SNAKE_CASE_   	=    args[0]
																		SCREAMING_SNAKE_CASE_   	=    args[1:]

											if input_features is not None:
																		SCREAMING_SNAKE_CASE_   	=    self.feature_extractor.pad(_lowerCamelCase		,					*_lowerCamelCase		,					**_lowerCamelCase		)
											if labels is not None:
																		SCREAMING_SNAKE_CASE_   	=    self.tokenizer.pad(_lowerCamelCase		,					**_lowerCamelCase		)

											if labels is None:
																		return input_features
											elif input_features is None:
																		return labels
											else:
																		SCREAMING_SNAKE_CASE_   	=    labels['''input_ids''']
																		return input_features


				def     _A							(							self:   str		,					*_lowerCamelCase:   Dict		,					**_lowerCamelCase:   Dict		):
											return self.tokenizer.batch_decode(*_lowerCamelCase		,					**_lowerCamelCase		)


				def     _A							(							self:   Optional[int]		,					*_lowerCamelCase:   Optional[int]		,					**_lowerCamelCase:   Tuple		):
											return self.tokenizer.decode(*_lowerCamelCase		,					**_lowerCamelCase		)





				@contextmanager
				def     _A							(							self:   Tuple		):
											warnings.warn(
											    '''`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '''
											    '''labels by using the argument `text` of the regular `__call__` method (either in the same call as '''
											    '''your audio inputs, or in a separate call.'''		)
											SCREAMING_SNAKE_CASE_   	=    True
											SCREAMING_SNAKE_CASE_   	=    self.tokenizer
											yield
											SCREAMING_SNAKE_CASE_   	=    self.feature_extractor
											SCREAMING_SNAKE_CASE_   	=    False


