


'''simple docstring'''




import unittest

from transformers import load_tool
from transformers.tools.agent_types import AGENT_TYPE_MAPPING

from .test_tools_common import ToolTesterMixin, output_types



class 			lowerCAmelCase					(					unittest.TestCase   ,					a				):



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     str   				=			load_tool('translation'     )
		self.tool.setup()
		lowerCAmelCase       :     Dict   				=			load_tool('translation'			,       remote=snake_case__     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Any   				=			self.tool('Hey, what\'s up?'			,       src_lang='English'			,       tgt_lang='French'     )
		self.assertEqual(snake_case__			,       '- Hé, comment ça va?'     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Optional[Any]   				=			self.remote_tool('Hey, what\'s up?'			,       src_lang='English'			,       tgt_lang='French'     )
		self.assertEqual(snake_case__			,       '- Hé, comment ça va?'     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     int   				=			self.tool(text='Hey, what\'s up?'			,       src_lang='English'			,       tgt_lang='French'     )
		self.assertEqual(snake_case__			,       '- Hé, comment ça va?'     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Union[str, Any]   				=			self.remote_tool(text='Hey, what\'s up?'			,       src_lang='English'			,       tgt_lang='French'     )
		self.assertEqual(snake_case__			,       '- Hé, comment ça va?'     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Tuple   				=			['Hey, what\'s up?', 'English', 'Spanish']
		lowerCAmelCase       :     List[str]   				=			self.tool(*snake_case__     )

		# There is a single output
		if len(self.tool.outputs     ) == 1:
			lowerCAmelCase       :     int   				=			[outputs]

		self.assertListEqual(output_types(snake_case__     )			,       self.tool.outputs     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     str   				=			['Hey, what\'s up?', 'English', 'Spanish']
		lowerCAmelCase       :     Dict   				=			self.tool(*snake_case__     )

		if not isinstance(snake_case__			,       snake_case__     ):
			lowerCAmelCase       :     List[Any]   				=			[outputs]

		self.assertEqual(len(snake_case__     )			,       len(self.tool.outputs     )     )

		for output, output_type in zip(snake_case__			,       self.tool.outputs     ):
			lowerCAmelCase       :     Optional[int]   				=			AGENT_TYPE_MAPPING[output_type]
			self.assertTrue(isinstance(snake_case__			,       snake_case__     )     )



	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Optional[int]   				=			['Hey, what\'s up?', 'English', 'Spanish']

		lowerCAmelCase       :     int   				=			[]

		for _input, input_type in zip(snake_case__			,       self.tool.inputs     ):
			if isinstance(snake_case__			,       snake_case__     ):
				_inputs.append([AGENT_TYPE_MAPPING[_input_type](_input     ) for _input_type in input_type]     )
			else:
				_inputs.append(AGENT_TYPE_MAPPING[input_type](_input     )     )

        # Should not raise an error
		lowerCAmelCase       :     str   				=			self.tool(*snake_case__     )

		if not isinstance(snake_case__			,       snake_case__     ):
			lowerCAmelCase       :     Union[str, Any]   				=			[outputs]

		self.assertEqual(len(snake_case__     )			,       len(self.tool.outputs     )     )




'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCAmelCase	:		List[str]		  =						logging.get_logger(__name__)

_lowerCAmelCase	:		int		  =						{
    'facebook/opt-125m': 'https://huggingface.co/facebook/opt-125m/blob/main/config.json',
    'facebook/opt-350m': 'https://huggingface.co/facebook/opt-350m/blob/main/config.json',
    'facebook/opt-1.3b': 'https://huggingface.co/facebook/opt-1.3b/blob/main/config.json',
    'facebook/opt-2.7b': 'https://huggingface.co/facebook/opt-2.7b/blob/main/config.json',
    'facebook/opt-6.7b': 'https://huggingface.co/facebook/opt-6.7b/blob/main/config.json',
    'facebook/opt-13b': 'https://huggingface.co/facebook/opt-13b/blob/main/config.json',
}



class 			lowerCAmelCase					(					a				):
	_lowerCamelCase :       Dict         =			"""opt"""
	_lowerCamelCase :       Optional[Any]         =			["""past_key_values"""]



	def __init__(       self			,       snake_case__=5_0272			,       snake_case__=768			,       snake_case__=12			,       snake_case__=3072			,       snake_case__=2048			,       snake_case__=True			,       snake_case__=False			,       snake_case__=None			,       snake_case__=0.1			,       snake_case__=0.0			,       snake_case__=12			,       snake_case__="relu"			,       snake_case__=0.0			,       snake_case__=0.0_2			,       snake_case__=True			,       snake_case__=1			,       snake_case__=2			,       snake_case__=2			,       snake_case__=True			,       snake_case__=True			,       **snake_case__			,       ):
		super().__init__(
		    pad_token_id=snake_case__			,       bos_token_id=snake_case__			,       eos_token_id=snake_case__			,       **snake_case__			,       )
		lowerCAmelCase       :     Union[str, Any]   				=			vocab_size
		lowerCAmelCase       :     List[Any]   				=			max_position_embeddings
		lowerCAmelCase       :     List[str]   				=			num_attention_heads
		lowerCAmelCase       :     Dict   				=			word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
		lowerCAmelCase       :     Optional[Any]   				=			ffn_dim
		lowerCAmelCase       :     Optional[int]   				=			hidden_size
		lowerCAmelCase       :     List[str]   				=			num_hidden_layers
		lowerCAmelCase       :     Union[str, Any]   				=			dropout
		lowerCAmelCase       :     List[str]   				=			attention_dropout
		lowerCAmelCase       :     Union[str, Any]   				=			activation_function
		lowerCAmelCase       :     Optional[Any]   				=			init_std
		lowerCAmelCase       :     List[str]   				=			layerdrop
		lowerCAmelCase       :     Dict   				=			use_cache
		lowerCAmelCase       :     List[Any]   				=			do_layer_norm_before
		# We keep these variables at `True` for backward compatibility.
		lowerCAmelCase       :     List[str]   				=			enable_bias
		lowerCAmelCase       :     Dict   				=			layer_norm_elementwise_affine

		# Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
		# with checkpoints that have been fine-tuned before transformers v4.20.1
		# see https://github.com/facebookresearch/metaseq/pull/164
		lowerCAmelCase       :     Tuple   				=			_remove_final_layer_norm
