



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_:Optional[int]             =						threading.Lock()
SCREAMING_SNAKE_CASE_:Optional[logging.Handler]             =						None

SCREAMING_SNAKE_CASE_:str             =						{
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

SCREAMING_SNAKE_CASE_:Tuple             =						logging.WARNING

SCREAMING_SNAKE_CASE_:Dict             =						True




def 	__UpperCamelCase	(  )       ->  Optional[Any]:



    """simple docstring"""






    A :       str          =   os.getenv("""TRANSFORMERS_VERBOSITY"""      ,     _lowerCAmelCase		)
    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	(  )       ->  str:



    """simple docstring"""






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




def 	__UpperCamelCase	(  )       ->  logging.Logger:



    """simple docstring"""






    return logging.getLogger(_get_library_name()		)




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    global _default_handler

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

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




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    global _default_handler

    with _lock:
        if not _default_handler:
            return

        A :       Tuple          =   _get_library_root_logger()
        library_root_logger.removeHandler(_default_handler		)
        library_root_logger.setLevel(logging.NOTSET		)
        A :       List[str]          =   None




def 	__UpperCamelCase	(  )       ->  Optional[Any]:



    """simple docstring"""






    return log_levels




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



    """simple docstring"""






    if name is None:
        A :       Any          =   _get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  int:



    """simple docstring"""






    _configure_library_root_logger()
    return _get_library_root_logger().getEffectiveLevel()




def 	__UpperCamelCase	(  _lowerCAmelCase		)       ->  None:



    """simple docstring"""






    _configure_library_root_logger()
    _get_library_root_logger().setLevel(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  Any:



    """simple docstring"""






    return set_verbosity(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  int:



    """simple docstring"""






    return set_verbosity(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  Dict:



    """simple docstring"""






    return set_verbosity(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  Any:



    """simple docstring"""






    return set_verbosity(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    _configure_library_root_logger()

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




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    _configure_library_root_logger()

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




def 	__UpperCamelCase	(  _lowerCAmelCase		)       ->  None:



    """simple docstring"""






    _configure_library_root_logger()

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




def 	__UpperCamelCase	(  _lowerCAmelCase		)       ->  None:



    """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(_lowerCAmelCase		)




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    _configure_library_root_logger()
    A :       Any          =   False




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    _configure_library_root_logger()
    A :       Dict          =   True




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    A :       Tuple          =   _get_library_root_logger().handlers

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




def 	__UpperCamelCase	(  )       ->  None:



    """simple docstring"""






    A :       List[Any]          =   _get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(_lowerCAmelCase		)




def 	__UpperCamelCase	(  self      ,     *_lowerCAmelCase      ,     **_lowerCAmelCase		)       ->  Any:



    """simple docstring"""






    A :       List[Any]          =   os.getenv("""TRANSFORMERS_NO_ADVISORY_WARNINGS"""      ,     _lowerCAmelCase		)
    if no_advisory_warnings:
        return
    self.warning(*_lowerCAmelCase      ,     **_lowerCAmelCase		)


SCREAMING_SNAKE_CASE_:Union[str, Any]             =						warning_advice




@functools.lru_cache(_lowerCAmelCase		)
def 	__UpperCamelCase	(  self      ,     *_lowerCAmelCase      ,     **_lowerCAmelCase		)       ->  str:



    """simple docstring"""






    self.warning(*_lowerCAmelCase      ,     **_lowerCAmelCase		)


SCREAMING_SNAKE_CASE_:Optional[Any]             =						warning_once






class SCREAMING_SNAKE_CASE__     :




    '''simple docstring'''






    def __init__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):  # pylint: disable=unused-argument
        A :       Optional[int]          =   args[0] if args else None






    def __iter__(       self		):
        return iter(self._iterator		)






    def __getattr__(       self,		lowerCamelCase__		):

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

        return empty_fn






    def __enter__(       self		):
        return self






    def __exit__(       self,		lowerCamelCase__,		lowerCamelCase__,		lowerCamelCase__		):
        return






class SCREAMING_SNAKE_CASE__     :




    '''simple docstring'''






    def __call__(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        if _tqdm_active:
            return tqdm_lib.tqdm(*lowerCamelCase__,		**lowerCamelCase__		)
        else:
            return EmptyTqdm(*lowerCamelCase__,		**lowerCamelCase__		)






    def 			_lowerCAmelCase					(       self,		*lowerCamelCase__,		**lowerCamelCase__		):
        A :       str          =   None
        if _tqdm_active:
            return tqdm_lib.tqdm.set_lock(*lowerCamelCase__,		**lowerCamelCase__		)






    def 			_lowerCAmelCase					(       self		):
        if _tqdm_active:
            return tqdm_lib.tqdm.get_lock()


SCREAMING_SNAKE_CASE_:List[Any]             =						_tqdm_cls()




def 	__UpperCamelCase	(  )       ->  bool:



    """simple docstring"""






    global _tqdm_active
    return bool(_tqdm_active		)




def 	__UpperCamelCase	(  )       ->  List[str]:



    """simple docstring"""






    global _tqdm_active
    A :       List[str]          =   True
    hf_hub_utils.enable_progress_bars()




def 	__UpperCamelCase	(  )       ->  Dict:



    """simple docstring"""






    global _tqdm_active
    A :       Dict          =   False
    hf_hub_utils.disable_progress_bars()







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


SCREAMING_SNAKE_CASE_:str             =						{
    """configuration_transfo_xl""": ["""TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TransfoXLConfig"""],
    """tokenization_transfo_xl""": ["""TransfoXLCorpus""", """TransfoXLTokenizer"""],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     SCREAMING_SNAKE_CASE_:Union[str, Any]             =						[
         """TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """AdaptiveEmbedding""",
         """TransfoXLForSequenceClassification""",
         """TransfoXLLMHeadModel""",
         """TransfoXLModel""",
         """TransfoXLPreTrainedModel""",
         """load_tf_weights_in_transfo_xl""",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     SCREAMING_SNAKE_CASE_:Any             =						[
         """TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """TFAdaptiveEmbedding""",
         """TFTransfoXLForSequenceClassification""",
         """TFTransfoXLLMHeadModel""",
         """TFTransfoXLMainLayer""",
         """TFTransfoXLModel""",
         """TFTransfoXLPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_transfo_xl import TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, TransfoXLConfig
     from .tokenization_transfo_xl import TransfoXLCorpus, TransfoXLTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_transfo_xl import (
              TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
              AdaptiveEmbedding,
              TransfoXLForSequenceClassification,
              TransfoXLLMHeadModel,
              TransfoXLModel,
              TransfoXLPreTrainedModel,
              load_tf_weights_in_transfo_xl,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_transfo_xl import (
              TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFAdaptiveEmbedding,
              TFTransfoXLForSequenceClassification,
              TFTransfoXLLMHeadModel,
              TFTransfoXLMainLayer,
              TFTransfoXLModel,
              TFTransfoXLPreTrainedModel,
          )

else:
     import sys

     SCREAMING_SNAKE_CASE_:Dict             =						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


