



from collections import deque





def     __lowerCamelCase							(   __magic_name__						:	Tuple    ):
							return input(UpperCAmelCase_    ).strip().split(" "    )





def     __lowerCamelCase							(   __magic_name__						:	int  ,			__magic_name__						:	int    ):
							a__:							dict[int, list[int]]									={}
							for i in range(UpperCAmelCase_    ):
														a__:							Any									=[]

							for e in range(UpperCAmelCase_    ):
														a__:							Any									=(int(UpperCAmelCase_    ) for i in _input(F"Edge {e + 1}: <node1> <node2> "    ))
														graph[x].append(UpperCAmelCase_    )
							return graph





def     __lowerCamelCase							(   __magic_name__						:	int  ,			__magic_name__						:	int    ):
							a__:							dict[int, list[int]]									={}
							for i in range(UpperCAmelCase_    ):
														a__:							List[str]									=[]

							for e in range(UpperCAmelCase_    ):
														a__:							Optional[Any]									=(int(UpperCAmelCase_    ) for i in _input(F"Edge {e + 1}: <node1> <node2> "    ))
														graph[x].append(UpperCAmelCase_    )
														graph[y].append(UpperCAmelCase_    )
							return graph





def     __lowerCamelCase							(   __magic_name__						:	int  ,			__magic_name__						:	int    ):
							a__:							dict[int, list[tuple[int, int]]]									={}
							for i in range(UpperCAmelCase_    ):
														a__:							Dict									=[]

							for e in range(UpperCAmelCase_    ):
														a__:							List[Any]									=(int(UpperCAmelCase_    ) for i in _input(F"Edge {e + 1}: <node1> <node2> <weight> "    ))
														graph[x].append((y, w)    )
														graph[y].append((x, w)    )
							return graph


if __name__ == "__main__":
		__UpperCAmelCase    	=  (int(i) for i in _input('''Number of nodes and edges: '''))

		__UpperCAmelCase    	=  int(
		    _input(
		        '''Press 1 or 2 or 3 \n'''
		        '''1. Unweighted directed \n'''
		        '''2. Unweighted undirected \n'''
		        '''3. Weighted undirected \n'''
		    )[0]
		)

		__UpperCAmelCase    	=  {
		    1: initialize_unweighted_directed_graph,
		    2: initialize_unweighted_undirected_graph,
		    3: initialize_weighted_undirected_graph,
		}[graph_choice](n, m)





def     __lowerCamelCase							(   __magic_name__						:	Union[str, Any]  ,			__magic_name__						:	Optional[int]    ):
							a__:							int									={s}, [s]
							print(UpperCAmelCase_    )
							while _s:
														a__:							Union[str, Any]									=0
														for i in g[_s[-1]]:
																					if i not in vis:
																												_s.append(UpperCAmelCase_    )
																												vis.add(UpperCAmelCase_    )
																												a__:							List[Any]									=1
																												print(UpperCAmelCase_    )
																												break
														if not flag:
																					_s.pop()





def     __lowerCamelCase							(   __magic_name__						:	Tuple  ,			__magic_name__						:	Optional[Any]    ):
							a__:							Dict									={s}, deque([s]    )
							print(UpperCAmelCase_    )
							while q:
														a__:							Dict									=q.popleft()
														for v in g[u]:
																					if v not in vis:
																												vis.add(UpperCAmelCase_    )
																												q.append(UpperCAmelCase_    )
																												print(UpperCAmelCase_    )





def     __lowerCamelCase							(   __magic_name__						:	Optional[int]  ,			__magic_name__						:	Union[str, Any]    ):
							a__:							str									={s: 0}, set(), {s: 0}
							while True:
														if len(UpperCAmelCase_    ) == len(UpperCAmelCase_    ) - 1:
																					break
														a__:							List[Any]									=100_000
														for i in dist:
																					if i not in known and dist[i] < mini:
																												a__:							str									=dist[i]
																												a__:							Dict									=i
														known.add(UpperCAmelCase_    )
														for v in g[u]:
																					if v[0] not in known and dist[u] + v[1] < dist.get(v[0]  ,			100_000    ):
																												a__:							List[str]									=dist[u] + v[1]
																												a__:							Optional[Any]									=u
							for i in dist:
														if i != s:
																					print(dist[i]    )





def     __lowerCamelCase							(   __magic_name__						:	Dict  ,			__magic_name__						:	Optional[int]=None  ,			__magic_name__						:	List[Any]=None    ):





							if q is None:
														a__:							List[str]									=[1]
							if ind is None:
														a__:							List[str]									=[0] * (len(UpperCAmelCase_    ) + 1)  # SInce oth Index is ignored
														for u in g:
																					for v in g[u]:
																												ind[v] += 1
														a__:							Optional[Any]									=deque()
														for i in g:
																					if ind[i] == 0:
																												q.append(UpperCAmelCase_    )
							if len(UpperCAmelCase_    ) == 0:
														return
							a__:							Any									=q.popleft()
							print(UpperCAmelCase_    )
							for w in g[v]:
														ind[w] -= 1
														if ind[w] == 0:
																					q.append(UpperCAmelCase_    )
							topo(UpperCAmelCase_  ,			UpperCAmelCase_  ,			UpperCAmelCase_    )





def     __lowerCamelCase							(   ):
							a__:							str									=input().strip()
							a__:							List[str]									=[]
							for _ in range(UpperCAmelCase_    ):
														a.append(map(UpperCAmelCase_  ,			input().strip().split()    )    )
							return a, n





def     __lowerCamelCase							(   __magic_name__						:	Tuple    ):
							(a__):							Tuple									=a_and_n
							a__:							List[Any]									=list(UpperCAmelCase_    )
							a__:							Tuple									=[[0] * n for i in range(UpperCAmelCase_    )]
							for k in range(UpperCAmelCase_    ):
														for i in range(UpperCAmelCase_    ):
																					for j in range(UpperCAmelCase_    ):
																												if dist[i][j] > dist[i][k] + dist[k][j]:
																																			a__:							List[str]									=dist[i][k] + dist[k][j]
																																			a__:							Tuple									=k
							print(UpperCAmelCase_    )





def     __lowerCamelCase							(   __magic_name__						:	str  ,			__magic_name__						:	Optional[int]    ):
							a__:							Union[str, Any]									={s: 0}, set(), {s: 0}
							while True:
														if len(UpperCAmelCase_    ) == len(UpperCAmelCase_    ) - 1:
																					break
														a__:							str									=100_000
														for i in dist:
																					if i not in known and dist[i] < mini:
																												a__:							str									=dist[i]
																												a__:							Union[str, Any]									=i
														known.add(UpperCAmelCase_    )
														for v in g[u]:
																					if v[0] not in known and v[1] < dist.get(v[0]  ,			100_000    ):
																												a__:							int									=v[1]
																												a__:							Optional[Any]									=u
							return dist





def     __lowerCamelCase							(   ):
							a__:							Union[str, Any]									=map(UpperCAmelCase_  ,			input().split(" "    )    )
							a__:							Dict									=[]
							for _ in range(UpperCAmelCase_    ):
														edges.append(map(UpperCAmelCase_  ,			input().split(" "    )    )    )
							return edges, n





def     __lowerCamelCase							(   __magic_name__						:	str    ):
							(a__):							int									=e_and_n
							e.sort(reverse=UpperCAmelCase_  ,			key=lambda __magic_name__    : x[2]    )
							a__:							List[str]									=[{i} for i in range(1  ,			n + 1    )]
							while True:
														if len(UpperCAmelCase_    ) == 1:
																					break
														print(UpperCAmelCase_    )
														a__:							List[Any]									=e.pop()
														for i in range(len(UpperCAmelCase_    )    ):
																					if x[0] in s[i]:
																												break
														for j in range(len(UpperCAmelCase_    )    ):
																					if x[1] in s[j]:
																												if i == j:
																																			break
																												s[j].update(s[i]    )
																												s.pop(UpperCAmelCase_    )
																												break







def     __lowerCamelCase							(   __magic_name__						:	Any    ):
							a__:							Tuple									=[]
							for node in graph:
														if not graph[node]:
																					isolated.append(UpperCAmelCase_    )
							return isolated






"""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


_a	:	Union[str, Any]=					"Here is a text containing a lot of information: '''{text}'''.\n\nCan you answer this question about the text: '{question}'"

class 						UpperCamelCase     (       lowercase		):
				UpperCAmelCase							: str       =						"""google/flan-t5-base"""
				UpperCAmelCase							: int       =						(
				    """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							: Dict       =						"""text_qa"""
				UpperCAmelCase							: Dict       =						AutoTokenizer
				UpperCAmelCase							: Optional[Any]       =						AutoModelForSeqaSeqLM

				UpperCAmelCase							: List[str]       =						["""text""", """text"""]
				UpperCAmelCase							: Any       =						["""text"""]



				def    _lowercase	(self							: Tuple      ,    _A							: str      ,    _A							: str)       ->      Tuple:
					__snake_case     :				List[Any] 						=					QA_PROMPT.format(text=_A      ,    question=_A)
					return self.pre_processor(_A      ,    return_tensors='pt')



				def    _lowercase	(self							: Tuple      ,    _A							: Optional[Any])       ->      List[Any]:
					__snake_case     :				List[Any] 						=					self.model.generate(**_A)

					__snake_case						,							__snake_case     :				Any 						=					inputs['input_ids'].shape
					__snake_case     :				Any 						=					output_ids.shape[0]

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






				def    _lowercase	(self							: Optional[int]      ,    _A							: int)       ->      str:
					return self.pre_processor.decode(_A      ,    skip_special_tokens=_A      ,    clean_up_tokenization_spaces=_A)





