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 			__SCREAMING_SNAKE_CASE						(      )							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   10
  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""": [97], """text""": ["""1976"""]}] * 10,
          """id""": list(range(SCREAMING_SNAKE_CASE_			)			),
      }				,  features=SCREAMING_SNAKE_CASE_				,  )
  return dataset



@pytest.fixture(scope="""session"""			)
def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict				,  __UpperCamelCase					: Any			)							->      Optional[int]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """file.arrow"""			)
  dataset.map(cache_file_name=SCREAMING_SNAKE_CASE_			)
  return filename


# FILE_CONTENT + files


__lowerCamelCase    :				Any							     =	'''\
    Text data.
    Second line of data.'''



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







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """file.txt"""
  SCREAMING_SNAKE_CASE__    							=   FILE_CONTENT
  with open(SCREAMING_SNAKE_CASE_				,  """w"""			) as f:
    f.write(SCREAMING_SNAKE_CASE_			)
  return filename



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







  """simple docstring"""





  import bza

  SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """file.txt.bz2"""
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int			)							->      List[str]:







  """simple docstring"""





  import gzip

  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """file.txt.gz"""			)
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Union[str, Any]			)							->      List[str]:







  """simple docstring"""





  if datasets.config.LZ4_AVAILABLE:
    import lza.frame

    SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """file.txt.lz4"""
    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: str				,  __UpperCamelCase					: Tuple			)							->      Union[str, Any]:







  """simple docstring"""





  if datasets.config.PY7ZR_AVAILABLE:
    import pyazr

    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Tuple				,  __UpperCamelCase					: Any			)							->      Any:







  """simple docstring"""





  import tarfile

  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Optional[int]			)							->      int:







  """simple docstring"""





  import lzma

  SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """file.txt.xz"""
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]				,  __UpperCamelCase					: Optional[Any]			)							->      Union[str, Any]:







  """simple docstring"""





  import zipfile

  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Union[str, Any]			)							->      List[str]:







  """simple docstring"""





  if datasets.config.ZSTANDARD_AVAILABLE:
    import zstandard as zstd

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



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







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """file.xml"""
  SCREAMING_SNAKE_CASE__    							=   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


__lowerCamelCase    :				str							     =	[
    {'''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    :				List[Any]							     =	{
    '''col_1''': ['''0''', '''1''', '''2''', '''3'''],
    '''col_2''': [0, 1, 2, 3],
    '''col_3''': [0.0, 1.0, 2.0, 3.0],
}

__lowerCamelCase    :				Tuple							     =	[
    {'''col_3''': 0.0, '''col_1''': '''0''', '''col_2''': 0},
    {'''col_3''': 1.0, '''col_1''': '''1''', '''col_2''': 1},
]

__lowerCamelCase    :				List[Any]							     =	[
    {'''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 			__SCREAMING_SNAKE_CASE						(      )							->      Optional[int]:







  """simple docstring"""





  return DATA_DICT_OF_LISTS



@pytest.fixture(scope="""session"""			)
def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[Any]			)							->      int:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   datasets.Dataset.from_dict(SCREAMING_SNAKE_CASE_			)
  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset.arrow"""			)
  dataset.map(cache_file_name=SCREAMING_SNAKE_CASE_			)
  return path



@pytest.fixture(scope="""session"""			)
def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict			)							->      Tuple:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset.sqlite"""			)
  with contextlib.closing(sqlitea.connect(SCREAMING_SNAKE_CASE_			)			) 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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Tuple			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset.csv"""			)
  with open(SCREAMING_SNAKE_CASE_				,  """w"""				,  newline=""""""			) as f:
    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: str			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset2.csv"""			)
  with open(SCREAMING_SNAKE_CASE_				,  """w"""				,  newline=""""""			) as f:
    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[Any]				,  __UpperCamelCase					: Any			)							->      List[Any]:







  """simple docstring"""





  import bza

  SCREAMING_SNAKE_CASE__    							=   tmp_path_factory.mktemp("""data"""			) / """dataset.csv.bz2"""
  with open(SCREAMING_SNAKE_CASE_				,  """rb"""			) as f:
    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict				,  __UpperCamelCase					: Tuple				,  __UpperCamelCase					: Optional[int]			)							->      List[str]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict				,  __UpperCamelCase					: int				,  __UpperCamelCase					: Any			)							->      List[str]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict				,  __UpperCamelCase					: str				,  __UpperCamelCase					: Union[str, Any]			)							->      List[str]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Tuple			)							->      str:







  """simple docstring"""





  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(SCREAMING_SNAKE_CASE_				,  """wb"""			) as f:
    SCREAMING_SNAKE_CASE__    							=   pq.ParquetWriter(SCREAMING_SNAKE_CASE_				,  schema=SCREAMING_SNAKE_CASE_			)
    SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Tuple			)							->      Optional[int]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset.json"""			)
  SCREAMING_SNAKE_CASE__    							=   {"""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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Tuple			)							->      Optional[int]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   str(tmp_path_factory.mktemp("""data"""			) / """dataset.json"""			)
  SCREAMING_SNAKE_CASE__    							=   {"""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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Optional[Any]			)							->      Any:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Optional[int]			)							->      str:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Union[str, Any]			)							->      Any:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]			)							->      Dict:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int				,  __UpperCamelCase					: Optional[int]			)							->      Any:







  """simple docstring"""





  import gzip

  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Any				,  __UpperCamelCase					: Optional[Any]			)							->      Optional[int]:







  """simple docstring"""





  import gzip

  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[Any]				,  __UpperCamelCase					: Union[str, Any]				,  __UpperCamelCase					: Dict			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]				,  __UpperCamelCase					: Dict				,  __UpperCamelCase					: Optional[Any]				,  __UpperCamelCase					: Union[str, Any]			)							->      int:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int				,  __UpperCamelCase					: List[Any]				,  __UpperCamelCase					: Optional[Any]			)							->      int:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int				,  __UpperCamelCase					: Dict				,  __UpperCamelCase					: Dict			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict				,  __UpperCamelCase					: Optional[int]				,  __UpperCamelCase					: Dict				,  __UpperCamelCase					: Any			)							->      Dict:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Union[str, Any]			)							->      Optional[int]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   ["""0""", """1""", """2""", """3"""]
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: str			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   ["""0""", """1""", """2""", """3"""]
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Optional[Any]			)							->      List[str]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   ["""0""", """1""", """2""", """3"""]
  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: int				,  __UpperCamelCase					: Union[str, Any]				,  __UpperCamelCase					: Union[str, Any]			)							->      List[str]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Union[str, Any]				,  __UpperCamelCase					: List[str]				,  __UpperCamelCase					: Dict			)							->      Union[str, Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]				,  __UpperCamelCase					: int				,  __UpperCamelCase					: Optional[Any]			)							->      Optional[Any]:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]			)							->      Any:







  """simple docstring"""





  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(SCREAMING_SNAKE_CASE_				,  """w"""				,  encoding="""utf-8"""			) as f:
    f.write(SCREAMING_SNAKE_CASE_			)
  return path



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







  """simple docstring"""





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



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







  """simple docstring"""





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



@pytest.fixture(scope="""session"""			)
def 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: List[str]				,  __UpperCamelCase					: Union[str, Any]			)							->      Tuple:







  """simple docstring"""





  SCREAMING_SNAKE_CASE__    							=   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 			__SCREAMING_SNAKE_CASE						(      __UpperCamelCase					: Dict			)							->      List[Any]:







  """simple docstring"""





  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""" * 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

from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

__lowerCamelCase    :				List[str]							     =	TypeVar('''KEY''')
__lowerCamelCase    :				int							     =	TypeVar('''VAL''')







@dataclass(frozen=lowerCamelCase_     ,	slots=lowerCamelCase_	)
class __snake_case       (		Generic[KEY, VAL]	):
   lowerCAmelCase_														=							42
   lowerCAmelCase_														=							42







class __snake_case       (		_Item	):




   def __init__(					self    :       List[Any]   ):



     """simple docstring"""






     super().__init__(_lowercase ,			_lowercase   )




   def __bool__(					self    :       List[str]   ):



     """simple docstring"""






     return False





__lowerCamelCase    :				str							     =	_DeletedItem()







class __snake_case       (		MutableMapping[KEY, VAL]	):




   def __init__(					self    :       Optional[int] ,			_lowercase    :       int = 8 ,			_lowercase    :       float = 0.75   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   initial_block_size
     SCREAMING_SNAKE_CASE__    							=   [None] * initial_block_size
     assert 0.0 < capacity_factor < 1.0
     SCREAMING_SNAKE_CASE__    							=   capacity_factor
     SCREAMING_SNAKE_CASE__    							=   0




   def 			__a		(					self    :       Union[str, Any] ,			_lowercase    :       KEY   ):



     """simple docstring"""






     return hash(_lowercase   ) % len(self._buckets   )




   def 			__a		(					self    :       List[str] ,			_lowercase    :       int   ):



     """simple docstring"""






     return (ind + 1) % len(self._buckets   )




   def 			__a		(					self    :       Union[str, Any] ,			_lowercase    :       int ,			_lowercase    :       KEY ,			_lowercase    :       VAL   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   self._buckets[ind]
     if not stored:
       SCREAMING_SNAKE_CASE__    							=   _Item(_lowercase ,			_lowercase   )
       self._len += 1
       return True
     elif stored.key == key:
       SCREAMING_SNAKE_CASE__    							=   _Item(_lowercase ,			_lowercase   )
       return True
     else:
       return False




   def 			__a		(					self    :       List[Any]   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   len(self._buckets   ) * self._capacity_factor
     return len(self   ) >= int(_lowercase   )




   def 			__a		(					self    :       Dict   ):



     """simple docstring"""






     if len(self._buckets   ) <= self._initial_block_size:
       return False
     SCREAMING_SNAKE_CASE__    							=   len(self._buckets   ) * self._capacity_factor / 2
     return len(self   ) < limit




   def 			__a		(					self    :       List[Any] ,			_lowercase    :       int   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   self._buckets
     SCREAMING_SNAKE_CASE__    							=   [None] * new_size
     SCREAMING_SNAKE_CASE__    							=   0
     for item in old_buckets:
       if item:
         self._add_item(item.key ,			item.val   )




   def 			__a		(					self    :       Tuple   ):



     """simple docstring"""






     self._resize(len(self._buckets   ) * 2   )




   def 			__a		(					self    :       Tuple   ):



     """simple docstring"""






     self._resize(len(self._buckets   ) // 2   )




   def 			__a		(					self    :       List[str] ,			_lowercase    :       KEY   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   self._get_bucket_index(_lowercase   )
     for _ in range(len(self._buckets   )   ):
       yield ind
       SCREAMING_SNAKE_CASE__    							=   self._get_next_ind(_lowercase   )




   def 			__a		(					self    :       List[str] ,			_lowercase    :       KEY ,			_lowercase    :       VAL   ):



     """simple docstring"""






     for ind in self._iterate_buckets(_lowercase   ):
       if self._try_set(_lowercase ,			_lowercase ,			_lowercase   ):
         break




   def __setitem__(					self    :       List[str] ,			_lowercase    :       KEY ,			_lowercase    :       VAL   ):



     """simple docstring"""






     if self._is_full():
       self._size_up()

     self._add_item(_lowercase ,			_lowercase   )




   def __delitem__(					self    :       Tuple ,			_lowercase    :       KEY   ):



     """simple docstring"""






     for ind in self._iterate_buckets(_lowercase   ):
       SCREAMING_SNAKE_CASE__    							=   self._buckets[ind]
       if item is None:
         raise KeyError(_lowercase   )
       if item is _deleted:
         continue
       if item.key == key:
         SCREAMING_SNAKE_CASE__    							=   _deleted
         self._len -= 1
         break
     if self._is_sparse():
       self._size_down()




   def __getitem__(					self    :       Tuple ,			_lowercase    :       KEY   ):



     """simple docstring"""






     for ind in self._iterate_buckets(_lowercase   ):
       SCREAMING_SNAKE_CASE__    							=   self._buckets[ind]
       if item is None:
         break
       if item is _deleted:
         continue
       if item.key == key:
         return item.val
     raise KeyError(_lowercase   )




   def __len__(					self    :       List[Any]   ):



     """simple docstring"""






     return self._len




   def __iter__(					self    :       List[str]   ):



     """simple docstring"""






     yield from (item.key for item in self._buckets if item)




   def __repr__(					self    :       Optional[Any]   ):



     """simple docstring"""






     SCREAMING_SNAKE_CASE__    							=   """ ,""".join(
         f"""{item.key}: {item.val}""" for item in self._buckets if item   )
     return f"""HashMap({val_string})"""
