

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


UpperCamelCase__	:   Optional[Any]								=     threading.Lock()
UpperCamelCase__	:   Optional[logging.Handler]								=     None

UpperCamelCase__	:   List[str]								=     {
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

UpperCamelCase__	:   Tuple								=     logging.WARNING

UpperCamelCase__	:   str								=     True


def        _UpperCAmelCase							(	):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_						=    os.getenv('DIFFUSERS_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 DIFFUSERS_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
        SCREAMING_SNAKE_CASE_						=    logging.StreamHandler()  # Set sys.stderr as stream.
        SCREAMING_SNAKE_CASE_						=    sys.stderr.flush

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


def        _UpperCAmelCase							(	):





    """simple docstring"""


    global _default_handler

    with _lock:
        if not _default_handler:
            return

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


def        _UpperCAmelCase							(	):





    """simple docstring"""


    return log_levels


def        _UpperCAmelCase							(	_SCREAMING_SNAKE_CASE       :		Optional[str] = None							):





    """simple docstring"""


    if name is None:
        SCREAMING_SNAKE_CASE_						=    _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()
    SCREAMING_SNAKE_CASE_						=    False


def        _UpperCAmelCase							(	):





    """simple docstring"""


    _configure_library_root_logger()
    SCREAMING_SNAKE_CASE_						=    True


def        _UpperCAmelCase							(	):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_						=    _get_library_root_logger().handlers

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


def        _UpperCAmelCase							(	):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_						=    _get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(_SCREAMING_SNAKE_CASE							)


def        _UpperCAmelCase							(	self       :		Any			, *_SCREAMING_SNAKE_CASE       :		int			, **_SCREAMING_SNAKE_CASE       :		Optional[Any]							):





    """simple docstring"""


    SCREAMING_SNAKE_CASE_						=    os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'			, _SCREAMING_SNAKE_CASE							)
    if no_advisory_warnings:
        return
    self.warning(*_SCREAMING_SNAKE_CASE			, **_SCREAMING_SNAKE_CASE							)


UpperCamelCase__	:   Tuple								=     warning_advice



class    __snake_case	:

  def __init__(       self    ,		*_A    ,		**_A):  # pylint: disable=unused-argument
      SCREAMING_SNAKE_CASE_						=    args[0] if args else None

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

  def __getattr__(       self    ,		_A):

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

      return empty_fn

  def __enter__(       self):
      return self


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






class    __snake_case	:

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

  def     lowerCAmelCase__  (       self    ,		*_A    ,		**_A):
      SCREAMING_SNAKE_CASE_						=    None
      if _tqdm_active:
          return tqdm_lib.tqdm.set_lock(*_A    ,		**_A)


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






UpperCamelCase__	:   List[Any]								=     _tqdm_cls()


def        _UpperCAmelCase							(	):





    """simple docstring"""


    global _tqdm_active
    return bool(_tqdm_active							)


def        _UpperCAmelCase							(	):





    """simple docstring"""


    global _tqdm_active
    SCREAMING_SNAKE_CASE_						=    True





def        _UpperCAmelCase							(	):





    """simple docstring"""


    global _tqdm_active
    SCREAMING_SNAKE_CASE_						=    False





import warnings

from ...utils import logging
from .image_processing_vilt import ViltImageProcessor


UpperCamelCase__	:   Optional[Any]								=     logging.get_logger(__name__)



class    __snake_case	(     lowerCAmelCase__							):

  def __init__(       self    ,		*_A    ,		**_A):
      warnings.warn(
          'The class ViltFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please'
          ' use ViltImageProcessor instead.'    ,		_A    ,		)
      super().__init__(*_A    ,		**_A)


