




'''simple docstring'''





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 tensorflow as tf

		from transformers import AutoTokenizer, TFAutoModelForSeqaSeqLM




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




			@slow
			def        lowerCAmelCase__    ( self							)    ->    Any:

										'''simple docstring'''




										snake_case_      =				TFAutoModelForSeqaSeqLM.from_pretrained("google/mt5-small"							)
										snake_case_      =				AutoTokenizer.from_pretrained("google/mt5-small"							)

										snake_case_      =				tokenizer("Hello there"    ,							return_tensors="tf"							).input_ids
										snake_case_      =				tokenizer("Hi I am"    ,							return_tensors="tf"							).input_ids

										snake_case_      =				model(a__    ,							labels=a__							).loss
										snake_case_      =				-tf.math.reduce_mean(a__							).numpy()

										snake_case_      =				-2_1.2_2_8_1_6_8
										self.assertTrue(abs(mtf_score - EXPECTED_SCORE							) < 2e-4							)










'''simple docstring'''





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin




class 			_snake_case		(     unittest.TestCase						,						lowercase_							):




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

										'''simple docstring'''




										snake_case_      =				load_tool("text-classification"							)
										self.tool.setup()
										snake_case_      =				load_tool("text-classification"    ,							remote=a__							)




			def        lowerCAmelCase__    ( self							)    ->    str:

										'''simple docstring'''




										snake_case_      =				self.tool("That's quite cool"    ,							["positive", "negative"]							)
										self.assertEqual(a__    ,							"positive"							)




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

										'''simple docstring'''




										snake_case_      =				self.remote_tool("That's quite cool"    ,							["positive", "negative"]							)
										self.assertEqual(a__    ,							"positive"							)




			def        lowerCAmelCase__    ( self							)    ->    int:

										'''simple docstring'''




										snake_case_      =				self.tool(text="That's quite cool"    ,							labels=["positive", "negative"]							)
										self.assertEqual(a__    ,							"positive"							)




			def        lowerCAmelCase__    ( self							)    ->    Any:

										'''simple docstring'''




										snake_case_      =				self.remote_tool(text="That's quite cool"    ,							labels=["positive", "negative"]							)
										self.assertEqual(a__    ,							"positive"							)




