


'''simple docstring'''







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

from tqdm import auto as tqdm_lib


A   :  str       		=				threading.Lock()
A   :  Optional[logging.Handler]       		=				None

A   :  Union[str, Any]       		=				{
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

A   :  List[Any]       		=				logging.WARNING

A   :  Optional[int]       		=				True






def    lowerCAmelCase__ (       ):
       _A  :			Union[str, Any]											=      os.getenv('DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, '
                         F'has to be one of: { ", ".join(log_levels.keys()     ) }'     )
       return _default_log_level






def    lowerCAmelCase__ (       ):
       return __name__.split('.'     )[0]






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






def    lowerCAmelCase__ (       ):
       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  :			str											=      sys.stderr.flush

              # Apply our default configuration to the library root logger.
              _A  :			Any											=      _get_library_root_logger()
              library_root_logger.addHandler(_default_handler     )
              library_root_logger.setLevel(_get_default_logging_level()     )
              _A  :			Union[str, Any]											=      False






def    lowerCAmelCase__ (       ):
       global _default_handler

       with _lock:
              if not _default_handler:
                     return

              _A  :			Union[str, Any]											=      _get_library_root_logger()
              library_root_logger.removeHandler(_default_handler     )
              library_root_logger.setLevel(logging.NOTSET     )
              _A  :			Dict											=      None






def    lowerCAmelCase__ (       ):
       return log_levels






def    lowerCAmelCase__ (       lowerCamelCase  :    Optional[str] = None     ):

       if name is None:
              _A  :			Tuple											=      _get_library_name()

       _configure_library_root_logger()
       return logging.getLogger(lowerCamelCase     )






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






def    lowerCAmelCase__ (       lowerCamelCase  :    int     ):
       _configure_library_root_logger()
       _get_library_root_logger().setLevel(lowerCamelCase     )






def    lowerCAmelCase__ (       ):
       return set_verbosity(lowerCamelCase     )






def    lowerCAmelCase__ (       ):
       return set_verbosity(lowerCamelCase     )






def    lowerCAmelCase__ (       ):
       return set_verbosity(lowerCamelCase     )






def    lowerCAmelCase__ (       ):
       return set_verbosity(lowerCamelCase     )






def    lowerCAmelCase__ (       ):
       _configure_library_root_logger()

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






def    lowerCAmelCase__ (       ):
       _configure_library_root_logger()

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






def    lowerCAmelCase__ (       lowerCamelCase  :    logging.Handler     ):
       _configure_library_root_logger()

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






def    lowerCAmelCase__ (       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    lowerCAmelCase__ (       ):
       _configure_library_root_logger()
       _A  :			Any											=      False






def    lowerCAmelCase__ (       ):
       _configure_library_root_logger()
       _A  :			List[str]											=      True






def    lowerCAmelCase__ (       ):
       _A  :			Any											=      _get_library_root_logger().handlers

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






def    lowerCAmelCase__ (       ):
       _A  :			Optional[Any]											=      _get_library_root_logger().handlers

       for handler in handlers:
              handler.setFormatter(lowerCamelCase     )






def    lowerCAmelCase__ (       self  :    Tuple						,*lowerCamelCase  :    Dict						,**lowerCamelCase  :    List[Any]     ):
       _A  :			List[Any]											=      os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'						,lowerCamelCase     )
       if no_advisory_warnings:
              return
       self.warning(*lowerCamelCase						,**lowerCamelCase     )


A   :  Any       		=				warning_advice


class 				__lowerCamelCase				:
    """simple docstring"""


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


    def __iter__(						self    :							Optional[int]):
           return iter(self._iterator)


    def __getattr__(						self    :							Optional[int]   ,							SCREAMING_SNAKE_CASE    :							str):

           def empty_fn(*SCREAMING_SNAKE_CASE    :							Dict   ,							**SCREAMING_SNAKE_CASE    :							Union[str, Any]):  # pylint: disable=unused-argument
                  return

           return empty_fn


    def __enter__(						self    :							Union[str, Any]):
           return self


    def __exit__(						self    :							int   ,							SCREAMING_SNAKE_CASE    :							int   ,							SCREAMING_SNAKE_CASE    :							int   ,							SCREAMING_SNAKE_CASE    :							List[str]):
           return




class 				__lowerCamelCase				:
    """simple docstring"""


    def __call__(						self    :							Union[str, Any]   ,							*SCREAMING_SNAKE_CASE    :							Union[str, Any]   ,							**SCREAMING_SNAKE_CASE    :							Dict):
           if _tqdm_active:
                  return tqdm_lib.tqdm(*SCREAMING_SNAKE_CASE   ,							**SCREAMING_SNAKE_CASE)
           else:
                  return EmptyTqdm(*SCREAMING_SNAKE_CASE   ,							**SCREAMING_SNAKE_CASE)


    def      A					(						self    :							Optional[Any]   ,							*SCREAMING_SNAKE_CASE    :							Any   ,							**SCREAMING_SNAKE_CASE    :							Union[str, Any]):
           _A  :			Union[str, Any]											=      None
           if _tqdm_active:
                  return tqdm_lib.tqdm.set_lock(*SCREAMING_SNAKE_CASE   ,							**SCREAMING_SNAKE_CASE)


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




A   :  List[str]       		=				_tqdm_cls()






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






def    lowerCAmelCase__ (       ):
       global _tqdm_active
       _A  :			Dict											=      True






def    lowerCAmelCase__ (       ):
       global _tqdm_active
       _A  :			int											=      False










'''simple docstring'''







from unittest.mock import patch

import datasets
from datasets import Dataset






def    lowerCAmelCase__ (       ):
       _A  :			Optional[int]											=      Dataset.from_dict({'col_1': [3, 2, 0, 1]}     )

       with patch('tqdm.auto.tqdm'     ) as mock_tqdm:
              datasets.disable_progress_bar()
              dset.map(lambda lowerCamelCase     : {"col_2": x["col_1"] + 1}     )
              mock_tqdm.assert_not_called()

              mock_tqdm.reset_mock()

              datasets.enable_progress_bar()
              dset.map(lambda lowerCamelCase     : {"col_2": x["col_1"] + 1}     )
              mock_tqdm.assert_called()






