




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


lowerCamelCase_  						=   threading.Lock()
lowerCamelCase_  						=   None

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

lowerCamelCase_  						=   logging.WARNING

lowerCamelCase_  						=   True



def 	UpperCAmelCase_    (	):
    SCREAMING_SNAKE_CASE__								=os.getenv("""DIFFUSERS_VERBOSITY""",				__UpperCamelCase	)
    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_    (	):
    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
        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_    (	):
    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_    (	):
    return log_levels



def 	UpperCAmelCase_    (	__UpperCamelCase = None	):

    if name is None:
        SCREAMING_SNAKE_CASE__								=_get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(__UpperCamelCase	)



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



def 	UpperCAmelCase_    (	__UpperCamelCase	):
    _configure_library_root_logger()
    _get_library_root_logger().setLevel(__UpperCamelCase	)



def 	UpperCAmelCase_    (	):
    return set_verbosity(__UpperCamelCase	)



def 	UpperCAmelCase_    (	):
    return set_verbosity(__UpperCamelCase	)



def 	UpperCAmelCase_    (	):
    return set_verbosity(__UpperCamelCase	)



def 	UpperCAmelCase_    (	):
    return set_verbosity(__UpperCamelCase	)



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_    (	__UpperCamelCase	):
    _configure_library_root_logger()

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



def 	UpperCAmelCase_    (	__UpperCamelCase	):
    _configure_library_root_logger()

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



def 	UpperCAmelCase_    (	):
    _configure_library_root_logger()
    SCREAMING_SNAKE_CASE__								=False



def 	UpperCAmelCase_    (	):
    _configure_library_root_logger()
    SCREAMING_SNAKE_CASE__								=True



def 	UpperCAmelCase_    (	):
    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(__UpperCamelCase	)



def 	UpperCAmelCase_    (	):
    SCREAMING_SNAKE_CASE__								=_get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(__UpperCamelCase	)



def 	UpperCAmelCase_    (	self,				*__UpperCamelCase,				**__UpperCamelCase	):
    SCREAMING_SNAKE_CASE__								=os.getenv("""DIFFUSERS_NO_ADVISORY_WARNINGS""",				__UpperCamelCase	)
    if no_advisory_warnings:
        return
    self.warning(*__UpperCamelCase,				**__UpperCamelCase	)


lowerCamelCase_  						=   warning_advice
class       __a					:


     """simple docstring"""


     def __init__(	self			: int				,*_UpperCamelCase			: str				,**_UpperCamelCase			: List[Any]						)		->   Optional[Any]:  # pylint: disable=unused-argument


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=args[0] if args else None




     def __iter__(	self			: List[str]						)		->   Tuple:


         '''simple docstring'''





         return iter(self._iterator						)




     def __getattr__(	self			: str				,_UpperCamelCase			: Optional[Any]						)		->   Dict:


         '''simple docstring'''





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

         return empty_fn




     def __enter__(	self			: Union[str, Any]						)		->   List[Any]:


         '''simple docstring'''





         return self




     def __exit__(	self			: Any				,_UpperCamelCase			: Optional[Any]				,_UpperCamelCase			: Optional[int]				,_UpperCamelCase			: str						)		->   Dict:


         '''simple docstring'''





         return






class       __a					:


     """simple docstring"""


     def __call__(	self			: Optional[int]				,*_UpperCamelCase			: int				,**_UpperCamelCase			: Dict						)		->   str:


         '''simple docstring'''





         if _tqdm_active:
             return tqdm_lib.tqdm(*_UpperCamelCase				,**_UpperCamelCase						)
         else:
             return EmptyTqdm(*_UpperCamelCase				,**_UpperCamelCase						)




     def   __A				(	self			: Any				,*_UpperCamelCase			: Optional[Any]				,**_UpperCamelCase			: Tuple						)		->   Tuple:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=None
         if _tqdm_active:
             return tqdm_lib.tqdm.set_lock(*_UpperCamelCase				,**_UpperCamelCase						)




     def   __A				(	self			: List[str]						)		->   str:


         '''simple docstring'''





         if _tqdm_active:
             return tqdm_lib.tqdm.get_lock()






lowerCamelCase_  						=   _tqdm_cls()



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



def 	UpperCAmelCase_    (	):
    global _tqdm_active
    SCREAMING_SNAKE_CASE__								=True




def 	UpperCAmelCase_    (	):
    global _tqdm_active
    SCREAMING_SNAKE_CASE__								=False












from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any
class       __a					:


     """simple docstring"""


     _A				:    List[Any]									=  ("_front", "_back", "_len")
     @dataclass
     class       __a					:


          """simple docstring"""


          _A				:    Any									=  None
          _A				:    Deque._Node | None									=  None
          _A				:    Deque._Node | None									=  None






     class       __a					:


          """simple docstring"""


          _A				:    List[str]									=  ("_cur",)




          def __init__(	self			: int				,_UpperCamelCase			: Deque._Node | None						)		->   None:


              '''simple docstring'''





              SCREAMING_SNAKE_CASE__								=cur




          def __iter__(	self			: Optional[Any]						)		->   Deque._Iterator:


              '''simple docstring'''





              return self




          def   __A				(	self			: Union[str, Any]						)		->   Any:


              '''simple docstring'''





              if self._cur is None:
                  # finished iterating
                  raise StopIteration
              SCREAMING_SNAKE_CASE__								=self._cur.val
              SCREAMING_SNAKE_CASE__								=self._cur.next_node

              return val






     def __init__(	self			: Union[str, Any]				,_UpperCamelCase			: Iterable[Any] | None = None						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=None
         SCREAMING_SNAKE_CASE__								=None
         SCREAMING_SNAKE_CASE__								=0

         if iterable is not None:
             # append every value to the deque
             for val in iterable:
                 self.append(_UpperCamelCase						)




     def   __A				(	self			: Optional[Any]				,_UpperCamelCase			: Any						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=self._Node(_UpperCamelCase				,_UpperCamelCase				,_UpperCamelCase						)
         if self.is_empty():
             # front = back
             SCREAMING_SNAKE_CASE__								=SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=1
         else:
             # connect nodes
             SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=self._back
             SCREAMING_SNAKE_CASE__								=node  # assign new back to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."




     def   __A				(	self			: Any				,_UpperCamelCase			: Any						)		->   None:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=self._Node(_UpperCamelCase				,_UpperCamelCase				,_UpperCamelCase						)
         if self.is_empty():
             # front = back
             SCREAMING_SNAKE_CASE__								=SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=1
         else:
             # connect nodes
             SCREAMING_SNAKE_CASE__								=self._front
             SCREAMING_SNAKE_CASE__								=node
             SCREAMING_SNAKE_CASE__								=node  # assign new front to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."




     def   __A				(	self			: List[Any]				,_UpperCamelCase			: Iterable[Any]						)		->   None:


         '''simple docstring'''





         for val in iterable:
             self.append(_UpperCamelCase						)




     def   __A				(	self			: str				,_UpperCamelCase			: Iterable[Any]						)		->   None:


         '''simple docstring'''





         for val in iterable:
             self.appendleft(_UpperCamelCase						)




     def   __A				(	self			: str						)		->   Any:


         '''simple docstring'''





         assert not self.is_empty(), "Deque is empty."

         SCREAMING_SNAKE_CASE__								=self._back
         SCREAMING_SNAKE_CASE__								=self._back.prev_node  # set new back
         # drop the last node - python will deallocate memory automatically
         SCREAMING_SNAKE_CASE__								=None

         self._len -= 1

         return topop.val




     def   __A				(	self			: Union[str, Any]						)		->   Any:


         '''simple docstring'''





         assert not self.is_empty(), "Deque is empty."

         SCREAMING_SNAKE_CASE__								=self._front
         SCREAMING_SNAKE_CASE__								=self._front.next_node  # set new front and drop the first node
         SCREAMING_SNAKE_CASE__								=None

         self._len -= 1

         return topop.val




     def   __A				(	self			: Tuple						)		->   bool:


         '''simple docstring'''





         return self._front is None




     def __len__(	self			: Optional[int]						)		->   int:


         '''simple docstring'''





         return self._len




     def __eq__(	self			: Union[str, Any]				,_UpperCamelCase			: object						)		->   bool:


         '''simple docstring'''





         if not isinstance(_UpperCamelCase				,_UpperCamelCase						):
             return NotImplemented

         SCREAMING_SNAKE_CASE__								=self._front
         SCREAMING_SNAKE_CASE__								=other._front

         # if the length of the dequeues are not the same, they are not equal
         if len(self						) != len(_UpperCamelCase						):
             return False

         while me is not None and oth is not None:
             # compare every value
             if me.val != oth.val:
                 return False
             SCREAMING_SNAKE_CASE__								=me.next_node
             SCREAMING_SNAKE_CASE__								=oth.next_node

         return True




     def __iter__(	self			: Optional[Any]						)		->   Deque._Iterator:


         '''simple docstring'''





         return Deque._Iterator(self._front						)




     def __repr__(	self			: Optional[Any]						)		->   str:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__								=[]
         SCREAMING_SNAKE_CASE__								=self._front
         while aux is not None:
             # append the values in a list to display
             values_list.append(aux.val						)
             SCREAMING_SNAKE_CASE__								=aux.next_node

         return f"""[{", ".join(repr(_UpperCamelCase						) for val in values_list						)}]"""


if __name__ == "__main__":
    import doctest

    doctest.testmod()






