




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:    List[str]											=   threading.Lock()
SCREAMING_SNAKE_CASE:    Optional[logging.Handler]											=   None

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

SCREAMING_SNAKE_CASE:    List[Any]											=   logging.WARNING

SCREAMING_SNAKE_CASE:    str											=   True


def 				_a       (				)->  List[str]:
  SCREAMING_SNAKE_CASE_							=       os.getenv('DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, '''
          F'''has to be one of: { ", ".join(log_levels.keys()   ) }'''   )
  return _default_log_level


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


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


def 				_a       (				)->  None:
  global _default_handler

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

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


def 				_a       (				)->  None:
  global _default_handler

  with _lock:
    if not _default_handler:
      return

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


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


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

  if name is None:
    SCREAMING_SNAKE_CASE_							=       _get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(lowerCAmelCase   )


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


def 				_a       (				lowerCAmelCase   )->  None:
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(lowerCAmelCase   )


def 				_a       (				)->  List[Any]:
  return set_verbosity(lowerCAmelCase   )


def 				_a       (				)->  List[Any]:
  return set_verbosity(lowerCAmelCase   )


def 				_a       (				)->  Dict:
  return set_verbosity(lowerCAmelCase   )


def 				_a       (				)->  Dict:
  return set_verbosity(lowerCAmelCase   )


def 				_a       (				)->  None:
  _configure_library_root_logger()

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


def 				_a       (				)->  None:
  _configure_library_root_logger()

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


def 				_a       (				lowerCAmelCase   )->  None:
  _configure_library_root_logger()

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


def 				_a       (				lowerCAmelCase   )->  None:
  _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 				_a       (				)->  None:
  _configure_library_root_logger()
  SCREAMING_SNAKE_CASE_							=       False


def 				_a       (				)->  None:
  _configure_library_root_logger()
  SCREAMING_SNAKE_CASE_							=       True


def 				_a       (				)->  None:
  SCREAMING_SNAKE_CASE_							=       _get_library_root_logger().handlers

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


def 				_a       (				)->  None:
  SCREAMING_SNAKE_CASE_							=       _get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(lowerCAmelCase   )


def 				_a       (				self						,	*lowerCAmelCase						,	**lowerCAmelCase   )->  Tuple:
  SCREAMING_SNAKE_CASE_							=       os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS'						,	lowerCAmelCase   )
  if no_advisory_warnings:
    return
  self.warning(*lowerCAmelCase						,	**lowerCAmelCase   )


SCREAMING_SNAKE_CASE:    int											=   warning_advice



class       lowercase_		:



      def __init__( self  :      Tuple				,       *snake_case__  :      int				,       **snake_case__  :      Optional[int]     ):  # pylint: disable=unused-argument

        """simple docstring"""

        SCREAMING_SNAKE_CASE_							=       args[0] if args else None



      def __iter__( self  :      Any     ):

        """simple docstring"""

        return iter(self._iterator     )



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

        """simple docstring"""

        def empty_fn(*snake_case__  :      Tuple				,       **snake_case__  :      Optional[Any]     ):  # pylint: disable=unused-argument
          return

        return empty_fn



      def __enter__( self  :      Union[str, Any]     ):

        """simple docstring"""

        return self






      def __exit__( self  :      int				,       snake_case__  :      int				,       snake_case__  :      str				,       snake_case__  :      Dict     ):

        """simple docstring"""

        return



class       lowercase_		:



      def __call__( self  :      int				,       *snake_case__  :      List[Any]				,       **snake_case__  :      Union[str, Any]     ):

        """simple docstring"""

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



      def   __a				( self  :      Tuple				,       *snake_case__  :      Tuple				,       **snake_case__  :      List[Any]     ):

        """simple docstring"""

        SCREAMING_SNAKE_CASE_							=       None
        if _tqdm_active:
          return tqdm_lib.tqdm.set_lock(*snake_case__				,       **snake_case__     )






      def   __a				( self  :      str     ):

        """simple docstring"""

        if _tqdm_active:
          return tqdm_lib.tqdm.get_lock()

SCREAMING_SNAKE_CASE:    List[Any]											=   _tqdm_cls()


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


def 				_a       (				)->  List[str]:
  global _tqdm_active
  SCREAMING_SNAKE_CASE_							=       True




def 				_a       (				)->  Dict:
  global _tqdm_active
  SCREAMING_SNAKE_CASE_							=       False





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


SCREAMING_SNAKE_CASE:    List[str]											=   '''
Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]
'''



class       lowercase_		(unittest.TestCase       ,  SCREAMING_SNAKE_CASE__   ):



						def   __a				( self  :      Dict     ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_							=       load_tool('summarization'     )
								self.tool.setup()
								SCREAMING_SNAKE_CASE_							=       load_tool('summarization'				,       remote=snake_case__     )



						def   __a				( self  :      Union[str, Any]     ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_							=       self.tool(snake_case__     )
								self.assertEqual(
								    snake_case__				,       'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'				,       )



						def   __a				( self  :      List[str]     ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_							=       self.remote_tool(snake_case__     )
								self.assertEqual(
								    snake_case__				,       'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'				,       )



						def   __a				( self  :      Optional[Any]     ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_							=       self.tool(text=snake_case__     )
								self.assertEqual(
								    snake_case__				,       'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'				,       )






						def   __a				( self  :      List[Any]     ):

								"""simple docstring"""

								SCREAMING_SNAKE_CASE_							=       self.remote_tool(text=snake_case__     )
								self.assertEqual(
								    snake_case__				,       'Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf. In March 2021, Hugging Face raised $40 million in a Series B funding round. On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model. In 2022, the workshop concluded with the announcement of BLOOM.'				,       )