


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


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

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

_lowerCAmelCase	:		Optional[Any]		  =						logging.WARNING

_lowerCAmelCase	:		List[Any]		  =						True

def       __UpperCamelCase     (     )     ->   List[str]:




	"""simple docstring"""





	lowerCAmelCase       :     List[str]   				=			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       __UpperCamelCase     (     )     ->   str:




	"""simple docstring"""





	return __name__.split('.'					)[0]

def       __UpperCamelCase     (     )     ->   logging.Logger:




	"""simple docstring"""





	return logging.getLogger(_get_library_name()					)

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	global _default_handler

	with _lock:
		if _default_handler:
			# This library has already configured the library root logger.
			return
		lowerCAmelCase       :     List[str]   				=			logging.StreamHandler()  # Set sys.stderr as stream.
		lowerCAmelCase       :     Any   				=			sys.stderr.flush

		# Apply our default configuration to the library root logger.
		lowerCAmelCase       :     Optional[int]   				=			_get_library_root_logger()
		library_root_logger.addHandler(_default_handler					)
		library_root_logger.setLevel(_get_default_logging_level()					)
		lowerCAmelCase       :     str   				=			False

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	global _default_handler

	with _lock:
		if not _default_handler:
			return

		lowerCAmelCase       :     Optional[int]   				=			_get_library_root_logger()
		library_root_logger.removeHandler(_default_handler					)
		library_root_logger.setLevel(logging.NOTSET					)
		lowerCAmelCase       :     Union[str, Any]   				=			None

def       __UpperCamelCase     (     )     ->   List[str]:




	"""simple docstring"""





	return log_levels

def       __UpperCamelCase     (     _A     :					Optional[str] = None					)     ->   logging.Logger:




	"""simple docstring"""





	if name is None:
		lowerCAmelCase       :     List[Any]   				=			_get_library_name()

	_configure_library_root_logger()
	return logging.getLogger(_A					)

def       __UpperCamelCase     (     )     ->   int:




	"""simple docstring"""





	_configure_library_root_logger()
	return _get_library_root_logger().getEffectiveLevel()

def       __UpperCamelCase     (     _A     :					int					)     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()
	_get_library_root_logger().setLevel(_A					)

def       __UpperCamelCase     (     )     ->   Optional[int]:




	"""simple docstring"""





	return set_verbosity(_A					)

def       __UpperCamelCase     (     )     ->   int:




	"""simple docstring"""





	return set_verbosity(_A					)

def       __UpperCamelCase     (     )     ->   int:




	"""simple docstring"""





	return set_verbosity(_A					)

def       __UpperCamelCase     (     )     ->   Tuple:




	"""simple docstring"""





	return set_verbosity(_A					)

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()

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

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()

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

def       __UpperCamelCase     (     _A     :					logging.Handler					)     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()

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

def       __UpperCamelCase     (     _A     :					logging.Handler					)     ->   None:




	"""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(_A					)

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()
	lowerCAmelCase       :     Tuple   				=			False

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	_configure_library_root_logger()
	lowerCAmelCase       :     str   				=			True

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	lowerCAmelCase       :     Tuple   				=			_get_library_root_logger().handlers

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

def       __UpperCamelCase     (     )     ->   None:




	"""simple docstring"""





	lowerCAmelCase       :     str   				=			_get_library_root_logger().handlers

	for handler in handlers:
		handler.setFormatter(_A					)

def       __UpperCamelCase     (     self     :					Optional[Any]       , *_A     :					str       , **_A     :					Tuple					)     ->   Optional[int]:




	"""simple docstring"""





	lowerCAmelCase       :     str   				=			os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'       , _A					)
	if no_advisory_warnings:
		return
	self.warning(*_A       , **_A					)


_lowerCAmelCase	:		Tuple		  =						warning_advice



class 			lowerCAmelCase					:



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



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



	def __getattr__(       self			,       snake_case__     ):

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

		return empty_fn



	def __enter__(       self     ):
		return self



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



class 			lowerCAmelCase					:



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



	def 					lowercase  (       self			,       *snake_case__			,       **snake_case__     ):
		lowerCAmelCase       :     Union[str, Any]   				=			None
		if _tqdm_active:
			return tqdm_lib.tqdm.set_lock(*snake_case__			,       **snake_case__     )



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


_lowerCAmelCase	:		List[Any]		  =						_tqdm_cls()

def       __UpperCamelCase     (     )     ->   bool:




	"""simple docstring"""





	global _tqdm_active
	return bool(_tqdm_active					)

def       __UpperCamelCase     (     )     ->   str:




	"""simple docstring"""





	global _tqdm_active
	lowerCAmelCase       :     List[str]   				=			True






def       __UpperCamelCase     (     )     ->   str:




	"""simple docstring"""





	global _tqdm_active
	lowerCAmelCase       :     List[str]   				=			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
