

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


SCREAMING_SNAKE_CASE		:Dict				  =    threading.Lock()
SCREAMING_SNAKE_CASE		:Optional[logging.Handler]				  =    None

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

SCREAMING_SNAKE_CASE		:Dict				  =    logging.WARNING

SCREAMING_SNAKE_CASE		:List[Any]				  =    True




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



    """simple docstring"""






    UpperCamelCase_      =	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  lowerCAmelCase(			)->	str:



    """simple docstring"""






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




def  lowerCAmelCase(			)->	logging.Logger:



    """simple docstring"""






    return logging.getLogger(_get_library_name() )




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    global _default_handler

    with _lock:
        if _default_handler:
            # This library has already configured the library root logger.
            return
        UpperCamelCase_      =	logging.StreamHandler()  # Set sys.stderr as stream.
        UpperCamelCase_      =	sys.stderr.flush

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




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    global _default_handler

    with _lock:
        if not _default_handler:
            return

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




def  lowerCAmelCase(			)->	str:



    """simple docstring"""






    return log_levels




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ = None )->	logging.Logger:



    """simple docstring"""






    if name is None:
        UpperCamelCase_      =	_get_library_name()

    _configure_library_root_logger()
    return logging.getLogger(_UpperCAmelCase )




def  lowerCAmelCase(			)->	int:



    """simple docstring"""






    _configure_library_root_logger()
    return _get_library_root_logger().getEffectiveLevel()




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	None:



    """simple docstring"""






    _configure_library_root_logger()
    _get_library_root_logger().setLevel(_UpperCAmelCase )




def  lowerCAmelCase(			)->	Optional[int]:



    """simple docstring"""






    return set_verbosity(_UpperCAmelCase )




def  lowerCAmelCase(			)->	int:



    """simple docstring"""






    return set_verbosity(_UpperCAmelCase )




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



    """simple docstring"""






    return set_verbosity(_UpperCAmelCase )




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



    """simple docstring"""






    return set_verbosity(_UpperCAmelCase )




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    _configure_library_root_logger()

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




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    _configure_library_root_logger()

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




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	None:



    """simple docstring"""






    _configure_library_root_logger()

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




def  lowerCAmelCase(			SCREAMING_SNAKE_CASE_ )->	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(_UpperCAmelCase )




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    _configure_library_root_logger()
    UpperCamelCase_      =	False




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    _configure_library_root_logger()
    UpperCamelCase_      =	True




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    UpperCamelCase_      =	_get_library_root_logger().handlers

    for handler in handlers:
        UpperCamelCase_      =	logging.Formatter("[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s" )
        handler.setFormatter(_UpperCAmelCase )




def  lowerCAmelCase(			)->	None:



    """simple docstring"""






    UpperCamelCase_      =	_get_library_root_logger().handlers

    for handler in handlers:
        handler.setFormatter(_UpperCAmelCase )




def  lowerCAmelCase(			self ,	*SCREAMING_SNAKE_CASE_ ,	**SCREAMING_SNAKE_CASE_ )->	str:



    """simple docstring"""






    UpperCamelCase_      =	os.getenv("DIFFUSERS_NO_ADVISORY_WARNINGS" ,	_UpperCAmelCase )
    if no_advisory_warnings:
        return
    self.warning(*_UpperCAmelCase ,	**_UpperCAmelCase )


SCREAMING_SNAKE_CASE		:Optional[Any]				  =    warning_advice






class 	__magic_name__				:






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






     def __iter__(							self  )->    Any:
         return iter(self._iterator  )






     def __getattr__(							self		,	_lowercase  )->    Optional[int]:

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

         return empty_fn






     def __enter__(							self  )->    List[str]:
         return self






     def __exit__(							self		,	_lowercase		,	_lowercase		,	_lowercase  )->    str:
         return






class 	__magic_name__				:






     def __call__(							self		,	*_lowercase		,	**_lowercase  )->    Optional[Any]:
         if _tqdm_active:
             return tqdm_lib.tqdm(*UpperCAmelCase_		,	**UpperCAmelCase_  )
         else:
             return EmptyTqdm(*UpperCAmelCase_		,	**UpperCAmelCase_  )






     def   UpperCAmelCase_							(							self		,	*_lowercase		,	**_lowercase  )->    Dict:
         UpperCamelCase_      =	None
         if _tqdm_active:
             return tqdm_lib.tqdm.set_lock(*UpperCAmelCase_		,	**UpperCAmelCase_  )






     def   UpperCAmelCase_							(							self  )->    Dict:
         if _tqdm_active:
             return tqdm_lib.tqdm.get_lock()
SCREAMING_SNAKE_CASE		:str				  =    _tqdm_cls()




def  lowerCAmelCase(			)->	bool:



    """simple docstring"""






    global _tqdm_active
    return bool(_tqdm_active )




def  lowerCAmelCase(			)->	Any:



    """simple docstring"""






    global _tqdm_active
    UpperCamelCase_      =	True




def  lowerCAmelCase(			)->	int:



    """simple docstring"""






    global _tqdm_active
    UpperCamelCase_      =	False








from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


SCREAMING_SNAKE_CASE		:Optional[Any]				  =    {"""configuration_t5""": ["""T5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """T5Config""", """T5OnnxConfig"""]}

try:
 if not is_sentencepiece_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE		:Dict				  =    ["""T5Tokenizer"""]

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE		:str				  =    ["""T5TokenizerFast"""]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE		:List[Any]				  =    [
     """T5_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """T5EncoderModel""",
     """T5ForConditionalGeneration""",
     """T5Model""",
     """T5PreTrainedModel""",
     """load_tf_weights_in_t5""",
     """T5ForQuestionAnswering""",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE		:int				  =    [
     """TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """TFT5EncoderModel""",
     """TFT5ForConditionalGeneration""",
     """TFT5Model""",
     """TFT5PreTrainedModel""",
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 SCREAMING_SNAKE_CASE		:List[str]				  =    [
     """FlaxT5EncoderModel""",
     """FlaxT5ForConditionalGeneration""",
     """FlaxT5Model""",
     """FlaxT5PreTrainedModel""",
 ]


if TYPE_CHECKING:
 from .configuration_ta import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, TaConfig, TaOnnxConfig

 try:
  if not is_sentencepiece_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_ta import TaTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_ta_fast import TaTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_ta import (
      T5_PRETRAINED_MODEL_ARCHIVE_LIST,
      TaEncoderModel,
      TaForConditionalGeneration,
      TaForQuestionAnswering,
      TaModel,
      TaPreTrainedModel,
      load_tf_weights_in_ta,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_ta import (
      TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFTaEncoderModel,
      TFTaForConditionalGeneration,
      TFTaModel,
      TFTaPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_ta import (
      FlaxTaEncoderModel,
      FlaxTaForConditionalGeneration,
      FlaxTaModel,
      FlaxTaPreTrainedModel,
  )


else:
 import sys

 SCREAMING_SNAKE_CASE		:List[Any]				  =    _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
