





'''simple docstring'''







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


_lowercase       						=			threading.Lock()
_lowercase       						=			None

_lowercase       						=			{
    'debug': logging.DEBUG,
    'info': logging.INFO,
    'warning': logging.WARNING,
    'error': logging.ERROR,
    'critical': logging.CRITICAL,
}

_lowercase       						=			logging.WARNING

_lowercase       						=			True

def    __UpperCamelCase	(	) ->str:
 snake_case				=			os.getenv('''TRANSFORMERS_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 TRANSFORMERS_VERBOSITY={env_level_str}, """
       f"""has to be one of: { ', '.join(log_levels.keys()     ) }"""     )
 return _default_log_level

def    __UpperCamelCase	(	) ->str:
 return __name__.split('''.'''     )[0]

def    __UpperCamelCase	(	) ->logging.Logger:
 return logging.getLogger(_get_library_name()     )

def    __UpperCamelCase	(	) ->None:
 global _default_handler

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

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

def    __UpperCamelCase	(	) ->None:
 global _default_handler

 with _lock:
  if not _default_handler:
   return

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

def    __UpperCamelCase	(	) ->str:
 return log_levels

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

 if name is None:
  snake_case				=			_get_library_name()

 _configure_library_root_logger()
 return logging.getLogger(a     )

def    __UpperCamelCase	(	) ->int:
 _configure_library_root_logger()
 return _get_library_root_logger().getEffectiveLevel()

def    __UpperCamelCase	(	a    : int     ) ->None:
 _configure_library_root_logger()
 _get_library_root_logger().setLevel(a     )

def    __UpperCamelCase	(	) ->Any:
 return set_verbosity(a     )

def    __UpperCamelCase	(	) ->int:
 return set_verbosity(a     )

def    __UpperCamelCase	(	) ->Tuple:
 return set_verbosity(a     )

def    __UpperCamelCase	(	) ->Union[str, Any]:
 return set_verbosity(a     )

def    __UpperCamelCase	(	) ->None:
 _configure_library_root_logger()

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

def    __UpperCamelCase	(	) ->None:
 _configure_library_root_logger()

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

def    __UpperCamelCase	(	a    : logging.Handler     ) ->None:
 _configure_library_root_logger()

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

def    __UpperCamelCase	(	a    : logging.Handler     ) ->None:
 _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:
 _configure_library_root_logger()
 snake_case				=			False

def    __UpperCamelCase	(	) ->None:
 _configure_library_root_logger()
 snake_case				=			True

def    __UpperCamelCase	(	) ->None:
 snake_case				=			_get_library_root_logger().handlers

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

def    __UpperCamelCase	(	) ->None:
 snake_case				=			_get_library_root_logger().handlers

 for handler in handlers:
  handler.setFormatter(a     )

def    __UpperCamelCase	(	self    : List[str]					,   *a    : List[Any]					,   **a    : Union[str, Any]     ) ->Optional[Any]:
 snake_case				=			os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''					,   a     )
 if no_advisory_warnings:
  return
 self.warning(*a					,   **a     )


_lowercase       						=			warning_advice

@functools.lru_cache(a     )
def    __UpperCamelCase	(	self    : Optional[Any]					,   *a    : str					,   **a    : Dict     ) ->List[str]:
 self.warning(*a					,   **a     )


_lowercase       						=			warning_once
class 			_lowercase						:







     def __init__( self    ,   *A__    ,   **A__    ) ->	List[Any]:  # pylint: disable=unused-argument
      snake_case				=			args[0] if args else None







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







     def __getattr__( self    ,   A__    ) ->	Union[str, Any]:

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

      return empty_fn







     def __enter__( self    ) ->	Optional[Any]:
      return self







     def __exit__( self    ,   A__    ,   A__    ,   A__    ) ->	Dict:
      return




class 			_lowercase						:







     def __call__( self    ,   *A__    ,   **A__    ) ->	int:
      if _tqdm_active:
       return tqdm_lib.tqdm(*A__    ,   **A__    )
      else:
       return EmptyTqdm(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ,   *A__    ,   **A__    ) ->	List[Any]:
      snake_case				=			None
      if _tqdm_active:
       return tqdm_lib.tqdm.set_lock(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ) ->	Optional[Any]:
      if _tqdm_active:
       return tqdm_lib.tqdm.get_lock()




_lowercase       						=			_tqdm_cls()

def    __UpperCamelCase	(	) ->bool:
 global _tqdm_active
 return bool(_tqdm_active     )

def    __UpperCamelCase	(	) ->List[Any]:
 global _tqdm_active
 snake_case				=			True
 hf_hub_utils.enable_progress_bars()






def    __UpperCamelCase	(	) ->Any:
 global _tqdm_active
 snake_case				=			False
 hf_hub_utils.disable_progress_bars()








'''simple docstring'''







from ...utils import is_note_seq_available, is_transformers_available, is_torch_available
from ...utils import OptionalDependencyNotAvailable


try:
   if not (is_transformers_available() and is_torch_available()):
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
   from .notes_encoder import SpectrogramNotesEncoder
   from .continous_encoder import SpectrogramContEncoder
   from .pipeline_spectrogram_diffusion import (
       SpectrogramContEncoder,
       SpectrogramDiffusionPipeline,
       TaFilmDecoder,
   )

try:
   if not (is_transformers_available() and is_torch_available() and is_note_seq_available()):
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   from ...utils.dummy_transformers_and_torch_and_note_seq_objects import *  # noqa F403
else:
   from .midi_utils import MidiProcessor

