



'''simple docstring'''





import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


SCREAMING_SNAKE_CASE__       =      threading.Lock()
SCREAMING_SNAKE_CASE__       =      None

SCREAMING_SNAKE_CASE__       =      {
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

SCREAMING_SNAKE_CASE__       =      logging.WARNING

SCREAMING_SNAKE_CASE__       =      True


def A						(       )						->      Union[str, Any]:
			A__       =    os.getenv('TRANSFORMERS_VERBOSITY' ,	a_					)
			if env_level_str:
						if env_level_str in log_levels:
									return log_levels[env_level_str]
						else:
									logging.getLogger().warning(
									    f'''Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, '''
									    f'''has to be one of: { ", ".join(log_levels.keys()					) }'''					)
			return _default_log_level


def A						(       )						->      str:
			return __name__.split('.'					)[0]


def A						(       )						->      logging.Logger:
			return logging.getLogger(_get_library_name()					)


def A						(       )						->      None:
			global _default_handler

			with _lock:
						if _default_handler:
									# This library has already configured the library root logger.
									return
						A__       =    logging.StreamHandler()  # Set sys.stderr as stream.
						A__       =    sys.stderr.flush

						# Apply our default configuration to the library root logger.
						A__       =    _get_library_root_logger()
						library_root_logger.addHandler(_default_handler					)
						library_root_logger.setLevel(_get_default_logging_level()					)
						A__       =    False


def A						(       )						->      None:
			global _default_handler

			with _lock:
						if not _default_handler:
									return

						A__       =    _get_library_root_logger()
						library_root_logger.removeHandler(_default_handler					)
						library_root_logger.setLevel(logging.NOTSET					)
						A__       =    None


def A						(       )						->      Optional[Any]:
			return log_levels


def A						(       __UpperCamelCase = None					)						->      logging.Logger:

			if name is None:
						A__       =    _get_library_name()

			_configure_library_root_logger()
			return logging.getLogger(a_					)


def A						(       )						->      int:
			_configure_library_root_logger()
			return _get_library_root_logger().getEffectiveLevel()


def A						(       __UpperCamelCase					)						->      None:
			_configure_library_root_logger()
			_get_library_root_logger().setLevel(a_					)


def A						(       )						->      int:
			return set_verbosity(a_					)


def A						(       )						->      List[Any]:
			return set_verbosity(a_					)


def A						(       )						->      Optional[int]:
			return set_verbosity(a_					)


def A						(       )						->      int:
			return set_verbosity(a_					)


def A						(       )						->      None:
			_configure_library_root_logger()

			assert _default_handler is not None
			_get_library_root_logger().removeHandler(_default_handler					)


def A						(       )						->      None:
			_configure_library_root_logger()

			assert _default_handler is not None
			_get_library_root_logger().addHandler(_default_handler					)


def A						(       __UpperCamelCase					)						->      None:
			_configure_library_root_logger()

			assert handler is not None
			_get_library_root_logger().addHandler(a_					)


def A						(       __UpperCamelCase					)						->      None:
			_configure_library_root_logger()

			assert handler is not None and handler not in _get_library_root_logger().handlers
			_get_library_root_logger().removeHandler(a_					)


def A						(       )						->      None:
			_configure_library_root_logger()
			A__       =    False


def A						(       )						->      None:
			_configure_library_root_logger()
			A__       =    True


def A						(       )						->      None:
			A__       =    _get_library_root_logger().handlers

			for handler in handlers:
						A__       =    logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s'					)
						handler.setFormatter(a_					)


def A						(       )						->      None:
			A__       =    _get_library_root_logger().handlers

			for handler in handlers:
						handler.setFormatter(a_					)


def A						(       self ,	*__UpperCamelCase ,	**__UpperCamelCase					)						->      int:
			A__       =    os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS' ,	a_					)
			if no_advisory_warnings:
						return
			self.warning(*a_ ,	**a_					)


SCREAMING_SNAKE_CASE__       =      warning_advice


@functools.lru_cache(a_					)
def A						(       self ,	*__UpperCamelCase ,	**__UpperCamelCase					)						->      List[str]:
			self.warning(*a_ ,	**a_					)


SCREAMING_SNAKE_CASE__       =      warning_once


class      __lowerCAmelCase     :
					"""simple docstring"""






					def __init__(     self					:       Dict				,					*_snake_case					:       Any				,					**_snake_case					:       Dict					):  # pylint: disable=unused-argument






								"""simple docstring"""


								A__       =    args[0] if args else None



					def __iter__(     self					:       Optional[Any]					):






								"""simple docstring"""


								return iter(self._iterator					)



					def __getattr__(     self					:       Optional[Any]				,					_snake_case					:       Union[str, Any]					):






								"""simple docstring"""


								def empty_fn(*_snake_case					:       Dict				,					**_snake_case					:       Any					):  # pylint: disable=unused-argument
											return

								return empty_fn



					def __enter__(     self					:       Optional[int]					):






								"""simple docstring"""


								return self



					def __exit__(     self					:       Optional[Any]				,					_snake_case					:       int				,					_snake_case					:       List[str]				,					_snake_case					:       Dict					):






								"""simple docstring"""


								return







class      __lowerCAmelCase     :
					"""simple docstring"""






					def __call__(     self					:       int				,					*_snake_case					:       Tuple				,					**_snake_case					:       str					):






								"""simple docstring"""


								if _tqdm_active:
											return tqdm_lib.tqdm(*_UpperCAmelCase				,					**_UpperCAmelCase					)
								else:
											return EmptyTqdm(*_UpperCAmelCase				,					**_UpperCAmelCase					)



					def     _a							(     self					:       List[Any]				,					*_snake_case					:       Any				,					**_snake_case					:       Any					):






								"""simple docstring"""


								A__       =    None
								if _tqdm_active:
											return tqdm_lib.tqdm.set_lock(*_UpperCAmelCase				,					**_UpperCAmelCase					)



					def     _a							(     self					:       Tuple					):






								"""simple docstring"""


								if _tqdm_active:
											return tqdm_lib.tqdm.get_lock()







SCREAMING_SNAKE_CASE__       =      _tqdm_cls()


def A						(       )						->      bool:
			global _tqdm_active
			return bool(_tqdm_active					)


def A						(       )						->      str:
			global _tqdm_active
			A__       =    True
			hf_hub_utils.enable_progress_bars()






def A						(       )						->      int:
			global _tqdm_active
			A__       =    False
			hf_hub_utils.disable_progress_bars()









import pytest

import datasets


# Import fixture modules as plugins
SCREAMING_SNAKE_CASE__       =      ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec''']


def A						(       __UpperCamelCase ,	__UpperCamelCase					)						->      Optional[int]:
			# Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
			for item in items:
						if any(marker in item.keywords for marker in ['integration', 'unit']					):
									continue
						item.add_marker(pytest.mark.unit					)


def A						(       __UpperCamelCase					)						->      str:
			config.addinivalue_line('markers' ,	'torchaudio_latest: mark test to run with torchaudio>=0.12'					)


@pytest.fixture(autouse=__UpperCamelCase					)
def A						(       __UpperCamelCase ,	__UpperCamelCase					)						->      Union[str, Any]:
			# test_hf_cache_home = tmp_path_factory.mktemp("cache")  # TODO: why a cache dir per test function does not work?
			A__       =    tmp_path_factory.getbasetemp() / 'cache'
			A__       =    test_hf_cache_home / 'datasets'
			A__       =    test_hf_cache_home / 'metrics'
			A__       =    test_hf_cache_home / 'modules'
			monkeypatch.setattr('datasets.config.HF_DATASETS_CACHE' ,	str(__UpperCamelCase					)					)
			monkeypatch.setattr('datasets.config.HF_METRICS_CACHE' ,	str(__UpperCamelCase					)					)
			monkeypatch.setattr('datasets.config.HF_MODULES_CACHE' ,	str(__UpperCamelCase					)					)
			A__       =    test_hf_datasets_cache / 'downloads'
			monkeypatch.setattr('datasets.config.DOWNLOADED_DATASETS_PATH' ,	str(__UpperCamelCase					)					)
			A__       =    test_hf_datasets_cache / 'downloads' / 'extracted'
			monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_PATH' ,	str(__UpperCamelCase					)					)


@pytest.fixture(autouse=__UpperCamelCase ,	scope='session'					)
def A						(       )						->      Union[str, Any]:
			datasets.disable_progress_bar()


@pytest.fixture(autouse=__UpperCamelCase					)
def A						(       __UpperCamelCase					)						->      int:
			# don't take tests into account when counting downloads
			monkeypatch.setattr('datasets.config.HF_UPDATE_DOWNLOAD_COUNTS' ,	__UpperCamelCase					)






@pytest.fixture
def A						(       __UpperCamelCase					)						->      Any:
			# Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
			# To be removed once SQLAlchemy 2.0 supported
			monkeypatch.setattr('sqlalchemy.util.deprecations.SILENCE_UBER_WARNING' ,	__UpperCamelCase					)




