

"""simple docstring"""






import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


__lowerCamelCase										=		"\nHugging 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.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn 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]\n"
class        _lowercase					(     unittest.TestCase   , __UpperCAmelCase     ):







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      load_tool('''text-question-answering'''       )
      self.tool.setup()
      __magic_name__     =      load_tool('''text-question-answering''' ,						remote=UpperCamelCase_       )







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      self.tool(UpperCamelCase_ ,						'''What did Hugging Face do in April 2021?'''       )
      self.assertEqual(UpperCamelCase_ ,						'''launched the BigScience Research Workshop'''       )







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      self.remote_tool(UpperCamelCase_ ,						'''What did Hugging Face do in April 2021?'''       )
      self.assertEqual(UpperCamelCase_ ,						'''launched the BigScience Research Workshop'''       )







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      self.tool(text=UpperCamelCase_ ,						question='''What did Hugging Face do in April 2021?'''       )
      self.assertEqual(UpperCamelCase_ ,						'''launched the BigScience Research Workshop'''       )







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      self.remote_tool(text=UpperCamelCase_ ,						question='''What did Hugging Face do in April 2021?'''       )
      self.assertEqual(UpperCamelCase_ ,						'''launched the BigScience Research Workshop'''       )




"""simple docstring"""






import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
 from transformers import AutoModelForSeqaSeqLM, AutoTokenizer
@require_torch
@require_sentencepiece
@require_tokenizers
class        _lowercase					(     unittest.TestCase     ):







     @slow
     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small''' ,						return_dict=UpperCamelCase_       ).to(UpperCamelCase_       )
      __magic_name__     =      AutoTokenizer.from_pretrained('''google/mt5-small'''       )

      __magic_name__     =      tokenizer('''Hello there''' ,						return_tensors='''pt'''       ).input_ids
      __magic_name__     =      tokenizer('''Hi I am''' ,						return_tensors='''pt'''       ).input_ids

      __magic_name__     =      model(input_ids.to(UpperCamelCase_       ) ,						labels=labels.to(UpperCamelCase_       )       ).loss
      __magic_name__     =      -(labels.shape[-1] * loss.item())

      __magic_name__     =      -8_4.9_1_2_7
      self.assertTrue(abs(mtf_score - EXPECTED_SCORE       ) < 1E-4       )

