






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


_UpperCamelCase				:    int     =						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				:    Optional[int]     =						logging.WARNING

_UpperCamelCase				:    List[str]     =						True




def 			snake_case  ():







  '''simple docstring'''

  a     :			Any				=   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 			snake_case  ():







  '''simple docstring'''

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




def 			snake_case  ():







  '''simple docstring'''

  return logging.getLogger(_get_library_name()      )




def 			snake_case  ():







  '''simple docstring'''

  global _default_handler

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

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




def 			snake_case  ():







  '''simple docstring'''

  global _default_handler

  with _lock:
    if not _default_handler:
      return

    a     :			Optional[Any]				=   _get_library_root_logger()
    library_root_logger.removeHandler(_default_handler      )
    library_root_logger.setLevel(logging.NOTSET      )
    a     :			Any				=   None




def 			snake_case  ():







  '''simple docstring'''

  return log_levels




def 			snake_case  (A_      :Optional[str] = None      ):







  '''simple docstring'''

  if name is None:
    a     :			int				=   _get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(A_      )




def 			snake_case  ():







  '''simple docstring'''

  _configure_library_root_logger()
  return _get_library_root_logger().getEffectiveLevel()




def 			snake_case  (A_      :int      ):







  '''simple docstring'''

  _configure_library_root_logger()
  _get_library_root_logger().setLevel(A_      )




def 			snake_case  ():







  '''simple docstring'''

  return set_verbosity(A_      )




def 			snake_case  ():







  '''simple docstring'''

  return set_verbosity(A_      )




def 			snake_case  ():







  '''simple docstring'''

  return set_verbosity(A_      )




def 			snake_case  ():







  '''simple docstring'''

  return set_verbosity(A_      )




def 			snake_case  ():







  '''simple docstring'''

  _configure_library_root_logger()

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




def 			snake_case  ():







  '''simple docstring'''

  _configure_library_root_logger()

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




def 			snake_case  (A_      :logging.Handler      ):







  '''simple docstring'''

  _configure_library_root_logger()

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




def 			snake_case  (A_      :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(A_      )




def 			snake_case  ():







  '''simple docstring'''

  _configure_library_root_logger()
  a     :			Optional[Any]				=   False




def 			snake_case  ():







  '''simple docstring'''

  _configure_library_root_logger()
  a     :			str				=   True




def 			snake_case  ():







  '''simple docstring'''

  a     :			Union[str, Any]				=   _get_library_root_logger().handlers

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




def 			snake_case  ():







  '''simple docstring'''

  a     :			Dict				=   _get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(A_      )




def 			snake_case  (self      :int	,			*A_      :Optional[Any]	,			**A_      :List[Any]      ):







  '''simple docstring'''

  a     :			Any				=   os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'	,			A_      )
  if no_advisory_warnings:
    return
  self.warning(*A_	,			**A_      )


_UpperCamelCase				:    Optional[int]     =						warning_advice






class 						snake_case  :





    def __init__(							self	:					Union[str, Any]				,		*A	:					Dict				,		**A	:					str			):  # pylint: disable=unused-argument


      '''simple docstring'''




      a     :			int				=   args[0] if args else None





    def __iter__(							self	:					Dict			):


      '''simple docstring'''




      return iter(self._iterator			)





    def __getattr__(							self	:					Union[str, Any]				,		A	:					List[str]			):


      '''simple docstring'''




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

      return empty_fn





    def __enter__(							self	:					str			):


      '''simple docstring'''




      return self





    def __exit__(							self	:					List[Any]				,		A	:					Optional[Any]				,		A	:					Dict				,		A	:					Union[str, Any]			):


      '''simple docstring'''




      return






class 						snake_case  :





    def __call__(							self	:					Optional[Any]				,		*A	:					str				,		**A	:					int			):


      '''simple docstring'''




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





    def 				lowerCamelCase__      (							self	:					str				,		*A	:					Optional[int]				,		**A	:					List[Any]			):


      '''simple docstring'''




      a     :			Any				=   None
      if _tqdm_active:
        return tqdm_lib.tqdm.set_lock(*A				,		**A			)





    def 				lowerCamelCase__      (							self	:					Any			):


      '''simple docstring'''




      if _tqdm_active:
        return tqdm_lib.tqdm.get_lock()




_UpperCamelCase				:    int     =						_tqdm_cls()




def 			snake_case  ():







  '''simple docstring'''

  global _tqdm_active
  return bool(_tqdm_active      )




def 			snake_case  ():







  '''simple docstring'''

  global _tqdm_active
  a     :			List[str]				=   True






def 			snake_case  ():







  '''simple docstring'''

  global _tqdm_active
  a     :			int				=   False












"""simple docstring"""


import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


_UpperCamelCase				:    Optional[int]     =						logging.get_logger(__name__)






class 						snake_case  (  UpperCAmelCase       ):
    __magic_name__         =     '''speech-encoder-decoder'''
    __magic_name__         =     True





    def __init__(							self	:					Optional[Any]				,		**A	:					List[Any]			):


      '''simple docstring'''




      super().__init__(**A			)
      if "encoder" not in kwargs or "decoder" not in kwargs:
        raise ValueError(
            F'''A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and'''
            F''' `decoder` sub-configurations are passed, but only {kwargs}'''			)

      a     :			Optional[int]				=   kwargs.pop('encoder'			)
      a     :			Any				=   encoder_config.pop('model_type'			)
      a     :			Optional[Any]				=   kwargs.pop('decoder'			)
      a     :			str				=   decoder_config.pop('model_type'			)

      a     :			Tuple				=   AutoConfig.for_model(A				,		**A			)
      a     :			Dict				=   AutoConfig.for_model(A				,		**A			)
      a     :			Optional[Any]				=   True





    @classmethod
    def 				lowerCamelCase__      (							cls	:					List[Any]				,		A	:					PretrainedConfig				,		A	:					PretrainedConfig				,		**A	:					str			):


      '''simple docstring'''




      logger.info('Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'			)
      a     :			Any				=   True
      a     :			List[str]				=   True

      return cls(encoder=encoder_config.to_dict()				,		decoder=decoder_config.to_dict()				,		**A			)





    def 				lowerCamelCase__      (							self	:					Optional[int]			):


      '''simple docstring'''




      a     :			List[Any]				=   copy.deepcopy(self.__dict__			)
      a     :			int				=   self.encoder.to_dict()
      a     :			Optional[int]				=   self.decoder.to_dict()
      a     :			Any				=   self.__class__.model_type
      return output




