




'''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     UpperCAmelCase_     (unittest.TestCase,      a__     ):







						"""simple docstring"""


						def       _a    (     self      :       str    ):





											"""simple docstring"""







											A_ :     str =							load_tool('''translation'''    )
											self.tool.setup()
											A_ :     Tuple =							load_tool('''translation'''							, remote=_lowerCamelCase    )







						def       _a    (     self      :       Dict    ):





											"""simple docstring"""







											A_ :     Tuple =							self.tool('''Hey, what\'s up?'''							, src_lang='''English'''							, tgt_lang='''French'''    )
											self.assertEqual(_lowerCamelCase							, '''- Hé, comment ça va?'''    )







						def       _a    (     self      :       Optional[Any]    ):





											"""simple docstring"""







											A_ :     str =							self.remote_tool('''Hey, what\'s up?'''							, src_lang='''English'''							, tgt_lang='''French'''    )
											self.assertEqual(_lowerCamelCase							, '''- Hé, comment ça va?'''    )







						def       _a    (     self      :       Tuple    ):





											"""simple docstring"""







											A_ :     List[Any] =							self.tool(text='''Hey, what\'s up?'''							, src_lang='''English'''							, tgt_lang='''French'''    )
											self.assertEqual(_lowerCamelCase							, '''- Hé, comment ça va?'''    )







						def       _a    (     self      :       Any    ):





											"""simple docstring"""







											A_ :     Tuple =							self.remote_tool(text='''Hey, what\'s up?'''							, src_lang='''English'''							, tgt_lang='''French'''    )
											self.assertEqual(_lowerCamelCase							, '''- Hé, comment ça va?'''    )







						def       _a    (     self      :       Optional[Any]    ):





											"""simple docstring"""







											A_ :     List[Any] =							['''Hey, what\'s up?''', '''English''', '''Spanish''']
											A_ :     List[Any] =							self.tool(*_lowerCamelCase    )

											# There is a single output
											if len(self.tool.outputs    ) == 1:
																A_ :     List[Any] =							[outputs]

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







						def       _a    (     self      :       Any    ):





											"""simple docstring"""







											A_ :     Optional[int] =							['''Hey, what\'s up?''', '''English''', '''Spanish''']
											A_ :     List[str] =							self.tool(*_lowerCamelCase    )

											if not isinstance(_lowerCamelCase							, _lowerCamelCase    ):
																A_ :     Optional[Any] =							[outputs]

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

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







						def       _a    (     self      :       Dict    ):





											"""simple docstring"""







											A_ :     Any =							['''Hey, what\'s up?''', '''English''', '''Spanish''']

											A_ :     Union[str, Any] =							[]

											for _input, input_type in zip(_lowerCamelCase							, self.tool.inputs    ):
																if isinstance(_lowerCamelCase							, _lowerCamelCase    ):
																					_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
											A_ :     Optional[int] =							self.tool(*_lowerCamelCase    )

											if not isinstance(_lowerCamelCase							, _lowerCamelCase    ):
																A_ :     List[Any] =							[outputs]

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









'''simple docstring'''




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


snake_case__          =						logging.get_logger(__name__)

snake_case__          =						{
    """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
    # QDQBERT models can be loaded from any BERT checkpoint, available at https://huggingface.co/models?filter=bert
}






class     UpperCamelCase_     (a__     ):







						"""simple docstring"""


						_lowerCAmelCase    						=					'qdqbert'







						def __init__(     self      :       Union[str, Any]							, _lowerCamelCase      :       List[Any]=30522							, _lowerCamelCase      :       str=768							, _lowerCamelCase      :       Optional[Any]=12							, _lowerCamelCase      :       str=12							, _lowerCamelCase      :       List[Any]=3072							, _lowerCamelCase      :       Union[str, Any]="gelu"							, _lowerCamelCase      :       Dict=0.1							, _lowerCamelCase      :       Union[str, Any]=0.1							, _lowerCamelCase      :       Optional[int]=512							, _lowerCamelCase      :       Dict=2							, _lowerCamelCase      :       Optional[Any]=0.02							, _lowerCamelCase      :       List[Any]=1E-12							, _lowerCamelCase      :       Tuple=True							, _lowerCamelCase      :       Tuple=1							, _lowerCamelCase      :       Optional[Any]=0							, _lowerCamelCase      :       Optional[int]=2							, **_lowerCamelCase      :       List[str]							, ):





											"""simple docstring"""







											super().__init__(pad_token_id=_lowerCamelCase							, bos_token_id=_lowerCamelCase							, eos_token_id=_lowerCamelCase							, **_lowerCamelCase    )

											A_ :     Optional[Any] =							vocab_size
											A_ :     str =							max_position_embeddings
											A_ :     List[str] =							hidden_size
											A_ :     str =							num_hidden_layers
											A_ :     List[str] =							num_attention_heads
											A_ :     List[str] =							intermediate_size
											A_ :     int =							hidden_act
											A_ :     Tuple =							hidden_dropout_prob
											A_ :     Optional[Any] =							attention_probs_dropout_prob
											A_ :     Dict =							initializer_range
											A_ :     Optional[int] =							type_vocab_size
											A_ :     Any =							layer_norm_eps
											A_ :     Optional[int] =							use_cache



