




import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowerCAmelCase_					    = """
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  _lowerCAmelCase     (  unittest.TestCase    ,			_a	):

      def 	__magic_name__(   self		):
        lowerCAmelCase__				:  Optional[int]		       =     load_tool('''text-question-answering'''		)
        self.tool.setup()
        lowerCAmelCase__				:  int		       =     load_tool('''text-question-answering'''      ,				remote=_A		)

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

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

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







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







from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
     import numpy as np
     import tensorflow as tf

     from transformers import TFCamembertModel






@require_tf
@require_sentencepiece
@require_tokenizers
class  _lowerCAmelCase     (  unittest.TestCase	):

      @slow
      def 	__magic_name__(   self		):
        lowerCAmelCase__				:  Optional[Any]		       =     TFCamembertModel.from_pretrained('''jplu/tf-camembert-base'''		)

        lowerCAmelCase__				:  List[str]		       =     tf.convert_to_tensor(
            [[5, 121, 11, 660, 16, 730, 2_5543, 110, 83, 6]]      ,				dtype=tf.intaa      ,				)  # J'aime le camembert !"

        lowerCAmelCase__				:  str		       =     model(__UpperCAmelCase		)['''last_hidden_state''']
        lowerCAmelCase__				:  List[Any]		       =     tf.TensorShape((1, 10, 768)		)
        self.assertEqual(output.shape      ,				__UpperCAmelCase		)
        # compare the actual values for a slice.
        lowerCAmelCase__				:  int		       =     tf.convert_to_tensor(
            [[[-0.0254, 0.0235, 0.1027], [0.0606, -0.1811, -0.0418], [-0.1561, -0.1127, 0.2687]]]      ,				dtype=tf.floataa      ,				)
        # camembert = torch.hub.load('pytorch/fairseq', 'camembert.v0')
        # camembert.eval()
        # expected_slice = roberta.model.forward(input_ids)[0][:, :3, :3].detach()

        self.assertTrue(np.allclose(output[:, :3, :3].numpy()      ,				expected_slice.numpy()      ,				atol=1e-4		)		)

