






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    __magic_name__    (	)     ->    Dict:
							_lowercase							:   Optional[int] 							=   10
							_lowercase							:   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'				),
							    }				)
							_lowercase							:   Dict 							=   datasets.Dataset.from_dict(
							    {
							        'tokens': [['foo'] * 5] * n,
							        'labels': [[1] * 5] * n,
							        'answers': [{'answer_start': [97], 'text': ['1976']}] * 10,
							        'id': list(range(SCREAMING_SNAKE_CASE				)				),
							    }     ,     features=SCREAMING_SNAKE_CASE     ,     )
							return dataset






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							_lowercase							:   int 							=   str(tmp_path_factory.mktemp('data'				) / 'file.arrow'				)
							dataset.map(cache_file_name=SCREAMING_SNAKE_CASE				)
							return filename


# FILE_CONTENT + files


UpperCamelCase								=		"\\n    Text data.\n    Second line of data."






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Tuple:
							_lowercase							:   Optional[int] 							=   tmp_path_factory.mktemp('data'				) / 'file.txt'
							_lowercase							:   int 							=   FILE_CONTENT
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE				)
							return filename






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							import bza

							_lowercase							:   Dict 							=   tmp_path_factory.mktemp('data'				) / 'file.txt.bz2'
							_lowercase							:   Optional[int] 							=   bytes(SCREAMING_SNAKE_CASE     ,     'utf-8'				)
							with bza.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as f:
														f.write(SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    str:
							import gzip

							_lowercase							:   Optional[int] 							=   str(tmp_path_factory.mktemp('data'				) / 'file.txt.gz'				)
							_lowercase							:   Union[str, Any] 							=   bytes(SCREAMING_SNAKE_CASE     ,     'utf-8'				)
							with gzip.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as f:
														f.write(SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[str]:
							if datasets.config.LZ4_AVAILABLE:
														import lza.frame

														_lowercase							:   List[Any] 							=   tmp_path_factory.mktemp('data'				) / 'file.txt.lz4'
														_lowercase							:   Tuple 							=   bytes(SCREAMING_SNAKE_CASE     ,     'utf-8'				)
														with lza.frame.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as f:
																					f.write(SCREAMING_SNAKE_CASE				)
														return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Tuple:
							if datasets.config.PY7ZR_AVAILABLE:
														import pyazr

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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    List[str]:
							import tarfile

							_lowercase							:   List[Any] 							=   tmp_path_factory.mktemp('data'				) / 'file.txt.tar'
							with tarfile.TarFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.add(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Any:
							import lzma

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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Any:
							import zipfile

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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							if datasets.config.ZSTANDARD_AVAILABLE:
														import zstandard as zstd

														_lowercase							:   Optional[Any] 							=   tmp_path_factory.mktemp('data'				) / 'file.txt.zst'
														_lowercase							:   List[Any] 							=   bytes(SCREAMING_SNAKE_CASE     ,     'utf-8'				)
														with zstd.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as f:
																					f.write(SCREAMING_SNAKE_CASE				)
														return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Optional[int]:
							_lowercase							:   Dict 							=   tmp_path_factory.mktemp('data'				) / 'file.xml'
							_lowercase							:   List[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(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE				)
							return filename


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

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

UpperCamelCase								=		[
    {"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    __magic_name__    (	)     ->    Dict:
							return DATA_DICT_OF_LISTS






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							_lowercase							:   Dict 							=   datasets.Dataset.from_dict(SCREAMING_SNAKE_CASE				)
							_lowercase							:   Dict 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.arrow'				)
							dataset.map(cache_file_name=SCREAMING_SNAKE_CASE				)
							return path






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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Any:
							_lowercase							:   Dict 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset2.csv'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'     ,     newline=''				) as f:
														_lowercase							:   Union[str, Any] 							=   csv.DictWriter(SCREAMING_SNAKE_CASE     ,     fieldnames=['col_1', 'col_2', 'col_3']				)
														writer.writeheader()
														for item in DATA:
																					writer.writerow(SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							import bza

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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Tuple:
							_lowercase							:   List[Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset.csv.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Dict:
							_lowercase							:   int 							=   tmp_path_factory.mktemp('data'				) / 'dataset.csv.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(csv_path.replace('.csv'     ,     '.CSV'				)				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(csva_path.replace('.csv'     ,     '.CSV'				)				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[int]:
							_lowercase							:   Any 							=   tmp_path_factory.mktemp('data'				) / 'dataset_with_dir.csv.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
							return path






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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							_lowercase							:   Union[str, Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.json'				)
							_lowercase							:   Dict 							=   {'data': DATA}
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														json.dump(SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							_lowercase							:   Optional[int] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.json'				)
							_lowercase							:   Optional[Any] 							=   {'data': DATA_DICT_OF_LISTS}
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														json.dump(SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    str:
							_lowercase							:   Optional[Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.jsonl'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in DATA:
																					f.write(json.dumps(SCREAMING_SNAKE_CASE				) + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							_lowercase							:   int 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset2.jsonl'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in DATA:
																					f.write(json.dumps(SCREAMING_SNAKE_CASE				) + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    Dict:
							_lowercase							:   Optional[Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset_312.jsonl'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in DATA_312:
																					f.write(json.dumps(SCREAMING_SNAKE_CASE				) + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    str:
							_lowercase							:   List[Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset-str.jsonl'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in DATA_STR:
																					f.write(json.dumps(SCREAMING_SNAKE_CASE				) + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							import gzip

							_lowercase							:   Union[str, Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.txt.gz'				)
							with open(SCREAMING_SNAKE_CASE     ,     'rb'				) as orig_file:
														with gzip.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as zipped_file:
																					zipped_file.writelines(SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							import gzip

							_lowercase							:   Optional[Any] 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset.jsonl.gz'				)
							with open(SCREAMING_SNAKE_CASE     ,     'rb'				) as orig_file:
														with gzip.open(SCREAMING_SNAKE_CASE     ,     'wb'				) as zipped_file:
																					zipped_file.writelines(SCREAMING_SNAKE_CASE				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							_lowercase							:   List[str] 							=   tmp_path_factory.mktemp('data'				) / 'dataset.jsonl.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    str:
							_lowercase							:   List[Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset_nested.jsonl.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('nested'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							_lowercase							:   Union[str, Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset_with_dir.jsonl.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Union[str, Any]:
							_lowercase							:   Optional[Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset.jsonl.tar'
							with tarfile.TarFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.add(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
														f.add(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Tuple:
							_lowercase							:   Optional[Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset_nested.jsonl.tar'
							with tarfile.TarFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.add(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('nested'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
							return path






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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[str]:
							_lowercase							:   Optional[int] 							=   ['0', '1', '2', '3']
							_lowercase							:   int 							=   str(tmp_path_factory.mktemp('data'				) / 'dataset2.txt'				)
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in data:
																					f.write(item + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    List[Any]:
							_lowercase							:   Tuple 							=   ['0', '1', '2', '3']
							_lowercase							:   str 							=   tmp_path_factory.mktemp('data'				) / 'dataset.abc'
							with open(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														for item in data:
																					f.write(item + '\n'				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    List[str]:
							_lowercase							:   str 							=   tmp_path_factory.mktemp('data'				) / 'dataset.text.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[int]:
							_lowercase							:   Union[str, Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset_with_dir.text.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.join('main_dir'     ,     os.path.basename(SCREAMING_SNAKE_CASE				)				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Optional[Any]:
							_lowercase							:   Union[str, Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset.ext.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename('unsupported.ext'				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename('unsupported_2.ext'				)				)
							return path






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






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






@pytest.fixture(scope='session'				)
def    __magic_name__    (	)     ->    Optional[Any]:
							return os.path.join('tests'     ,     'features'     ,     'data'     ,     'test_audio_44100.wav'				)






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE     ,     SCREAMING_SNAKE_CASE				)     ->    Tuple:
							_lowercase							:   Optional[Any] 							=   tmp_path_factory.mktemp('data'				) / 'dataset.img.zip'
							with zipfile.ZipFile(SCREAMING_SNAKE_CASE     ,     'w'				) as f:
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				)				)
														f.write(SCREAMING_SNAKE_CASE     ,     arcname=os.path.basename(SCREAMING_SNAKE_CASE				).replace('.jpg'     ,     '2.jpg'				)				)
							return path






@pytest.fixture(scope='session'				)
def    __magic_name__    (	SCREAMING_SNAKE_CASE				)     ->    int:
							_lowercase							:   Dict 							=   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








import argparse
import os
import re

import packaging.version


SCREAMING_SNAKE_CASE__     					=			"examples/"
SCREAMING_SNAKE_CASE__     					=			{
    "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
    "init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$", re.MULTILINE), "__version__ = \"VERSION\"\n"),
    "setup": (re.compile(R"^(\s*)version\s*=\s*\"[^\"]+\",", re.MULTILINE), R"\1version=\"VERSION\","),
    "doc": (re.compile(R"^(\s*)release\s*=\s*\"[^\"]+\"$", re.MULTILINE), "release = \"VERSION\"\n"),
}
SCREAMING_SNAKE_CASE__     					=			{
    "init": "src/transformers/__init__.py",
    "setup": "setup.py",
}
SCREAMING_SNAKE_CASE__     					=			"README.md"


def     lowercase	(    a     , a     , a ):



		'''simple docstring'''




		with open(a     , "r"     , encoding="utf-8"     , newline="\n" ) as f:
				SCREAMING_SNAKE_CASE_				:Dict				     =						f.read()
		SCREAMING_SNAKE_CASE_     ,				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						REPLACE_PATTERNS[pattern]
		SCREAMING_SNAKE_CASE_				:List[str]				     =						replace.replace("VERSION"     , a )
		SCREAMING_SNAKE_CASE_				:str				     =						re_pattern.sub(a     , a )
		with open(a     , "w"     , encoding="utf-8"     , newline="\n" ) as f:
				f.write(a )


def     lowercase	(    a ):



		'''simple docstring'''




		for folder, directories, fnames in os.walk(a ):
				# Removing some of the folders with non-actively maintained examples from the walk
				if "research_projects" in directories:
						directories.remove("research_projects" )
				if "legacy" in directories:
						directories.remove("legacy" )
				for fname in fnames:
						if fname.endswith(".py" ):
								update_version_in_file(os.path.join(a     , a )     , a     , pattern="examples" )


def     lowercase	(    a     , a=False ):



		'''simple docstring'''




		for pattern, fname in REPLACE_FILES.items():
				update_version_in_file(a     , a     , a )
		if not patch:
				update_version_in_examples(a )


def     lowercase	(    ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:int				     =						"🤗 Transformers currently provides the following architectures"
		SCREAMING_SNAKE_CASE_				:Any				     =						"1. Want to contribute a new model?"
		with open(a     , "r"     , encoding="utf-8"     , newline="\n" ) as f:
				SCREAMING_SNAKE_CASE_				:List[str]				     =						f.readlines()

		# Find the start of the list.
		SCREAMING_SNAKE_CASE_				:int				     =						0
		while not lines[start_index].startswith(_start_prompt ):
				start_index += 1
		start_index += 1

		SCREAMING_SNAKE_CASE_				:int				     =						start_index
		# Update the lines in the model list.
		while not lines[index].startswith(_end_prompt ):
				if lines[index].startswith("1." ):
						SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						lines[index].replace(
						    "https://huggingface.co/docs/transformers/main/model_doc"     , "https://huggingface.co/docs/transformers/model_doc"     , )
				index += 1

		with open(a     , "w"     , encoding="utf-8"     , newline="\n" ) as f:
				f.writelines(a )


def     lowercase	(    ):



		'''simple docstring'''




		with open(REPLACE_FILES["init"]     , "r" ) as f:
				SCREAMING_SNAKE_CASE_				:str				     =						f.read()
		SCREAMING_SNAKE_CASE_				:Optional[int]				     =						REPLACE_PATTERNS["init"][0].search(a ).groups()[0]
		return packaging.version.parse(a )


def     lowercase	(    a=False ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:str				     =						get_version()
		if patch and default_version.is_devrelease:
				raise ValueError("Can't create a patch version from the dev branch, checkout a released version!" )
		if default_version.is_devrelease:
				SCREAMING_SNAKE_CASE_				:int				     =						default_version.base_version
		elif patch:
				SCREAMING_SNAKE_CASE_				:Union[str, Any]				     =						F"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
		else:
				SCREAMING_SNAKE_CASE_				:List[str]				     =						F"{default_version.major}.{default_version.minor + 1}.0"

		# Now let's ask nicely if that's the right one.
		SCREAMING_SNAKE_CASE_				:List[Any]				     =						input(F"Which version are you releasing? [{default_version}]" )
		if len(a ) == 0:
				SCREAMING_SNAKE_CASE_				:Any				     =						default_version

		print(F"Updating version to {version}." )
		global_version_update(a     , patch=a )
		if not patch:
				print("Cleaning main README, don't forget to run `make fix-copies`." )
				clean_main_ref_in_model_list()


def     lowercase	(    ):



		'''simple docstring'''




		SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						get_version()
		SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						F"{current_version.major}.{current_version.minor + 1}.0.dev0"
		SCREAMING_SNAKE_CASE_				:str				     =						current_version.base_version

		# Check with the user we got that right.
		SCREAMING_SNAKE_CASE_				:Any				     =						input(F"Which version are we developing now? [{dev_version}]" )
		if len(a ) == 0:
				SCREAMING_SNAKE_CASE_				:Optional[Any]				     =						dev_version

		print(F"Updating version to {version}." )
		global_version_update(a )
		print("Cleaning main README, don't forget to run `make fix-copies`." )
		clean_main_ref_in_model_list()


if __name__ == "__main__":
		SCREAMING_SNAKE_CASE__     					=			argparse.ArgumentParser()
		parser.add_argument("--post_release", action="store_true", help="Whether this is pre or post release.")
		parser.add_argument("--patch", action="store_true", help="Whether or not this is a patch release.")
		SCREAMING_SNAKE_CASE__     					=			parser.parse_args()
		if not args.post_release:
				pre_release_work(patch=args.patch)
		elif args.patch:
				print("Nothing to do after a patch :-)")
		else:
				post_release_work()






