





"""simple docstring"""






from packaging import version

from .import_utils import is_accelerate_available


if is_accelerate_available():
		import accelerate






def      lowercase__ (					lowerCAmelCase__   :			Union[str, Any]			)    ->			Tuple:



			'''simple docstring'''
			if not is_accelerate_available():
						return method
			a__  :	Union[str, Any]		 =			version.parse(accelerate.__version__			).base_version
			if version.parse(lowerCAmelCase__			) < version.parse("0.17.0"			):
						return method

			def wrapper(self   :			List[str]							,			*lowerCAmelCase__   :			Optional[Any]							,			**lowerCAmelCase__   :			Optional[int]			):
						if hasattr(self							,			"_hf_hook"			) and hasattr(self._hf_hook							,			"pre_forward"			):
									self._hf_hook.pre_forward(self			)
						return method(self							,			*lowerCAmelCase__							,			**lowerCAmelCase__			)

			return wrapper






"""simple docstring"""






import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin



class 					__UpperCAmelCase							(						unittest.TestCase						,  _UpperCamelCase  ):
				def       UpperCAmelCase      (		self    :			Dict    )	->	List[Any]:



							'''simple docstring'''



							a__  :	Any		 =			load_tool("text-classification"    )
							self.tool.setup()
							a__  :	List[Any]		 =			load_tool("text-classification"	, remote=a_    )
				def       UpperCAmelCase      (		self    :			Optional[int]    )	->	Optional[Any]:



							'''simple docstring'''



							a__  :	str		 =			self.tool("That's quite cool"	, ["positive", "negative"]    )
							self.assertEqual(a_	, "positive"    )
				def       UpperCAmelCase      (		self    :			Union[str, Any]    )	->	Optional[int]:



							'''simple docstring'''



							a__  :	List[str]		 =			self.remote_tool("That's quite cool"	, ["positive", "negative"]    )
							self.assertEqual(a_	, "positive"    )
				def       UpperCAmelCase      (		self    :			Dict    )	->	Any:



							'''simple docstring'''



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






				def       UpperCAmelCase      (		self    :			List[Any]    )	->	List[Any]:



							'''simple docstring'''



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