


import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


a_ :Union[str, Any]  							=			'\nHugging 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.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn 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]\n'

class 							lowercase  (						unittest.TestCase    ,       _UpperCAmelCase			):







     def 							lowercase__       (						self :						Dict      ):
           SCREAMING_SNAKE_CASE__       :  Dict						     =		load_tool('''text-question-answering'''      )
           self.tool.setup()
           SCREAMING_SNAKE_CASE__       :  Optional[Any]						     =		load_tool('''text-question-answering'''   ,   remote=_lowercase      )







     def 							lowercase__       (						self :						List[Any]      ):
           SCREAMING_SNAKE_CASE__       :  Union[str, Any]						     =		self.tool(_lowercase   ,   '''What did Hugging Face do in April 2021?'''      )
           self.assertEqual(_lowercase   ,   '''launched the BigScience Research Workshop'''      )







     def 							lowercase__       (						self :						Union[str, Any]      ):
           SCREAMING_SNAKE_CASE__       :  Tuple						     =		self.remote_tool(_lowercase   ,   '''What did Hugging Face do in April 2021?'''      )
           self.assertEqual(_lowercase   ,   '''launched the BigScience Research Workshop'''      )







     def 							lowercase__       (						self :						List[str]      ):
           SCREAMING_SNAKE_CASE__       :  Dict						     =		self.tool(text=_lowercase   ,   question='''What did Hugging Face do in April 2021?'''      )
           self.assertEqual(_lowercase   ,   '''launched the BigScience Research Workshop'''      )







     def 							lowercase__       (						self :						Optional[Any]      ):
           SCREAMING_SNAKE_CASE__       :  int						     =		self.remote_tool(text=_lowercase   ,   question='''What did Hugging Face do in April 2021?'''      )
           self.assertEqual(_lowercase   ,   '''launched the BigScience Research Workshop'''      )









from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 					lowercase							(			lowercase_     ):
				__SCREAMING_SNAKE_CASE   :					Union[str, Any]			     =     ['''image_processor''', '''tokenizer''']
				__SCREAMING_SNAKE_CASE   :					Tuple			     =     '''AutoImageProcessor'''
				__SCREAMING_SNAKE_CASE   :					Dict			     =     '''AutoTokenizer'''




				def __init__(   self ,  snake_case ,  snake_case			):
											super().__init__(snake_case ,  snake_case			)
											snake_case_     							=       self.image_processor




				def __call__(   self ,  snake_case=None ,  snake_case=None ,  snake_case=None ,  **snake_case			):

											if text is None and images is None:
																		raise ValueError('You have to specify either text or images. Both cannot be none.'			)

											if text is not None:
																		snake_case_     							=       self.tokenizer(snake_case ,  return_tensors=snake_case ,  **snake_case			)

											if images is not None:
																		snake_case_     							=       self.image_processor(snake_case ,  return_tensors=snake_case ,  **snake_case			)

											if text is not None and images is not None:
																		snake_case_     							=       image_features.pixel_values
																		return encoding
											elif text is not None:
																		return encoding
											else:
																		return BatchEncoding(data=dict(**snake_case			) ,  tensor_type=snake_case			)




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.batch_decode(*snake_case ,  **snake_case			)




				def        a				(   self ,  *snake_case ,  **snake_case			):
											return self.tokenizer.decode(*snake_case ,  **snake_case			)




				@property
				def        a				(   self			):
											return ["input_ids", "attention_mask", "pixel_values"]




