




from collections import deque






def 					snake_case					(							A			)							->							Optional[int]:




	'''simple docstring'''


	return input(A			).strip().split(' '			)






def 					snake_case					(							A						,   A			)							->							dict[int, list[int]]:




	'''simple docstring'''


	lowerCamelCase_							:		dict[int, list[int]]							   =							{}
	for i in range(A			):
		lowerCamelCase_							:		Optional[int]							   =							[]

	for e in range(A			):
		lowerCamelCase_   ,			lowerCamelCase_							:		int							   =							(int(A			) for i in _input(f"Edge {e + 1}: <node1> <node2> "			))
		graph[x].append(A			)
	return graph






def 					snake_case					(							A						,   A			)							->							dict[int, list[int]]:




	'''simple docstring'''


	lowerCamelCase_							:		dict[int, list[int]]							   =							{}
	for i in range(A			):
		lowerCamelCase_							:		Optional[int]							   =							[]

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






def 					snake_case					(							A						,   A			)							->							dict[int, list[tuple[int, int]]]:




	'''simple docstring'''


	lowerCamelCase_							:		dict[int, list[tuple[int, int]]]							   =							{}
	for i in range(A			):
		lowerCamelCase_							:		List[str]							   =							[]

	for e in range(A			):
		lowerCamelCase_   ,			lowerCamelCase_   ,			lowerCamelCase_							:		Optional[int]							   =							(int(A			) 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__       , 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 					snake_case					(							A						,   A			)							->							Optional[Any]:




	'''simple docstring'''


	lowerCamelCase_   ,			lowerCamelCase_							:		Optional[Any]							   =							{s}, [s]
	print(A			)
	while _s:
		lowerCamelCase_							:		Any							   =							0
		for i in g[_s[-1]]:
			if i not in vis:
				_s.append(A			)
				vis.add(A			)
				lowerCamelCase_							:		Dict							   =							1
				print(A			)
				break
		if not flag:
			_s.pop()






def 					snake_case					(							A						,   A			)							->							List[str]:




	'''simple docstring'''


	lowerCamelCase_   ,			lowerCamelCase_							:		int							   =							{s}, deque([s]			)
	print(A			)
	while q:
		lowerCamelCase_							:		Tuple							   =							q.popleft()
		for v in g[u]:
			if v not in vis:
				vis.add(A			)
				q.append(A			)
				print(A			)






def 					snake_case					(							A						,   A			)							->							Union[str, Any]:




	'''simple docstring'''


	lowerCamelCase_   ,			lowerCamelCase_   ,			lowerCamelCase_							:		str							   =							{s: 0}, set(), {s: 0}
	while True:
		if len(A			) == len(A			) - 1:
			break
		lowerCamelCase_							:		str							   =							100000
		for i in dist:
			if i not in known and dist[i] < mini:
				lowerCamelCase_							:		Any							   =							dist[i]
				lowerCamelCase_							:		Union[str, Any]							   =							i
		known.add(A			)
		for v in g[u]:
			if v[0] not in known and dist[u] + v[1] < dist.get(v[0]						,   100000			):
				lowerCamelCase_							:		Optional[Any]							   =							dist[u] + v[1]
				lowerCamelCase_							:		Union[str, Any]							   =							u
	for i in dist:
		if i != s:
			print(dist[i]			)






def 					snake_case					(							A						,   A=None						,   A=None			)							->							List[str]:




	'''simple docstring'''


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






def 					snake_case					(							)							->							Dict:




	'''simple docstring'''


	lowerCamelCase_							:		str							   =							input().strip()
	lowerCamelCase_							:		str							   =							[]
	for _ in range(A			):
		a.append(map(A						,   input().strip().split()			)			)
	return a, n






def 					snake_case					(							A			)							->							List[str]:




	'''simple docstring'''


	((lowerCamelCase_)   ,			(lowerCamelCase_))							:		List[str]							   =							a_and_n
	lowerCamelCase_							:		Optional[Any]							   =							list(A			)
	lowerCamelCase_							:		str							   =							[[0] * n for i in range(A			)]
	for k in range(A			):
		for i in range(A			):
			for j in range(A			):
				if dist[i][j] > dist[i][k] + dist[k][j]:
					lowerCamelCase_							:		Dict							   =							dist[i][k] + dist[k][j]
					lowerCamelCase_							:		Any							   =							k
	print(A			)






def 					snake_case					(							A						,   A			)							->							List[Any]:




	'''simple docstring'''


	lowerCamelCase_   ,			lowerCamelCase_   ,			lowerCamelCase_							:		List[str]							   =							{s: 0}, set(), {s: 0}
	while True:
		if len(A			) == len(A			) - 1:
			break
		lowerCamelCase_							:		List[Any]							   =							100000
		for i in dist:
			if i not in known and dist[i] < mini:
				lowerCamelCase_							:		int							   =							dist[i]
				lowerCamelCase_							:		List[str]							   =							i
		known.add(A			)
		for v in g[u]:
			if v[0] not in known and v[1] < dist.get(v[0]						,   100000			):
				lowerCamelCase_							:		Dict							   =							v[1]
				lowerCamelCase_							:		Any							   =							u
	return dist






def 					snake_case					(							)							->							Optional[int]:




	'''simple docstring'''


	lowerCamelCase_   ,			lowerCamelCase_							:		List[Any]							   =							map(A						,   input().split(' '			)			)
	lowerCamelCase_							:		str							   =							[]
	for _ in range(A			):
		edges.append(map(A						,   input().split(' '			)			)			)
	return edges, n






def 					snake_case					(							A			)							->							Union[str, Any]:




	'''simple docstring'''


	((lowerCamelCase_)   ,			(lowerCamelCase_))							:		Any							   =							e_and_n
	e.sort(reverse=A						,   key=lambda A			: x[2]			)
	lowerCamelCase_							:		Any							   =							[{i} for i in range(1						,   n + 1			)]
	while True:
		if len(A			) == 1:
			break
		print(A			)
		lowerCamelCase_							:		Tuple							   =							e.pop()
		for i in range(len(A			)			):
			if x[0] in s[i]:
				break
		for j in range(len(A			)			):
			if x[1] in s[j]:
				if i == j:
					break
				s[j].update(s[i]			)
				s.pop(A			)
				break






def 					snake_case					(							A			)							->							int:




	'''simple docstring'''


	lowerCamelCase_							:		Optional[int]							   =							[]
	for node in graph:
		if not graph[node]:
			isolated.append(A			)
	return isolated






from typing import Optional

from ..utils.logging import get_logger
from .audio_classificiation import AudioClassification
from .automatic_speech_recognition import AutomaticSpeechRecognition
from .base import TaskTemplate
from .image_classification import ImageClassification
from .language_modeling import LanguageModeling
from .question_answering import QuestionAnsweringExtractive
from .summarization import Summarization
from .text_classification import TextClassification


UpperCamelCase__              =						[
    'AutomaticSpeechRecognition',
    'AudioClassification',
    'ImageClassification',
    'LanguageModeling',
    'QuestionAnsweringExtractive',
    'Summarization',
    'TaskTemplate',
    'TextClassification',
]

UpperCamelCase__              =						get_logger(__name__)


UpperCamelCase__              =						{
    AutomaticSpeechRecognition.task: AutomaticSpeechRecognition,
    AudioClassification.task: AudioClassification,
    ImageClassification.task: ImageClassification,
    LanguageModeling.task: LanguageModeling,
    QuestionAnsweringExtractive.task: QuestionAnsweringExtractive,
    Summarization.task: Summarization,
    TextClassification.task: TextClassification,
}






def 					snake_case					(							A			)							->							Optional[TaskTemplate]:




	'''simple docstring'''


	lowerCamelCase_							:		Any							   =							task_template_dict.get('task'			)
	if task_name is None:
		logger.warning(f"Couldn't find template for task '{task_name}'. Available templates: {list(A			)}"			)
		return None
	lowerCamelCase_							:		Any							   =							NAMEaTEMPLATE.get(A			)
	return template.from_dict(A			)
