





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


_UpperCamelCase							=			threading.Lock()
_UpperCamelCase							=			None

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

_UpperCamelCase							=			logging.WARNING

_UpperCamelCase							=			True







def    lowerCAmelCase__(						)			->     Tuple:
  __snake_case :					Optional[Any]          =							os.getenv("TRANSFORMERS_VERBOSITY" ,  lowercase					)
  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    lowerCAmelCase__(						)			->     Tuple:
  return __name__.split("."					)[0]







def    lowerCAmelCase__(						)			->     Dict:
  return logging.getLogger(_get_library_name()					)







def    lowerCAmelCase__(						)			->     int:
  global _default_handler

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

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







def    lowerCAmelCase__(						)			->     List[str]:
  global _default_handler

  with _lock:
    if not _default_handler:
      return

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







def    lowerCAmelCase__(						)			->     List[Any]:
  return log_levels







def    lowerCAmelCase__(						lowercase							:     Optional[str] = None					)			->     List[str]:


  if name is None:
    __snake_case :					Any          =							_get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(lowercase					)







def    lowerCAmelCase__(						)			->     str:
  _configure_library_root_logger()
  return _get_library_root_logger().getEffectiveLevel()







def    lowerCAmelCase__(						lowercase							:     int					)			->     str:
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(lowercase					)







def    lowerCAmelCase__(						)			->     List[Any]:
  return set_verbosity(lowercase					)







def    lowerCAmelCase__(						)			->     List[Any]:
  return set_verbosity(lowercase					)







def    lowerCAmelCase__(						)			->     Tuple:
  return set_verbosity(lowercase					)







def    lowerCAmelCase__(						)			->     str:
  return set_verbosity(lowercase					)







def    lowerCAmelCase__(						)			->     Optional[Any]:
  _configure_library_root_logger()

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







def    lowerCAmelCase__(						)			->     str:
  _configure_library_root_logger()

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







def    lowerCAmelCase__(						lowercase							:     logging.Handler					)			->     Tuple:
  _configure_library_root_logger()

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







def    lowerCAmelCase__(						lowercase							:     logging.Handler					)			->     Optional[Any]:
  _configure_library_root_logger()

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







def    lowerCAmelCase__(						)			->     Any:
  _configure_library_root_logger()
  __snake_case :					str          =							False







def    lowerCAmelCase__(						)			->     Any:
  _configure_library_root_logger()
  __snake_case :					Any          =							True







def    lowerCAmelCase__(						)			->     Union[str, Any]:
  __snake_case :					str          =							_get_library_root_logger().handlers

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







def    lowerCAmelCase__(						)			->     Dict:
  __snake_case :					List[str]          =							_get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(lowercase					)







def    lowerCAmelCase__(						self							:     List[str] ,  *lowercase							:     Optional[Any] ,  **lowercase							:     Optional[int]					)			->     int:
  __snake_case :					str          =							os.getenv("TRANSFORMERS_NO_ADVISORY_WARNINGS" ,  lowercase					)
  if no_advisory_warnings:
    return
  self.warning(*lowercase ,  **lowercase					)


_UpperCamelCase							=			warning_advice







@functools.lru_cache(lowercase					)
def    lowerCAmelCase__(						self							:     List[str] ,  *lowercase							:     List[Any] ,  **lowercase							:     Union[str, Any]					)			->     Dict:
  self.warning(*lowercase ,  **lowercase					)


_UpperCamelCase							=			warning_once




class 					_lowerCamelCase			:



      """simple docstring"""






      def __init__(			self					,    *UpperCAmelCase					,    **UpperCAmelCase )							-> int:  # pylint: disable=unused-argument






        '''simple docstring'''






        __snake_case :					str          =							args[0] if args else None







      def __iter__(			self )							-> Any:






        '''simple docstring'''






        return iter(self._iterator )







      def __getattr__(			self					,    UpperCAmelCase )							-> str:






        '''simple docstring'''






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

        return empty_fn







      def __enter__(			self )							-> int:






        '''simple docstring'''






        return self







      def __exit__(			self					,    UpperCAmelCase					,    UpperCAmelCase					,    UpperCAmelCase )							-> Tuple:






        '''simple docstring'''






        return




class 					_lowerCamelCase			:



      """simple docstring"""






      def __call__(			self					,    *UpperCAmelCase					,    **UpperCAmelCase )							-> List[Any]:






        '''simple docstring'''






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







      def     UpperCAmelCase		(			self					,    *UpperCAmelCase					,    **UpperCAmelCase )							-> Any:






        '''simple docstring'''






        __snake_case :					List[str]          =							None
        if _tqdm_active:
          return tqdm_lib.tqdm.set_lock(*lowerCAmelCase_					,    **lowerCAmelCase_ )







      def     UpperCAmelCase		(			self )							-> str:






        '''simple docstring'''






        if _tqdm_active:
          return tqdm_lib.tqdm.get_lock()




_UpperCamelCase							=			_tqdm_cls()







def    lowerCAmelCase__(						)			->     List[Any]:
  global _tqdm_active
  return bool(_tqdm_active					)







def    lowerCAmelCase__(						)			->     Union[str, Any]:
  global _tqdm_active
  __snake_case :					Tuple          =							True
  hf_hub_utils.enable_progress_bars()







def    lowerCAmelCase__(						)			->     Tuple:
  global _tqdm_active
  __snake_case :					Optional[Any]          =							False
  hf_hub_utils.disable_progress_bars()







'''simple docstring'''


import requests
def 						snake_case_       (UpperCamelCase			:    str					,		UpperCamelCase			:    str ):





							'''simple docstring'''


							_a      	=							{'''Content-Type''': '''application/json'''}
							_a      	=							requests.post(UpperCamelCase					,		json={'''text''': message_body}					,		headers=UpperCamelCase )
							if response.status_code != 200:
														_a      	=							(
														    '''Request to slack returned an error '''
														    f'{response.status_code}, the response is:\n{response.text}'
														)
														raise ValueError(UpperCamelCase )


if __name__ == "__main__":
				# Set the slack url to the one provided by Slack when you create the webhook at
				# https://my.slack.com/services/new/incoming-webhook/
				send_slack_message('<YOUR MESSAGE BODY>', '<SLACK CHANNEL URL>')

