



"""simple docstring"""


# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer
from .base import PipelineTool


snake_case_								=			"""Here is a text containing a lot of information: '''{text}'''.

Can you answer this question about the text: '{question}'"""







class  A_     (	SCREAMING_SNAKE_CASE_							):



						"""simple docstring"""
						__UpperCamelCase													=				"""google/flan-t5-base"""
						__UpperCamelCase													=				(
						    """This is a tool that answers questions related to a text. It takes two arguments named `text`, which is the """
						    """text where to find the answer, and `question`, which is the question, and returns the answer to the question."""
						)
						__UpperCamelCase													=				"""text_qa"""
						__UpperCamelCase													=				AutoTokenizer
						__UpperCamelCase													=				AutoModelForSeqaSeqLM

						__UpperCamelCase													=				["""text""", """text"""]
						__UpperCamelCase													=				["""text"""]






						def       UpperCAmelCase__	(   self					:Tuple  ,    lowercase_					:str  ,    lowercase_					:str   )							->     Dict:
												UpperCAmelCase			 =					QA_PROMPT.format(text=lowercase_  ,    question=lowercase_   )
												return self.pre_processor(lowercase_  ,    return_tensors='pt'   )






						def       UpperCAmelCase__	(   self					:Any  ,    lowercase_					:Any   )							->     Any:
												UpperCAmelCase			 =					self.model.generate(**lowercase_   )

												UpperCAmelCase ,       UpperCAmelCase			 =					inputs['input_ids'].shape
												UpperCAmelCase			 =					output_ids.shape[0]

												return output_ids.reshape(lowercase_  ,    out_b // in_b  ,    *output_ids.shape[1:]   )[0][0]






						def       UpperCAmelCase__	(   self					:Union[str, Any]  ,    lowercase_					:Tuple   )							->     Optional[Any]:
												return self.pre_processor.decode(lowercase_  ,    skip_special_tokens=lowercase_  ,    clean_up_tokenization_spaces=lowercase_   )








from ..utils import DummyObject, requires_backends


class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)



class      lowerCamelCase_ (			metaclass=_lowerCAmelCase):
 _lowerCAmelCase									=	['''vision''']




 def __init__(			self  ,  *_UpperCAmelCase  ,  **_UpperCAmelCase							):
   requires_backends(self  ,  ['vision']							)





