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  __lowerCamelCase						(		):
       lowerCAmelCase__	      =   os.getenv('DIFFUSERS_VERBOSITY'      ,    _A      )
       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
              lowerCAmelCase__	      =   logging.StreamHandler()  # Set sys.stderr as stream.
              lowerCAmelCase__	      =   sys.stderr.flush

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






def  __lowerCamelCase						(		):
       global _default_handler

       with _lock:
              if not _default_handler:
                     return

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






def  __lowerCamelCase						(		):
       return log_levels






def  __lowerCamelCase						(		lowerCAmelCase__ = None      ):





       if name is None:
              lowerCAmelCase__	      =   _get_library_name()

       _configure_library_root_logger()
       return logging.getLogger(_A      )






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






def  __lowerCamelCase						(		lowerCAmelCase__      ):
       _configure_library_root_logger()
       _get_library_root_logger().setLevel(_A      )






def  __lowerCamelCase						(		):
       return set_verbosity(_A      )






def  __lowerCamelCase						(		):
       return set_verbosity(_A      )






def  __lowerCamelCase						(		):
       return set_verbosity(_A      )






def  __lowerCamelCase						(		):
       return set_verbosity(_A      )






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

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






def  __lowerCamelCase						(		lowerCAmelCase__      ):
       _configure_library_root_logger()

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






def  __lowerCamelCase						(		):
       _configure_library_root_logger()
       lowerCAmelCase__	      =   False






def  __lowerCamelCase						(		):
       _configure_library_root_logger()
       lowerCAmelCase__	      =   True






def  __lowerCamelCase						(		):
       lowerCAmelCase__	      =   _get_library_root_logger().handlers

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






def  __lowerCamelCase						(		):
       lowerCAmelCase__	      =   _get_library_root_logger().handlers

       for handler in handlers:
              handler.setFormatter(_A      )






def  __lowerCamelCase						(		self      ,    *lowerCAmelCase__      ,    **lowerCAmelCase__      ):
       lowerCAmelCase__	      =   os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'      ,    _A      )
       if no_advisory_warnings:
              return
       self.warning(*_A      ,    **_A      )


lowerCAmelCase__      		=					warning_advice
class 							a_					:






 '''simple docstring'''






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







        '''simple docstring'''



        lowerCAmelCase__	      =   args[0] if args else None




 def __iter__(     self   :    List[Any]):







        '''simple docstring'''



        return iter(self._iterator)




 def __getattr__(     self   :    List[str]     ,       lowercase__   :    List[str]):







        '''simple docstring'''



        def empty_fn(*lowercase__   :    List[Any]     ,       **lowercase__   :    Any):  # pylint: disable=unused-argument
               return

        return empty_fn




 def __enter__(     self   :    List[Any]):







        '''simple docstring'''



        return self




 def __exit__(     self   :    Dict     ,       lowercase__   :    str     ,       lowercase__   :    Tuple     ,       lowercase__   :    List[str]):







        '''simple docstring'''



        return






class 							a_					:






 '''simple docstring'''






 def __call__(     self   :    List[str]     ,       *lowercase__   :    int     ,       **lowercase__   :    Union[str, Any]):







        '''simple docstring'''



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




 def 						__snake_case		(     self   :    Tuple     ,       *lowercase__   :    Optional[int]     ,       **lowercase__   :    Tuple):







        '''simple docstring'''



        lowerCAmelCase__	      =   None
        if _tqdm_active:
               return tqdm_lib.tqdm.set_lock(*snake_case__     ,       **snake_case__)




 def 						__snake_case		(     self   :    List[Any]):







        '''simple docstring'''



        if _tqdm_active:
               return tqdm_lib.tqdm.get_lock()






lowerCAmelCase__      		=					_tqdm_cls()






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






def  __lowerCamelCase						(		):
       global _tqdm_active
       lowerCAmelCase__	      =   True






def  __lowerCamelCase						(		):
       global _tqdm_active
       lowerCAmelCase__	      =   False




'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCAmelCase	:		List[str]		  =						logging.get_logger(__name__)

_lowerCAmelCase	:		int		  =						{
    'facebook/opt-125m': 'https://huggingface.co/facebook/opt-125m/blob/main/config.json',
    'facebook/opt-350m': 'https://huggingface.co/facebook/opt-350m/blob/main/config.json',
    'facebook/opt-1.3b': 'https://huggingface.co/facebook/opt-1.3b/blob/main/config.json',
    'facebook/opt-2.7b': 'https://huggingface.co/facebook/opt-2.7b/blob/main/config.json',
    'facebook/opt-6.7b': 'https://huggingface.co/facebook/opt-6.7b/blob/main/config.json',
    'facebook/opt-13b': 'https://huggingface.co/facebook/opt-13b/blob/main/config.json',
}



class 			lowerCAmelCase					(					a				):
	_lowerCamelCase :       Dict         =			"""opt"""
	_lowerCamelCase :       Optional[Any]         =			["""past_key_values"""]



	def __init__(       self			,       snake_case__=5_0272			,       snake_case__=768			,       snake_case__=12			,       snake_case__=3072			,       snake_case__=2048			,       snake_case__=True			,       snake_case__=False			,       snake_case__=None			,       snake_case__=0.1			,       snake_case__=0.0			,       snake_case__=12			,       snake_case__="relu"			,       snake_case__=0.0			,       snake_case__=0.0_2			,       snake_case__=True			,       snake_case__=1			,       snake_case__=2			,       snake_case__=2			,       snake_case__=True			,       snake_case__=True			,       **snake_case__			,       ):
		super().__init__(
		    pad_token_id=snake_case__			,       bos_token_id=snake_case__			,       eos_token_id=snake_case__			,       **snake_case__			,       )
		lowerCAmelCase       :     Union[str, Any]   				=			vocab_size
		lowerCAmelCase       :     List[Any]   				=			max_position_embeddings
		lowerCAmelCase       :     List[str]   				=			num_attention_heads
		lowerCAmelCase       :     Dict   				=			word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
		lowerCAmelCase       :     Optional[Any]   				=			ffn_dim
		lowerCAmelCase       :     Optional[int]   				=			hidden_size
		lowerCAmelCase       :     List[str]   				=			num_hidden_layers
		lowerCAmelCase       :     Union[str, Any]   				=			dropout
		lowerCAmelCase       :     List[str]   				=			attention_dropout
		lowerCAmelCase       :     Union[str, Any]   				=			activation_function
		lowerCAmelCase       :     Optional[Any]   				=			init_std
		lowerCAmelCase       :     List[str]   				=			layerdrop
		lowerCAmelCase       :     Dict   				=			use_cache
		lowerCAmelCase       :     List[Any]   				=			do_layer_norm_before
		# We keep these variables at `True` for backward compatibility.
		lowerCAmelCase       :     List[str]   				=			enable_bias
		lowerCAmelCase       :     Dict   				=			layer_norm_elementwise_affine

		# Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
		# with checkpoints that have been fine-tuned before transformers v4.20.1
		# see https://github.com/facebookresearch/metaseq/pull/164
		lowerCAmelCase       :     Tuple   				=			_remove_final_layer_norm
