


"""simple docstring"""


from collections import deque
from math import floor
from random import random
from time import time
class snake_case      :







		def __init__(					self      :       Optional[int]		)       ->						Optional[Any]:





						'''simple docstring'''







						_A					  =			{}







		def  a_ (					self      :       Optional[int]    ,   a__      :       Tuple    ,   a__      :       Optional[Any]    ,   a__      :       Optional[Any]=1		)       ->						Tuple:





						'''simple docstring'''







						if self.graph.get(lowerCamelCase_		):
										if self.graph[u].count([w, v]		) == 0:
														self.graph[u].append([w, v]		)
						else:
										_A					  =			[[w, v]]
						if not self.graph.get(lowerCamelCase_		):
										_A					  =			[]







		def  a_ (					self      :       str		)       ->						Tuple:





						'''simple docstring'''







						return list(self.graph		)







		def  a_ (					self      :       int    ,   a__      :       str    ,   a__      :       Any		)       ->						Optional[int]:





						'''simple docstring'''







						if self.graph.get(lowerCamelCase_		):
										for _ in self.graph[u]:
														if _[1] == v:
																		self.graph[u].remove(lowerCamelCase_		)







		def  a_ (					self      :       Union[str, Any]    ,   a__      :       Optional[Any]=-2    ,   a__      :       Tuple=-1		)       ->						int:





						'''simple docstring'''







						if s == d:
										return []
						_A					  =			[]
						_A					  =			[]
						if s == -2:
										_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			s

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if visited.count(node[1]		) < 1:
																						if node[1] == d:
																										visited.append(lowerCamelCase_		)
																										return visited
																						else:
																										stack.append(node[1]		)
																										visited.append(node[1]		)
																										_A					  =			node[1]
																										break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return visited







		def  a_ (					self      :       Optional[int]    ,   a__      :       List[str]=-1		)       ->						Union[str, Any]:





						'''simple docstring'''







						if c == -1:
										_A					  =			floor(random() * 1_00_00		) + 10
						for i in range(lowerCamelCase_		):
										# every vertex has max 100 edges
										for _ in range(floor(random() * 1_02		) + 1		):
														_A					  =			floor(random() * c		) + 1
														if n != i:
																		self.add_pair(lowerCamelCase_    ,   lowerCamelCase_    ,   1		)







		def  a_ (					self      :       Optional[int]    ,   a__      :       Dict=-2		)       ->						List[str]:





						'''simple docstring'''







						_A					  =			deque()
						_A					  =			[]
						if s == -2:
										_A					  =			list(self.graph		)[0]
						d.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						while d:
										_A					  =			d.popleft()
										if len(self.graph[s]		) != 0:
														for node in self.graph[s]:
																		if visited.count(node[1]		) < 1:
																						d.append(node[1]		)
																						visited.append(node[1]		)
						return visited







		def  a_ (					self      :       Union[str, Any]    ,   a__      :       Dict		)       ->						int:





						'''simple docstring'''







						_A					  =			0
						for x in self.graph:
										for y in self.graph[x]:
														if y[1] == u:
																		count += 1
						return count







		def  a_ (					self      :       Optional[int]    ,   a__      :       List[str]		)       ->						List[str]:





						'''simple docstring'''







						return len(self.graph[u]		)







		def  a_ (					self      :       Optional[int]    ,   a__      :       List[str]=-2		)       ->						Optional[Any]:





						'''simple docstring'''







						_A					  =			[]
						_A					  =			[]
						if s == -2:
										_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			s
						_A					  =			[]

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if visited.count(node[1]		) < 1:
																						stack.append(node[1]		)
																						visited.append(node[1]		)
																						_A					  =			node[1]
																						break

            # check if all the children are visited
										if s == ss:
														sorted_nodes.append(stack.pop()		)
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return sorted_nodes







		def  a_ (					self      :       int		)       ->						Union[str, Any]:





						'''simple docstring'''







						_A					  =			[]
						_A					  =			[]
						_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			-2
						_A					  =			[]
						_A					  =			s
						_A					  =			False
						_A					  =			set()

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if (
																		    visited.count(node[1]		) > 0
																		    and node[1] != parent
																		    and indirect_parents.count(node[1]		) > 0
																		    and not on_the_way_back
																		):
																						_A					  =			len(lowerCamelCase_		) - 1
																						while len_stack >= 0:
																										if stack[len_stack] == node[1]:
																														anticipating_nodes.add(node[1]		)
																														break
																										else:
																														anticipating_nodes.add(stack[len_stack]		)
																														len_stack -= 1
																		if visited.count(node[1]		) < 1:
																						stack.append(node[1]		)
																						visited.append(node[1]		)
																						_A					  =			node[1]
																						break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														_A					  =			True
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			False
														indirect_parents.append(lowerCamelCase_		)
														_A					  =			s
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return list(lowerCamelCase_		)







		def  a_ (					self      :       Tuple		)       ->						Optional[Any]:





						'''simple docstring'''







						_A					  =			[]
						_A					  =			[]
						_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			-2
						_A					  =			[]
						_A					  =			s
						_A					  =			False
						_A					  =			set()

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if (
																		    visited.count(node[1]		) > 0
																		    and node[1] != parent
																		    and indirect_parents.count(node[1]		) > 0
																		    and not on_the_way_back
																		):
																						_A					  =			len(lowerCamelCase_		) - 1
																						while len_stack_minus_one >= 0:
																										if stack[len_stack_minus_one] == node[1]:
																														anticipating_nodes.add(node[1]		)
																														break
																										else:
																														return True
																		if visited.count(node[1]		) < 1:
																						stack.append(node[1]		)
																						visited.append(node[1]		)
																						_A					  =			node[1]
																						break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														_A					  =			True
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			False
														indirect_parents.append(lowerCamelCase_		)
														_A					  =			s
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return False







		def  a_ (					self      :       Union[str, Any]    ,   a__      :       Optional[int]=-2    ,   a__      :       Any=-1		)       ->						int:





						'''simple docstring'''







						_A					  =			time()
						self.dfs(lowerCamelCase_    ,   lowerCamelCase_		)
						_A					  =			time()
						return end - begin







		def  a_ (					self      :       Tuple    ,   a__      :       Optional[Any]=-2		)       ->						Tuple:





						'''simple docstring'''







						_A					  =			time()
						self.bfs(lowerCamelCase_		)
						_A					  =			time()
						return end - begin





class snake_case      :







		def __init__(					self      :       Any		)       ->						Any:





						'''simple docstring'''







						_A					  =			{}







		def  a_ (					self      :       Tuple    ,   a__      :       List[Any]    ,   a__      :       Union[str, Any]    ,   a__      :       str=1		)       ->						List[Any]:





						'''simple docstring'''







						if self.graph.get(lowerCamelCase_		):
										# if there already is a edge
										if self.graph[u].count([w, v]		) == 0:
														self.graph[u].append([w, v]		)
						else:
										# if u does not exist
										_A					  =			[[w, v]]
						# add the other way
						if self.graph.get(lowerCamelCase_		):
										# if there already is a edge
										if self.graph[v].count([w, u]		) == 0:
														self.graph[v].append([w, u]		)
						else:
										# if u does not exist
										_A					  =			[[w, u]]







		def  a_ (					self      :       Union[str, Any]    ,   a__      :       List[Any]    ,   a__      :       int		)       ->						List[str]:





						'''simple docstring'''







						if self.graph.get(lowerCamelCase_		):
										for _ in self.graph[u]:
														if _[1] == v:
																		self.graph[u].remove(lowerCamelCase_		)
        # the other way round
						if self.graph.get(lowerCamelCase_		):
										for _ in self.graph[v]:
														if _[1] == u:
																		self.graph[v].remove(lowerCamelCase_		)







		def  a_ (					self      :       Tuple    ,   a__      :       List[str]=-2    ,   a__      :       Union[str, Any]=-1		)       ->						Union[str, Any]:





						'''simple docstring'''







						if s == d:
										return []
						_A					  =			[]
						_A					  =			[]
						if s == -2:
										_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			s

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if visited.count(node[1]		) < 1:
																						if node[1] == d:
																										visited.append(lowerCamelCase_		)
																										return visited
																						else:
																										stack.append(node[1]		)
																										visited.append(node[1]		)
																										_A					  =			node[1]
																										break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return visited







		def  a_ (					self      :       List[str]    ,   a__      :       Tuple=-1		)       ->						Any:





						'''simple docstring'''







						if c == -1:
										_A					  =			floor(random() * 1_00_00		) + 10
						for i in range(lowerCamelCase_		):
										# every vertex has max 100 edges
										for _ in range(floor(random() * 1_02		) + 1		):
														_A					  =			floor(random() * c		) + 1
														if n != i:
																		self.add_pair(lowerCamelCase_    ,   lowerCamelCase_    ,   1		)







		def  a_ (					self      :       Tuple    ,   a__      :       Optional[int]=-2		)       ->						Dict:





						'''simple docstring'''







						_A					  =			deque()
						_A					  =			[]
						if s == -2:
										_A					  =			list(self.graph		)[0]
						d.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						while d:
										_A					  =			d.popleft()
										if len(self.graph[s]		) != 0:
														for node in self.graph[s]:
																		if visited.count(node[1]		) < 1:
																						d.append(node[1]		)
																						visited.append(node[1]		)
						return visited







		def  a_ (					self      :       int    ,   a__      :       Optional[int]		)       ->						Optional[Any]:





						'''simple docstring'''







						return len(self.graph[u]		)







		def  a_ (					self      :       Optional[Any]		)       ->						int:





						'''simple docstring'''







						_A					  =			[]
						_A					  =			[]
						_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			-2
						_A					  =			[]
						_A					  =			s
						_A					  =			False
						_A					  =			set()

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if (
																		    visited.count(node[1]		) > 0
																		    and node[1] != parent
																		    and indirect_parents.count(node[1]		) > 0
																		    and not on_the_way_back
																		):
																						_A					  =			len(lowerCamelCase_		) - 1
																						while len_stack >= 0:
																										if stack[len_stack] == node[1]:
																														anticipating_nodes.add(node[1]		)
																														break
																										else:
																														anticipating_nodes.add(stack[len_stack]		)
																														len_stack -= 1
																		if visited.count(node[1]		) < 1:
																						stack.append(node[1]		)
																						visited.append(node[1]		)
																						_A					  =			node[1]
																						break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														_A					  =			True
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			False
														indirect_parents.append(lowerCamelCase_		)
														_A					  =			s
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return list(lowerCamelCase_		)







		def  a_ (					self      :       str		)       ->						Tuple:





						'''simple docstring'''







						_A					  =			[]
						_A					  =			[]
						_A					  =			list(self.graph		)[0]
						stack.append(lowerCamelCase_		)
						visited.append(lowerCamelCase_		)
						_A					  =			-2
						_A					  =			[]
						_A					  =			s
						_A					  =			False
						_A					  =			set()

						while True:
										# check if there is any non isolated nodes
										if len(self.graph[s]		) != 0:
														_A					  =			s
														for node in self.graph[s]:
																		if (
																		    visited.count(node[1]		) > 0
																		    and node[1] != parent
																		    and indirect_parents.count(node[1]		) > 0
																		    and not on_the_way_back
																		):
																						_A					  =			len(lowerCamelCase_		) - 1
																						while len_stack_minus_one >= 0:
																										if stack[len_stack_minus_one] == node[1]:
																														anticipating_nodes.add(node[1]		)
																														break
																										else:
																														return True
																		if visited.count(node[1]		) < 1:
																						stack.append(node[1]		)
																						visited.append(node[1]		)
																						_A					  =			node[1]
																						break

            # check if all the children are visited
										if s == ss:
														stack.pop()
														_A					  =			True
														if len(lowerCamelCase_		) != 0:
																		_A					  =			stack[len(lowerCamelCase_		) - 1]
										else:
														_A					  =			False
														indirect_parents.append(lowerCamelCase_		)
														_A					  =			s
														_A					  =			ss

										# check if se have reached the starting point
										if len(lowerCamelCase_		) == 0:
														return False







		def  a_ (					self      :       Union[str, Any]		)       ->						int:





						'''simple docstring'''







						return list(self.graph		)







		def  a_ (					self      :       Union[str, Any]    ,   a__      :       List[str]=-2    ,   a__      :       List[str]=-1		)       ->						List[str]:





						'''simple docstring'''







						_A					  =			time()
						self.dfs(lowerCamelCase_    ,   lowerCamelCase_		)
						_A					  =			time()
						return end - begin







		def  a_ (					self      :       Dict    ,   a__      :       Any=-2		)       ->						str:





						'''simple docstring'''







						_A					  =			time()
						self.bfs(lowerCamelCase_		)
						_A					  =			time()
						return end - begin








"""simple docstring"""


import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin
class snake_case      (  unittest.TestCase     ,				_UpperCamelCase):







		def  a_ (					self      :       Optional[Any]		)       ->						List[str]:





						'''simple docstring'''







						_A					  =			load_tool("text-classification"		)
						self.tool.setup()
						_A					  =			load_tool("text-classification"    ,   remote=a__		)







		def  a_ (					self      :       Optional[int]		)       ->						Dict:





						'''simple docstring'''







						_A					  =			self.tool("That's quite cool"    ,   ["positive", "negative"]		)
						self.assertEqual(a__    ,   "positive"		)







		def  a_ (					self      :       Optional[Any]		)       ->						Dict:





						'''simple docstring'''







						_A					  =			self.remote_tool("That's quite cool"    ,   ["positive", "negative"]		)
						self.assertEqual(a__    ,   "positive"		)







		def  a_ (					self      :       Dict		)       ->						Optional[int]:





						'''simple docstring'''







						_A					  =			self.tool(text="That's quite cool"    ,   labels=["positive", "negative"]		)
						self.assertEqual(a__    ,   "positive"		)







		def  a_ (					self      :       Dict		)       ->						Any:





						'''simple docstring'''







						_A					  =			self.remote_tool(text="That's quite cool"    ,   labels=["positive", "negative"]		)
						self.assertEqual(a__    ,   "positive"		)