





'''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


__lowerCAmelCase							:     Union[str, Any]		     =threading.Lock()
__lowerCAmelCase							:     Optional[logging.Handler]		     =None

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

__lowerCAmelCase							:     str		     =logging.WARNING

__lowerCAmelCase							:     int		     =True





def 						UpperCamelCase    (							):
    A__    =      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    (							):
    return __name__.split("."	)[0]





def 						UpperCamelCase    (							):
    return logging.getLogger(_get_library_name()	)





def 						UpperCamelCase    (							):
    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 						UpperCamelCase    (							):
    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 						UpperCamelCase    (							):
    return log_levels





def 						UpperCamelCase    (							_lowerCamelCase : Optional[str] = None	):

    if name is None:
        A__    =      _get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    _configure_library_root_logger()
    return _get_library_root_logger().getEffectiveLevel()





def 						UpperCamelCase    (							_lowerCamelCase : int	):
    _configure_library_root_logger()
    _get_library_root_logger().setLevel(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    return set_verbosity(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    return set_verbosity(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    return set_verbosity(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    return set_verbosity(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    _configure_library_root_logger()

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





def 						UpperCamelCase    (							):
    _configure_library_root_logger()

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





def 						UpperCamelCase    (							_lowerCamelCase : logging.Handler	):
    _configure_library_root_logger()

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





def 						UpperCamelCase    (							_lowerCamelCase : logging.Handler	):
    _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    (							):
    _configure_library_root_logger()
    A__    =      False





def 						UpperCamelCase    (							):
    _configure_library_root_logger()
    A__    =      True





def 						UpperCamelCase    (							):
    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(_lowerCamelCase	)





def 						UpperCamelCase    (							):
    A__    =      _get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(_lowerCamelCase	)





def 						UpperCamelCase    (							self : List[Any]						,	*_lowerCamelCase : List[Any]						,	**_lowerCamelCase : Dict	):
    A__    =      os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS"						,	_lowerCamelCase	)
    if no_advisory_warnings:
        return
    self.warning(*_lowerCamelCase						,	**_lowerCamelCase	)


__lowerCAmelCase							:     Optional[Any]		     =warning_advice





@functools.lru_cache(_lowerCamelCase	)
def 						UpperCamelCase    (							self : int						,	*_lowerCamelCase : Dict						,	**_lowerCamelCase : List[Any]	):
    self.warning(*_lowerCamelCase						,	**_lowerCamelCase	)


__lowerCAmelCase							:     str		     =warning_once






class        UpperCAmelCase     :
 def __init__(    self				:List[Any]						,	*lowercase_				:List[str]						,	**lowercase_				:Dict							)->							Optional[Any]:  # pylint: disable=unused-argument
     A__    =      args[0] if args else None
 def __iter__(    self				:Any							)->							List[str]:
     return iter(self._iterator							)
 def __getattr__(    self				:Union[str, Any]						,	lowercase_				:Tuple							)->							Dict:

     def empty_fn(*lowercase_				:str						,	**lowercase_				:Optional[int]							):  # pylint: disable=unused-argument
         return

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



 def __exit__(    self				:Tuple						,	lowercase_				:str						,	lowercase_				:Union[str, Any]						,	lowercase_				:Dict							)->							Tuple:
     return






class        UpperCAmelCase     :
 def __call__(    self				:List[str]						,	*lowercase_				:Any						,	**lowercase_				:List[str]							)->							Optional[int]:
     if _tqdm_active:
         return tqdm_lib.tqdm(*lowercase_						,	**lowercase_							)
     else:
         return EmptyTqdm(*lowercase_						,	**lowercase_							)
 def 					UpperCAmelCase_							(    self				:List[str]						,	*lowercase_				:Optional[Any]						,	**lowercase_				:List[str]							)->							Union[str, Any]:
     A__    =      None
     if _tqdm_active:
         return tqdm_lib.tqdm.set_lock(*lowercase_						,	**lowercase_							)



 def 					UpperCAmelCase_							(    self				:int							)->							Dict:
     if _tqdm_active:
         return tqdm_lib.tqdm.get_lock()

__lowerCAmelCase							:     Dict		     =_tqdm_cls()





def 						UpperCamelCase    (							):
    global _tqdm_active
    return bool(_tqdm_active	)





def 						UpperCamelCase    (							):
    global _tqdm_active
    A__    =      True
    hf_hub_utils.enable_progress_bars()





def 						UpperCamelCase    (							):
    global _tqdm_active
    A__    =      False
    hf_hub_utils.disable_progress_bars()










'''simple docstring'''

__lowerCAmelCase							:     Dict		     ="\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggingface/transformers.git\n"

__lowerCAmelCase							:     Optional[Any]		     =[{"type": "code", "content": INSTALL_CONTENT}]
__lowerCAmelCase							:     Tuple		     ={
    "{processor_class}": "FakeProcessorClass",
    "{model_class}": "FakeModelClass",
    "{object_class}": "FakeObjectClass",
}



