






import functools
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

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


snake_case__      :	Optional[int]        =      threading.Lock()
snake_case__      :	Optional[logging.Handler]        =      None

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

snake_case__      :	List[str]        =      logging.WARNING

snake_case__      :	List[str]        =      True






def     _snake_case    ():
   UpperCamelCase_									=     os.getenv('TRANSFORMERS_VERBOSITY'    ,      _lowerCAmelCase)
   if env_level_str:
      if env_level_str in log_levels:
         return log_levels[env_level_str]
      else:
         logging.getLogger().warning(
             f"""Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, """
             f"""has to be one of: { ", ".join(log_levels.keys()) }""")
   return _default_log_level






def     _snake_case    ():
   return __name__.split('.')[0]






def     _snake_case    ():
   return logging.getLogger(_get_library_name())






def     _snake_case    ():
   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     _snake_case    ():
   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     _snake_case    ():
   return log_levels






def     _snake_case    (__lowercase = None):

   if name is None:
      UpperCamelCase_									=     _get_library_name()

   _configure_library_root_logger()
   return logging.getLogger(_lowerCAmelCase)






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






def     _snake_case    (__lowercase):
   _configure_library_root_logger()
   _get_library_root_logger().setLevel(_lowerCAmelCase)






def     _snake_case    ():
   return set_verbosity(_lowerCAmelCase)






def     _snake_case    ():
   return set_verbosity(_lowerCAmelCase)






def     _snake_case    ():
   return set_verbosity(_lowerCAmelCase)






def     _snake_case    ():
   return set_verbosity(_lowerCAmelCase)






def     _snake_case    ():
   _configure_library_root_logger()

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






def     _snake_case    ():
   _configure_library_root_logger()

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






def     _snake_case    (__lowercase):
   _configure_library_root_logger()

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






def     _snake_case    (__lowercase):
   _configure_library_root_logger()

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






def     _snake_case    ():
   _configure_library_root_logger()
   UpperCamelCase_									=     False






def     _snake_case    ():
   _configure_library_root_logger()
   UpperCamelCase_									=     True






def     _snake_case    ():
   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(_lowerCAmelCase)






def     _snake_case    ():
   UpperCamelCase_									=     _get_library_root_logger().handlers

   for handler in handlers:
      handler.setFormatter(_lowerCAmelCase)






def     _snake_case    (self    ,      *__lowercase    ,      **__lowercase):
   UpperCamelCase_									=     os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS'    ,      _lowerCAmelCase)
   if no_advisory_warnings:
      return
   self.warning(*_lowerCAmelCase    ,      **_lowerCAmelCase)


snake_case__      :	Tuple        =      warning_advice






@functools.lru_cache(_lowerCAmelCase)
def     _snake_case    (self    ,      *__lowercase    ,      **__lowercase):
   self.warning(*_lowerCAmelCase    ,      **_lowerCAmelCase)


snake_case__      :	str        =      warning_once


class 						_a       :






  """simple docstring"""





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




  def __iter__(     self )			-> Optional[int]:
     return iter(self._iterator )




  def __getattr__(     self		,		_UpperCAmelCase )			-> Tuple:




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

     return empty_fn




  def __enter__(     self )			-> str:
     return self




  def __exit__(     self		,		_UpperCAmelCase		,		_UpperCAmelCase		,		_UpperCAmelCase )			-> Optional[int]:
     return




class 						_a       :






  """simple docstring"""





  def __call__(     self		,		*_UpperCAmelCase		,		**_UpperCAmelCase )			-> Optional[int]:




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




  def    _UpperCAmelCase     (     self		,		*_UpperCAmelCase		,		**_UpperCAmelCase )			-> int:
     UpperCamelCase_									=     None
     if _tqdm_active:
        return tqdm_lib.tqdm.set_lock(*A_		,		**A_ )




  def    _UpperCAmelCase     (     self )			-> Tuple:




     if _tqdm_active:
        return tqdm_lib.tqdm.get_lock()




snake_case__      :	Union[str, Any]        =      _tqdm_cls()






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






def     _snake_case    ():
   global _tqdm_active
   UpperCamelCase_									=     True
   hf_hub_utils.enable_progress_bars()






def     _snake_case    ():
   global _tqdm_active
   UpperCamelCase_									=     False
   hf_hub_utils.disable_progress_bars()













from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_torch_available,
)


snake_case__      :	List[str]       	=      {
    """configuration_speecht5""": [
        """SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP""",
        """SpeechT5Config""",
        """SpeechT5HifiGanConfig""",
    ],
    """feature_extraction_speecht5""": ["""SpeechT5FeatureExtractor"""],
    """processing_speecht5""": ["""SpeechT5Processor"""],
}

try:
 if not is_sentencepiece_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 snake_case__      :	List[str]       	=      ["""SpeechT5Tokenizer"""]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 snake_case__      :	Any       	=      [
     """SPEECHT5_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """SpeechT5ForSpeechToText""",
     """SpeechT5ForSpeechToSpeech""",
     """SpeechT5ForTextToSpeech""",
     """SpeechT5Model""",
     """SpeechT5PreTrainedModel""",
     """SpeechT5HifiGan""",
 ]

if TYPE_CHECKING:
 from .configuration_speechta import (
     SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP,
     SPEECHT5_PRETRAINED_HIFIGAN_CONFIG_ARCHIVE_MAP,
     SpeechTaConfig,
     SpeechTaHifiGanConfig,
 )
 from .feature_extraction_speechta import SpeechTaFeatureExtractor
 from .processing_speechta import SpeechTaProcessor

 try:
  if not is_sentencepiece_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_speechta import SpeechTaTokenizer

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_speechta import (
      SPEECHT5_PRETRAINED_MODEL_ARCHIVE_LIST,
      SpeechTaForSpeechToSpeech,
      SpeechTaForSpeechToText,
      SpeechTaForTextToSpeech,
      SpeechTaHifiGan,
      SpeechTaModel,
      SpeechTaPreTrainedModel,
  )

else:
 import sys

 snake_case__      :	Optional[int]       	=      _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





