




import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


_lowerCamelCase			:	Optional[Any]							 =     """
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        UpperCamelCase_					(				unittest.TestCase	,      UpperCAmelCase__  ):

    '''simple docstring'''






    def  SCREAMING_SNAKE_CASE							(    self   :			Tuple)		->Optional[int]:





           '''simple docstring'''

           A__   				=					load_tool('''text-question-answering''')
           self.tool.setup()
           A__   				=					load_tool('''text-question-answering'''      ,				remote=UpperCAmelCase__)


    def  SCREAMING_SNAKE_CASE							(    self   :			Tuple)		->int:





           '''simple docstring'''

           A__   				=					self.tool(UpperCAmelCase__      ,				'''What did Hugging Face do in April 2021?''')
           self.assertEqual(UpperCAmelCase__      ,				'''launched the BigScience Research Workshop''')


    def  SCREAMING_SNAKE_CASE							(    self   :			Optional[Any])		->List[str]:





           '''simple docstring'''

           A__   				=					self.remote_tool(UpperCAmelCase__      ,				'''What did Hugging Face do in April 2021?''')
           self.assertEqual(UpperCAmelCase__      ,				'''launched the BigScience Research Workshop''')


    def  SCREAMING_SNAKE_CASE							(    self   :			int)		->Optional[int]:





           '''simple docstring'''

           A__   				=					self.tool(text=UpperCAmelCase__      ,				question='''What did Hugging Face do in April 2021?''')
           self.assertEqual(UpperCAmelCase__      ,				'''launched the BigScience Research Workshop''')





    def  SCREAMING_SNAKE_CASE							(    self   :			int)		->int:





           '''simple docstring'''

           A__   				=					self.remote_tool(text=UpperCAmelCase__      ,				question='''What did Hugging Face do in April 2021?''')
           self.assertEqual(UpperCAmelCase__      ,				'''launched the BigScience Research Workshop''')








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        UpperCamelCase_					(				unittest.TestCase  ):

    '''simple docstring'''






    @slow
    def  SCREAMING_SNAKE_CASE							(    self   :			Optional[Any])		->Any:





           '''simple docstring'''

           A__   				=					AutoModelForSeqaSeqLM.from_pretrained('''google/mt5-small'''      ,				return_dict=UpperCAmelCase__).to(UpperCAmelCase__)
           A__   				=					AutoTokenizer.from_pretrained('''google/mt5-small''')

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

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

           A__   				=					-84.9127
           self.assertTrue(abs(mtf_score - EXPECTED_SCORE) < 1e-4)


