



import re
import time
from typing import Optional

import IPython.display as disp

from ..trainer_callback import TrainerCallback
from ..trainer_utils import IntervalStrategy, has_length


def    __lowerCamelCase   (  lowerCamelCase__		):

				"""simple docstring"""


				lowercase__	:       List[str]						=	int(lowerCamelCase_		)
				lowercase__	:       Optional[Any]						=	t // 3_600, (t // 60) % 60, t % 60
				return F"""{h}:{m:02d}:{s:02d}""" if h != 0 else F"""{m:02d}:{s:02d}"""


def    __lowerCamelCase   (  lowerCamelCase__	,					lowerCamelCase__	,					lowerCamelCase__	,					lowerCamelCase__	,					lowerCamelCase__=300		):

				"""simple docstring"""


				return F"""
    <div>
      {prefix}
      <progress value=\'{value}\' max=\'{total}\' style=\'width:{width}px; height:20px; vertical-align: middle;\'></progress>
      {label}
    </div>
    """


def    __lowerCamelCase   (  lowerCamelCase__		):

				"""simple docstring"""


				lowercase__	:       int						=	'<table border="1" class="dataframe">\n'
				html_code += """  <thead>\n <tr style="text-align: left;">\n"""
				for i in items[0]:
								html_code += F"""      <th>{i}</th>\n"""
				html_code += "    </tr>\n  </thead>\n  <tbody>\n"
				for line in items[1:]:
								html_code += "    <tr>\n"
								for elt in line:
												lowercase__	:       Any						=	F"""{elt:.6f}""" if isinstance(lowerCamelCase_	,					lowerCamelCase_		) else str(lowerCamelCase_		)
												html_code += F"""      <td>{elt}</td>\n"""
								html_code += "    </tr>\n"
				html_code += "  </tbody>\n</table><p>"
				return html_code

class  snake_case__:

					"""simple docstring"""






					lowercase_								=						5
					lowercase_								=						0.2







					def __init__(				self   :      Optional[int] ,  SCREAMING_SNAKE_CASE   :      List[str] ,  SCREAMING_SNAKE_CASE   :      Optional[int] = None ,  SCREAMING_SNAKE_CASE   :      Optional[int] = True ,  SCREAMING_SNAKE_CASE   :      str = None ,  SCREAMING_SNAKE_CASE   :      List[str] = 300 ,  ):
									lowercase__	:       Optional[int]						=	total
									lowercase__	:       Optional[int]						=	'' if prefix is None else prefix
									lowercase__	:       Tuple						=	leave
									lowercase__	:       str						=	parent
									lowercase__	:       str						=	width
									lowercase__	:       List[Any]						=	None
									lowercase__	:       List[str]						=	None
									lowercase__	:       Tuple						=	None







					def 					snake_case	(				self   :      List[str] ,  SCREAMING_SNAKE_CASE   :      Tuple ,  SCREAMING_SNAKE_CASE   :      str = False ,  SCREAMING_SNAKE_CASE   :      str = None	):
									lowercase__	:       Any						=	value
									if comment is not None:
													lowercase__	:       Union[str, Any]						=	comment
									if self.last_value is None:
													lowercase__	:       Dict						=	time.time()
													lowercase__	:       Tuple						=	value
													lowercase__	:       str						=	None
													lowercase__	:       Optional[int]						=	self.warmup
													lowercase__	:       Optional[Any]						=	1
													self.update_bar(SCREAMING_SNAKE_CASE	)
									elif value <= self.last_value and not force_update:
													return
									elif force_update or self.first_calls > 0 or value >= min(self.last_value + self.wait_for ,  self.total	):
													if self.first_calls > 0:
																	self.first_calls -= 1
													lowercase__	:       List[str]						=	time.time()
													lowercase__	:       Tuple						=	current_time - self.start_time
													# We could have value = self.start_value if the update is called twixe with the same start value.
													if value > self.start_value:
																	lowercase__	:       Dict						=	self.elapsed_time / (value - self.start_value)
													else:
																	lowercase__	:       int						=	None
													if value >= self.total:
																	lowercase__	:       Dict						=	self.total
																	lowercase__	:       List[str]						=	None
																	if not self.leave:
																					self.close()
													elif self.average_time_per_item is not None:
																	lowercase__	:       Optional[int]						=	self.average_time_per_item * (self.total - value)
													self.update_bar(SCREAMING_SNAKE_CASE	)
													lowercase__	:       int						=	value
													lowercase__	:       Tuple						=	current_time
													if self.average_time_per_item is None:
																	lowercase__	:       str						=	1
													else:
																	lowercase__	:       int						=	max(int(self.update_every / self.average_time_per_item	) ,  1	)







					def 					snake_case	(				self   :      str ,  SCREAMING_SNAKE_CASE   :      Tuple ,  SCREAMING_SNAKE_CASE   :      List[Any]=None	):
									lowercase__	:       List[Any]						=	' ' * (len(str(self.total	)	) - len(str(SCREAMING_SNAKE_CASE	)	)) + str(SCREAMING_SNAKE_CASE	)
									if self.elapsed_time is None:
													lowercase__	:       int						=	f"""[{spaced_value}/{self.total} : < :"""
									elif self.predicted_remaining is None:
													lowercase__	:       Union[str, Any]						=	f"""[{spaced_value}/{self.total} {format_time(self.elapsed_time	)}"""
									else:
													lowercase__	:       Union[str, Any]						=	(
													    f"""[{spaced_value}/{self.total} {format_time(self.elapsed_time	)} <"""
													    f""" {format_time(self.predicted_remaining	)}"""
													)
													self.label += f""", {1/self.average_time_per_item:.2f} it/s"""
									self.label += "]" if self.comment is None or len(self.comment	) == 0 else f""", {self.comment}]"""
									self.display()







					def 					snake_case	(				self   :      Dict	):
									lowercase__	:       Any						=	html_progress_bar(self.value ,  self.total ,  self.prefix ,  self.label ,  self.width	)
									if self.parent is not None:
													# If this is a child bar, the parent will take care of the display.
													self.parent.display()
													return
									if self.output is None:
													lowercase__	:       Optional[Any]						=	disp.display(disp.HTML(self.html_code	) ,  display_id=SCREAMING_SNAKE_CASE	)
									else:
													self.output.update(disp.HTML(self.html_code	)	)







					def 					snake_case	(				self   :      Any	):

									if self.parent is None and self.output is not None:
													self.output.update(disp.HTML(""	)	)






class  snake_case__(_a     ):

					"""simple docstring"""






					def __init__(				self   :      Tuple ,  SCREAMING_SNAKE_CASE   :      Tuple ,  SCREAMING_SNAKE_CASE   :      Optional[Any]=None	):
									super().__init__(SCREAMING_SNAKE_CASE	)
									lowercase__	:       Optional[Any]						=	None if column_names is None else [column_names]
									lowercase__	:       Any						=	None







					def 					snake_case	(				self   :      List[Any]	):
									lowercase__	:       Any						=	html_progress_bar(self.value ,  self.total ,  self.prefix ,  self.label ,  self.width	)
									if self.inner_table is not None:
													self.html_code += text_to_html_table(self.inner_table	)
									if self.child_bar is not None:
													self.html_code += self.child_bar.html_code
									if self.output is None:
													lowercase__	:       Dict						=	disp.display(disp.HTML(self.html_code	) ,  display_id=SCREAMING_SNAKE_CASE	)
									else:
													self.output.update(disp.HTML(self.html_code	)	)







					def 					snake_case	(				self   :      List[Any] ,  SCREAMING_SNAKE_CASE   :      Optional[int]	):

									if self.inner_table is None:
													lowercase__	:       Dict						=	[list(values.keys()	), list(values.values()	)]
									else:
													lowercase__	:       Tuple						=	self.inner_table[0]
													if len(self.inner_table	) == 1:
																	# We give a chance to update the column names at the first iteration
																	for key in values.keys():
																					if key not in columns:
																									columns.append(SCREAMING_SNAKE_CASE	)
																	lowercase__	:       str						=	columns
													self.inner_table.append([values[c] for c in columns]	)







					def 					snake_case	(				self   :      Any ,  SCREAMING_SNAKE_CASE   :      Dict ,  SCREAMING_SNAKE_CASE   :      Optional[int]=None ,  SCREAMING_SNAKE_CASE   :      Dict=300	):
									lowercase__	:       List[str]						=	NotebookProgressBar(SCREAMING_SNAKE_CASE ,  prefix=SCREAMING_SNAKE_CASE ,  parent=self ,  width=SCREAMING_SNAKE_CASE	)
									return self.child_bar







					def 					snake_case	(				self   :      Any	):
									lowercase__	:       Optional[Any]						=	None
									self.display()






class  snake_case__(_a     ):

					"""simple docstring"""






					def __init__(				self   :      Any	):
									lowercase__	:       Union[str, Any]						=	None
									lowercase__	:       Dict						=	None
									lowercase__	:       Dict						=	False







					def 					snake_case	(				self   :      Any ,  SCREAMING_SNAKE_CASE   :      Optional[int] ,  SCREAMING_SNAKE_CASE   :      Optional[int] ,  SCREAMING_SNAKE_CASE   :      Any ,  **SCREAMING_SNAKE_CASE   :      int	):
									lowercase__	:       Dict						=	'Epoch' if args.evaluation_strategy == IntervalStrategy.EPOCH else 'Step'
									lowercase__	:       Dict						=	0
									lowercase__	:       Tuple						=	0
									lowercase__	:       int						=	[self.first_column] + ['Training Loss']
									if args.evaluation_strategy != IntervalStrategy.NO:
													column_names.append("Validation Loss"	)
									lowercase__	:       Union[str, Any]						=	NotebookTrainingTracker(state.max_steps ,  SCREAMING_SNAKE_CASE	)







					def 					snake_case	(				self   :      List[str] ,  SCREAMING_SNAKE_CASE   :      Dict ,  SCREAMING_SNAKE_CASE   :      Dict ,  SCREAMING_SNAKE_CASE   :      Tuple ,  **SCREAMING_SNAKE_CASE   :      Any	):
									lowercase__	:       Any						=	int(state.epoch	) if int(state.epoch	) == state.epoch else f"""{state.epoch:.2f}"""
									self.training_tracker.update(
									    state.global_step + 1 ,  comment=f"""Epoch {epoch}/{state.num_train_epochs}""" ,  force_update=self._force_next_update ,  )
									lowercase__	:       str						=	False







					def 					snake_case	(				self   :      Tuple ,  SCREAMING_SNAKE_CASE   :      Tuple ,  SCREAMING_SNAKE_CASE   :      List[str] ,  SCREAMING_SNAKE_CASE   :      int ,  SCREAMING_SNAKE_CASE   :      List[str]=None ,  **SCREAMING_SNAKE_CASE   :      Tuple	):

									if not has_length(SCREAMING_SNAKE_CASE	):
													return
									if self.prediction_bar is None:
													if self.training_tracker is not None:
																	lowercase__	:       Optional[int]						=	self.training_tracker.add_child(len(SCREAMING_SNAKE_CASE	)	)
													else:
																	lowercase__	:       Optional[int]						=	NotebookProgressBar(len(SCREAMING_SNAKE_CASE	)	)
													self.prediction_bar.update(1	)
									else:
													self.prediction_bar.update(self.prediction_bar.value + 1	)







					def 					snake_case	(				self   :      Dict ,  SCREAMING_SNAKE_CASE   :      Optional[int] ,  SCREAMING_SNAKE_CASE   :      Optional[Any] ,  SCREAMING_SNAKE_CASE   :      int ,  **SCREAMING_SNAKE_CASE   :      int	):

									if self.prediction_bar is not None:
													self.prediction_bar.close()
									lowercase__	:       Any						=	None







					def 					snake_case	(				self   :      List[str] ,  SCREAMING_SNAKE_CASE   :      Union[str, Any] ,  SCREAMING_SNAKE_CASE   :      Tuple ,  SCREAMING_SNAKE_CASE   :      List[Any] ,  SCREAMING_SNAKE_CASE   :      List[Any]=None ,  **SCREAMING_SNAKE_CASE   :      Optional[int]	):

									if args.evaluation_strategy == IntervalStrategy.NO and "loss" in logs:
													lowercase__	:       Dict						=	{'Training Loss': logs['loss']}
													# First column is necessarily Step sine we're not in epoch eval strategy
													lowercase__	:       List[Any]						=	state.global_step
													self.training_tracker.write_line(SCREAMING_SNAKE_CASE	)







					def 					snake_case	(				self   :      Any ,  SCREAMING_SNAKE_CASE   :      Optional[Any] ,  SCREAMING_SNAKE_CASE   :      str ,  SCREAMING_SNAKE_CASE   :      Union[str, Any] ,  SCREAMING_SNAKE_CASE   :      Optional[Any]=None ,  **SCREAMING_SNAKE_CASE   :      Union[str, Any]	):

									if self.training_tracker is not None:
													lowercase__	:       Tuple						=	{'Training Loss': 'No log', 'Validation Loss': 'No log'}
													for log in reversed(state.log_history	):
																	if "loss" in log:
																					lowercase__	:       int						=	log['loss']
																					break

													if self.first_column == "Epoch":
																	lowercase__	:       Union[str, Any]						=	int(state.epoch	)
													else:
																	lowercase__	:       Optional[Any]						=	state.global_step
													lowercase__	:       str						=	'eval'
													for k in metrics:
																	if k.endswith("_loss"	):
																					lowercase__	:       str						=	re.sub(r"\_loss$" ,  "" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       Tuple						=	metrics.pop("total_flos" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       List[str]						=	metrics.pop("epoch" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       List[Any]						=	metrics.pop(f"""{metric_key_prefix}_runtime""" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       Dict						=	metrics.pop(f"""{metric_key_prefix}_samples_per_second""" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       Tuple						=	metrics.pop(f"""{metric_key_prefix}_steps_per_second""" ,  SCREAMING_SNAKE_CASE	)
													lowercase__	:       List[str]						=	metrics.pop(f"""{metric_key_prefix}_jit_compilation_time""" ,  SCREAMING_SNAKE_CASE	)
													for k, v in metrics.items():
																	if k == f"""{metric_key_prefix}_loss""":
																					lowercase__	:       Union[str, Any]						=	v
																	else:
																					lowercase__	:       Optional[Any]						=	k.split("_"	)
																					lowercase__	:       Optional[int]						=	' '.join([part.capitalize() for part in splits[1:]]	)
																					lowercase__	:       Tuple						=	v
													self.training_tracker.write_line(SCREAMING_SNAKE_CASE	)
													self.training_tracker.remove_child()
													lowercase__	:       str						=	None
													# Evaluation takes a long time so we should force the next update.
													lowercase__	:       Optional[Any]						=	True







					def 					snake_case	(				self   :      Union[str, Any] ,  SCREAMING_SNAKE_CASE   :      Dict ,  SCREAMING_SNAKE_CASE   :      Dict ,  SCREAMING_SNAKE_CASE   :      List[Any] ,  **SCREAMING_SNAKE_CASE   :      str	):
									self.training_tracker.update(
									    state.global_step ,  comment=f"""Epoch {int(state.epoch	)}/{state.num_train_epochs}""" ,  force_update=SCREAMING_SNAKE_CASE	)
									lowercase__	:       Any						=	None








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

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

import datasets
import datasets.config



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( )       ->		Any:
    _lowercase			:				str 						=						10
    _lowercase			:				List[str] 						=						datasets.Features(
        {
            'tokens': datasets.Sequence(datasets.Value('string'					)					),
            'labels': datasets.Sequence(datasets.ClassLabel(names=['negative', 'positive']					)					),
            'answers': datasets.Sequence(
                {
                    'text': datasets.Value('string'					),
                    'answer_start': datasets.Value('int32'					),
                }					),
            'id': datasets.Value('int64'					),
        }					)
    _lowercase			:				Union[str, Any] 						=						datasets.Dataset.from_dict(
        {
            'tokens': [['foo'] * 5] * n,
            'labels': [[1] * 5] * n,
            'answers': [{'answer_start': [97], 'text': ['1976']}] * 10,
            'id': list(range(lowerCamelCase_					)					),
        }				,					features=lowerCamelCase_				,					)
    return dataset



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		int:
    _lowercase			:				int 						=						str(tmp_path_factory.mktemp('data'					) / 'file.arrow'					)
    dataset.map(cache_file_name=lowerCamelCase_					)
    return filename


# FILE_CONTENT + files


SCREAMING_SNAKE_CASE			: str				   =					"\\n    Text data.\n    Second line of data."



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				str 						=						tmp_path_factory.mktemp('data'					) / 'file.txt'
    _lowercase			:				List[str] 						=						FILE_CONTENT
    with open(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_					)
    return filename



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Tuple:
    import bza

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



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

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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    if datasets.config.LZ4_AVAILABLE:
        import lza.frame

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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    if datasets.config.PY7ZR_AVAILABLE:
        import pyazr

        _lowercase			:				int 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		List[str]:
    import tarfile

    _lowercase			:				Optional[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    import lzma

    _lowercase			:				Optional[Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.txt.xz'
    _lowercase			:				int 						=						bytes(lowerCamelCase_				,					'utf-8'					)
    with lzma.open(lowerCamelCase_				,					'wb'					) as f:
        f.write(lowerCamelCase_					)
    return path



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    import zipfile

    _lowercase			:				Dict 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    if datasets.config.ZSTANDARD_AVAILABLE:
        import zstandard as zstd

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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    _lowercase			:				Union[str, Any] 						=						tmp_path_factory.mktemp('data'					) / 'file.xml'
    _lowercase			:				Optional[Any] 						=						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(lowerCamelCase_				,					'w'					) as f:
        f.write(lowerCamelCase_					)
    return filename


SCREAMING_SNAKE_CASE			: Dict				   =					[
    {"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			: Dict				   =					[
    {"col_1": "4", "col_2": 4, "col_3": 4.0},
    {"col_1": "5", "col_2": 5, "col_3": 5.0},
]
SCREAMING_SNAKE_CASE			: Optional[Any]				   =					{
    "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			: Tuple				   =					[
    {"col_3": 0.0, "col_1": "0", "col_2": 0},
    {"col_3": 1.0, "col_1": "1", "col_2": 1},
]

SCREAMING_SNAKE_CASE			: 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 							UpperCamelCase_( )       ->		List[str]:
    return DATA_DICT_OF_LISTS



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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		str:
    _lowercase			:				List[str] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.sqlite'					)
    with contextlib.closing(sqlitea.connect(lowerCamelCase_					)					) 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 							UpperCamelCase_( lowerCamelCase_					)       ->		Dict:
    _lowercase			:				List[str] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.csv'					)
    with open(lowerCamelCase_				,					'w'				,					newline=''					) as f:
        _lowercase			:				Tuple 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				Tuple 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset2.csv'					)
    with open(lowerCamelCase_				,					'w'				,					newline=''					) as f:
        _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    import bza

    _lowercase			:				int 						=						tmp_path_factory.mktemp('data'					) / 'dataset.csv.bz2'
    with open(lowerCamelCase_				,					'rb'					) as f:
        _lowercase			:				int 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[int]:
    _lowercase			:				Optional[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				Union[str, Any] 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    _lowercase			:				Optional[int] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.parquet'					)
    _lowercase			:				Optional[Any] 						=						pa.schema(
        {
            'col_1': pa.string(),
            'col_2': pa.intaa(),
            'col_3': pa.floataa(),
        }					)
    with open(lowerCamelCase_				,					'wb'					) as f:
        _lowercase			:				List[str] 						=						pq.ParquetWriter(lowerCamelCase_				,					schema=lowerCamelCase_					)
        _lowercase			:				Any 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				Optional[Any] 						=						str(tmp_path_factory.mktemp('data'					) / 'dataset.json'					)
    _lowercase			:				List[Any] 						=						{'data': DATA}
    with open(lowerCamelCase_				,					'w'					) as f:
        json.dump(lowerCamelCase_				,					lowerCamelCase_					)
    return path



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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				Any 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Dict:
    _lowercase			:				Dict 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				Optional[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		List[Any]:
    _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[Any]:
    import gzip

    _lowercase			:				Tuple 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Dict:
    import gzip

    _lowercase			:				Optional[int] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				Any 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		int:
    _lowercase			:				Optional[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Optional[int]:
    _lowercase			:				Tuple 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Any:
    _lowercase			:				Optional[int] 						=						['0', '1', '2', '3']
    _lowercase			:				str 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Union[str, Any]:
    _lowercase			:				str 						=						['0', '1', '2', '3']
    _lowercase			:				List[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		List[str]:
    _lowercase			:				List[Any] 						=						['0', '1', '2', '3']
    _lowercase			:				Optional[int] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				Optional[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		Dict:
    _lowercase			:				List[Any] 						=						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 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_				,					lowerCamelCase_					)       ->		str:
    _lowercase			:				Any 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		int:
    _lowercase			:				List[str] 						=						'\n'.join(['First', 'Second\u2029with Unicode new line', 'Third']					)
    _lowercase			:				Any 						=						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 							UpperCamelCase_( )       ->		Dict:
    return os.path.join('tests'				,					'features'				,					'data'				,					'test_image_rgb.jpg'					)



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



@pytest.fixture(scope='session'					)
def 							UpperCamelCase_( lowerCamelCase_				,					lowerCamelCase_					)       ->		Any:
    _lowercase			:				Dict 						=						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 							UpperCamelCase_( lowerCamelCase_					)       ->		Optional[Any]:
    _lowercase			:				str 						=						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


