"""simple docstring"""






import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
_A   					=    abspath(join(dirname(__file__), 'src'))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   int:
				config.addinivalue_line(
				    "markers"  ,					"is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"       )
				config.addinivalue_line(
				    "markers"  ,					"is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"       )
				config.addinivalue_line("markers"  ,					"is_pipeline_test: mark test to run only when pipelines are tested"       )
				config.addinivalue_line("markers"  ,					"is_staging_test: mark test to run only in the staging environment"       )
				config.addinivalue_line("markers"  ,					"accelerate_tests: mark test that require accelerate"       )
				config.addinivalue_line("markers"  ,					"tool_tests: mark the tool tests that are run on their specific schedule"       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Tuple:
				from transformers.testing_utils import pytest_addoption_shared

				pytest_addoption_shared(__UpperCAmelCase       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   Dict:
				from transformers.testing_utils import pytest_terminal_summary_main

				SCREAMING_SNAKE_CASE__		  =				terminalreporter.config.getoption("--make-reports"       )
				if make_reports:
								pytest_terminal_summary_main(__UpperCAmelCase  ,					id=__UpperCAmelCase       )




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase  ,					__UpperCAmelCase       )							->   Dict:
				# If no tests are collected, pytest exists with code 5, which makes the CI fail.
				if exitstatus == 5:
								SCREAMING_SNAKE_CASE__		  =				0


# Doctest custom flag to ignore output.
_A   					=    doctest.register_optionflag('IGNORE_RESULT')

_A   					=    doctest.OutputChecker

class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					def 			lowerCAmelCase_					(						self			:				List[Any]   , _snake_case			:				Union[str, Any]   , _snake_case			:				Optional[Any]   , _snake_case			:				Optional[Any]		)							->       Dict:
									if IGNORE_RESULT & optionflags:
													return True
									return OutputChecker.check_output(self   , _snake_case   , _snake_case   , _snake_case		)



_A   					=    CustomOutputChecker
_A   					=    HfDoctestModule

_A   					=    HfDocTestParser





"""simple docstring"""






from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream

class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					def __init__(						self			:				List[str]   , _snake_case			:				Callable   , _snake_case			:				Optional[Features] = None   , _snake_case			:				str = None   , _snake_case			:				bool = False   , _snake_case			:				bool = False   , _snake_case			:				Optional[dict] = None   , _snake_case			:				Optional[int] = None   , **_snake_case			:				Dict   , )							->       Any:
									super().__init__(
									    features=_snake_case   , cache_dir=_snake_case   , keep_in_memory=_snake_case   , streaming=_snake_case   , num_proc=_snake_case   , **_snake_case   , )
									SCREAMING_SNAKE_CASE__		  =				Generator(
									    cache_dir=_snake_case   , features=_snake_case   , generator=_snake_case   , gen_kwargs=_snake_case   , **_snake_case   , )



					def 			lowerCAmelCase_					(						self			:				List[str]		)							->       Optional[Any]:
									# Build iterable dataset
									if self.streaming:
													SCREAMING_SNAKE_CASE__		  =				self.builder.as_streaming_dataset(split="train"		)
									# Build regular (map-style) dataset
									else:
													SCREAMING_SNAKE_CASE__		  =				None
													SCREAMING_SNAKE_CASE__		  =				None
													SCREAMING_SNAKE_CASE__		  =				None
													SCREAMING_SNAKE_CASE__		  =				None

													self.builder.download_and_prepare(
													    download_config=_snake_case   , download_mode=_snake_case   , verification_mode=_snake_case   , base_path=_snake_case   , num_proc=self.num_proc   , )
													SCREAMING_SNAKE_CASE__		  =				self.builder.as_dataset(
													    split="train"   , verification_mode=_snake_case   , in_memory=self.keep_in_memory		)
									return dataset




