





"""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      UpperCAmelCase__				(    ):







      '''simple docstring'''




      lowerCAmelCase    		=			os.getenv("""TRANSFORMERS_VERBOSITY"""				,		SCREAMING_SNAKE_CASE     )
      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      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return __name__.split("""."""     )[0]


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return logging.getLogger(_get_library_name()     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      global _default_handler

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

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


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      global _default_handler

      with _lock:
            if not _default_handler:
                  return

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


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return log_levels


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		Optional[str] = None     ):







      '''simple docstring'''




      if name is None:
            lowerCAmelCase    		=			_get_library_name()

      _configure_library_root_logger()
      return logging.getLogger(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      _configure_library_root_logger()
      return _get_library_root_logger().getEffectiveLevel()


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		int     ):







      '''simple docstring'''




      _configure_library_root_logger()
      _get_library_root_logger().setLevel(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return set_verbosity(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return set_verbosity(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return set_verbosity(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      return set_verbosity(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      _configure_library_root_logger()

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


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      _configure_library_root_logger()

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


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		logging.Handler     ):







      '''simple docstring'''




      _configure_library_root_logger()

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


def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		logging.Handler     ):







      '''simple docstring'''




      _configure_library_root_logger()

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


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      _configure_library_root_logger()
      lowerCAmelCase    		=			False


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      _configure_library_root_logger()
      lowerCAmelCase    		=			True


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      lowerCAmelCase    		=			_get_library_root_logger().handlers

      for handler in handlers:
            lowerCAmelCase    		=			logging.Formatter("""[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s"""     )
            handler.setFormatter(SCREAMING_SNAKE_CASE     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      lowerCAmelCase    		=			_get_library_root_logger().handlers

      for handler in handlers:
            handler.setFormatter(SCREAMING_SNAKE_CASE     )


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







      '''simple docstring'''




      lowerCAmelCase    		=			os.getenv("""TRANSFORMERS_NO_ADVISORY_WARNINGS"""				,		SCREAMING_SNAKE_CASE     )
      if no_advisory_warnings:
            return
      self.warning(*SCREAMING_SNAKE_CASE				,		**SCREAMING_SNAKE_CASE     )


SCREAMING_SNAKE_CASE__   =  warning_advice


@functools.lru_cache(SCREAMING_SNAKE_CASE     )
def      UpperCAmelCase__				(    self	:		Any				,		*SCREAMING_SNAKE_CASE	:		Any				,		**SCREAMING_SNAKE_CASE	:		Dict     ):







      '''simple docstring'''




      self.warning(*SCREAMING_SNAKE_CASE				,		**SCREAMING_SNAKE_CASE     )


SCREAMING_SNAKE_CASE__   =  warning_once

class 						lowercase   :





      def __init__(			self ,		*lowercase ,		**lowercase					)						->	Union[str, Any]:  # pylint: disable=unused-argument
            lowerCAmelCase    		=			args[0] if args else None





      def __iter__(			self					)						->	Union[str, Any]:
            return iter(self._iterator					)





      def __getattr__(			self ,		lowercase					)						->	List[Any]:

            def empty_fn(*lowercase ,		**lowercase					):  # pylint: disable=unused-argument
                  return

            return empty_fn





      def __enter__(			self					)						->	List[str]:
            return self





      def __exit__(			self ,		lowercase ,		lowercase ,		lowercase					)						->	Optional[Any]:
            return







class 						lowercase   :





      def __call__(			self ,		*lowercase ,		**lowercase					)						->	Tuple:
            if _tqdm_active:
                  return tqdm_lib.tqdm(*lowercase ,		**lowercase					)
            else:
                  return EmptyTqdm(*lowercase ,		**lowercase					)





      def        _snake_case     (			self ,		*lowercase ,		**lowercase					)						->	Any:
            lowerCAmelCase    		=			None
            if _tqdm_active:
                  return tqdm_lib.tqdm.set_lock(*lowercase ,		**lowercase					)





      def        _snake_case     (			self					)						->	str:
            if _tqdm_active:
                  return tqdm_lib.tqdm.get_lock()







SCREAMING_SNAKE_CASE__   =  _tqdm_cls()


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      global _tqdm_active
      return bool(_tqdm_active     )


def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      global _tqdm_active
      lowerCAmelCase    		=			True
      hf_hub_utils.enable_progress_bars()






def      UpperCAmelCase__				(    ):







      '''simple docstring'''




      global _tqdm_active
      lowerCAmelCase    		=			False
      hf_hub_utils.disable_progress_bars()













"""simple docstring"""





from . import __version__

# Backward compatibility imports, to make sure all those objects can be found in file_utils
from .utils import (
    CLOUDFRONT_DISTRIB_PREFIX,
    CONFIG_NAME,
    DISABLE_TELEMETRY,
    DUMMY_INPUTS,
    DUMMY_MASK,
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    FEATURE_EXTRACTOR_NAME,
    FLAX_WEIGHTS_NAME,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    MODEL_CARD_NAME,
    MULTIPLE_CHOICE_DUMMY_INPUTS,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    SENTENCEPIECE_UNDERLINE,
    SPIECE_UNDERLINE,
    TF2_WEIGHTS_NAME,
    TF_WEIGHTS_NAME,
    TORCH_FX_REQUIRED_VERSION,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    WEIGHTS_INDEX_NAME,
    WEIGHTS_NAME,
    ContextManagers,
    DummyObject,
    EntryNotFoundError,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    TensorType,
    _LazyModule,
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    cached_property,
    copy_func,
    default_cache_path,
    define_sagemaker_information,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    get_torch_version,
    has_file,
    http_user_agent,
    is_apex_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_datasets_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_librosa_available,
    is_offline_mode,
    is_onnx_available,
    is_pandas_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_tensor,
    is_tensorflow_probability_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    replace_return_docstrings,
    requires_backends,
    to_numpy,
    to_py_obj,
    torch_only_method,
)






