






import math
import sys





class   SCREAMING_SNAKE_CASE :





							"""simple docstring"""

							def __init__(     self:      str      )			-> Optional[Any]:
												_A									=       0
												_A									=       []
												_A									=       {}  # To store the pos of node in array

							def 					__A       (     self:      List[Any]      )			-> List[str]:
												return self.cur_size == 0

							def 					__A       (     self:      Dict						,   __A:      Optional[int]      )			-> Tuple:
												_A									=       self.left(__A      )
												_A									=       self.right(__A      )
												if lc < self.cur_size and self.array(__A      )[0] < self.array(__A      )[0]:
																	_A									=       lc
												else:
																	_A									=       idx
												if rc < self.cur_size and self.array(__A      )[0] < self.array(__A      )[0]:
																	_A									=       rc
												if smallest != idx:
																	self.swap(__A						,   __A      )
																	self.min_heapify(__A      )

							def 					__A       (     self:      List[str]						,   __A:      Optional[Any]      )			-> str:
												# Inserts a node into the Priority Queue
												_A									=       self.cur_size
												self.cur_size += 1
												self.array.append((sys.maxsize, tup[1])      )
												self.decrease_key((sys.maxsize, tup[1])						,   tup[0]      )

							def 					__A       (     self:      Optional[Any]      )			-> List[Any]:
												# Removes and returns the min element at top of priority queue
												_A									=       self.array[0][1]
												_A									=       self.array[self.cur_size - 1]
												self.cur_size -= 1
												self.min_heapify(1      )
												del self.pos[min_node]
												return min_node

							def 					__A       (     self:      Any						,   __A:      Any      )			-> List[Any]:
												# returns the index of left child
												return 2 * i + 1

							def 					__A       (     self:      Any						,   __A:      int      )			-> Optional[int]:
												# returns the index of right child
												return 2 * i + 2

							def 					__A       (     self:      str						,   __A:      List[str]      )			-> Optional[int]:
												# returns the index of parent
												return math.floor(i / 2      )

							def 					__A       (     self:      Union[str, Any]						,   __A:      List[str]						,   __A:      Optional[int]      )			-> Union[str, Any]:
												# swaps array elements at indices i and j
												# update the pos{}
												_A									=       j
												_A									=       i
												_A									=       self.array[i]
												_A									=       self.array[j]
												_A									=       temp



							def 					__A       (     self:      List[str]						,   __A:      Optional[Any]						,   __A:      str      )			-> Union[str, Any]:
												_A									=       self.pos[tup[1]]
												# assuming the new_d is atmost old_d
												_A									=       (new_d, tup[1])
												while idx > 0 and self.array[self.par(__A      )][0] > self.array[idx][0]:
																	self.swap(__A						,   self.par(__A      )      )
																	_A									=       self.par(__A      )





class   SCREAMING_SNAKE_CASE :





							"""simple docstring"""

							def __init__(     self:      List[str]						,   __A:      int      )			-> Dict:
												_A									=       {}  # To store graph: u -> (v,w)
												_A									=       num  # Number of nodes in graph
												# To store the distance from source vertex
												_A									=       [0] * self.num_nodes
												_A									=       [-1] * self.num_nodes  # To store the path

							def 					__A       (     self:      Optional[Any]						,   __A:      Tuple						,   __A:      Dict						,   __A:      int      )			-> Union[str, Any]:
												#  Edge going from node u to v and v to u with weight w
												# u (w)-> v, v (w) -> u
												# Check if u already in graph
												if u in self.adjList:
																	self.adjList[u].append((v, w)      )
												else:
																	_A									=       [(v, w)]

												# Assuming undirected graph
												if v in self.adjList:
																	self.adjList[v].append((u, w)      )
												else:
																	_A									=       [(u, w)]

							def 					__A       (     self:      Optional[int]      )			-> List[Any]:
												# u -> v(w)
												for u in self.adjList:
																	print(__A						,   '''->'''						,   ''' -> '''.join(str(f"""{v}({w})"""      ) for v, w in self.adjList[u]      )      )

							def 					__A       (     self:      Dict						,   __A:      List[str]      )			-> int:
												# Flush old junk values in par[]
												_A									=       [-1] * self.num_nodes
												# src is the source node
												_A									=       0
												_A									=       PriorityQueue()
												q.insert((0, src)      )  # (dist from src, node)
												for u in self.adjList:
																	if u != src:
																						_A									=       sys.maxsize  # Infinity
																						_A									=       -1

												while not q.is_empty():
																	_A									=       q.extract_min()  # Returns node with the min dist from source
																	# Update the distance of all the neighbours of u and
																	# if their prev dist was INFINITY then push them in Q
																	for v, w in self.adjList[u]:
																						_A									=       self.dist[u] + w
																						if self.dist[v] > new_dist:
																											if self.dist[v] == sys.maxsize:
																																q.insert((new_dist, v)      )
																											else:
																																q.decrease_key((self.dist[v], v)						,   __A      )
																											_A									=       new_dist
																											_A									=       u

        # Show the shortest distances from src
												self.show_distances(__A      )

							def 					__A       (     self:      int						,   __A:      int      )			-> Dict:
												print(f"""Distance from node: {src}"""      )
												for u in range(self.num_nodes      ):
																	print(f"""Node {u} has distance: {self.dist[u]}"""      )



							def 					__A       (     self:      int						,   __A:      Union[str, Any]						,   __A:      Optional[Any]      )			-> List[str]:
												# To show the shortest path from src to dest
												# WARNING: Use it *after* calling dijkstra
												_A									=       []
												_A									=       0
												_A									=       dest
												# Backtracking from dest to src
												while self.par[temp] != -1:
																	path.append(__A      )
																	if temp != src:
																						for v, w in self.adjList[temp]:
																											if v == self.par[temp]:
																																cost += w
																																break
																	_A									=       self.par[temp]
												path.append(__A      )
												path.reverse()

												print(f"""----Path to reach {dest} from {src}----"""      )
												for u in path:
																	print(f"""{u}"""						,   end=''' '''      )
																	if u != dest:
																						print('''-> '''						,   end=''''''      )

												print('''\nTotal cost of path: '''						,   __A      )


if __name__ == "__main__":
				__A          = Graph(9)
				graph.add_edge(0, 1, 4)
				graph.add_edge(0, 7, 8)
				graph.add_edge(1, 2, 8)
				graph.add_edge(1, 7, 11)
				graph.add_edge(2, 3, 7)
				graph.add_edge(2, 8, 2)
				graph.add_edge(2, 5, 4)
				graph.add_edge(3, 4, 9)
				graph.add_edge(3, 5, 14)
				graph.add_edge(4, 5, 10)
				graph.add_edge(5, 6, 2)
				graph.add_edge(6, 7, 1)
				graph.add_edge(6, 8, 6)
				graph.add_edge(7, 8, 7)
				graph.show_graph()
				graph.dijkstra(0)
				graph.show_path(0, 4)

# OUTPUT
# 0 -> 1(4) -> 7(8)
# 1 -> 0(4) -> 2(8) -> 7(11)
# 7 -> 0(8) -> 1(11) -> 6(1) -> 8(7)
# 2 -> 1(8) -> 3(7) -> 8(2) -> 5(4)
# 3 -> 2(7) -> 4(9) -> 5(14)
# 8 -> 2(2) -> 6(6) -> 7(7)
# 5 -> 2(4) -> 3(14) -> 4(10) -> 6(2)
# 4 -> 3(9) -> 5(10)
# 6 -> 5(2) -> 7(1) -> 8(6)
# Distance from node: 0
# Node 0 has distance: 0
# Node 1 has distance: 4
# Node 2 has distance: 12
# Node 3 has distance: 19
# Node 4 has distance: 21
# Node 5 has distance: 11
# Node 6 has distance: 9
# Node 7 has distance: 8
# Node 8 has distance: 14
# ----Path to reach 4 from 0----
# 0 -> 7 -> 6 -> 5 -> 4
# Total cost of path:  21




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__SCREAMING_SNAKE_CASE						:    str     = logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE						:    Union[str, Any]     = {
    'nghuyong/ernie-1.0-base-zh': 'https://huggingface.co/nghuyong/ernie-1.0-base-zh/resolve/main/config.json',
    'nghuyong/ernie-2.0-base-en': 'https://huggingface.co/nghuyong/ernie-2.0-base-en/resolve/main/config.json',
    'nghuyong/ernie-2.0-large-en': 'https://huggingface.co/nghuyong/ernie-2.0-large-en/resolve/main/config.json',
    'nghuyong/ernie-3.0-base-zh': 'https://huggingface.co/nghuyong/ernie-3.0-base-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-medium-zh': 'https://huggingface.co/nghuyong/ernie-3.0-medium-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-mini-zh': 'https://huggingface.co/nghuyong/ernie-3.0-mini-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-micro-zh': 'https://huggingface.co/nghuyong/ernie-3.0-micro-zh/resolve/main/config.json',
    'nghuyong/ernie-3.0-nano-zh': 'https://huggingface.co/nghuyong/ernie-3.0-nano-zh/resolve/main/config.json',
    'nghuyong/ernie-gram-zh': 'https://huggingface.co/nghuyong/ernie-gram-zh/resolve/main/config.json',
    'nghuyong/ernie-health-zh': 'https://huggingface.co/nghuyong/ernie-health-zh/resolve/main/config.json',
}



class    lowercase_    (     __snake_case		):
							_lowerCamelCase						=		'ernie'



							def __init__(						self      ,				lowercase_=30_522      ,				lowercase_=768      ,				lowercase_=12      ,				lowercase_=12      ,				lowercase_=3_072      ,				lowercase_="gelu"      ,				lowercase_=0.1      ,				lowercase_=0.1      ,				lowercase_=512      ,				lowercase_=2      ,				lowercase_=3      ,				lowercase_=False      ,				lowercase_=0.02      ,				lowercase_=1e-12      ,				lowercase_=0      ,				lowercase_="absolute"      ,				lowercase_=True      ,				lowercase_=None      ,				**lowercase_      ,				):
													super().__init__(pad_token_id=lowercase_      ,				**lowercase_				)

													_snake_case						:     List[Any]				=    vocab_size
													_snake_case						:     Dict				=    hidden_size
													_snake_case						:     Any				=    num_hidden_layers
													_snake_case						:     List[str]				=    num_attention_heads
													_snake_case						:     int				=    hidden_act
													_snake_case						:     Tuple				=    intermediate_size
													_snake_case						:     Tuple				=    hidden_dropout_prob
													_snake_case						:     Optional[int]				=    attention_probs_dropout_prob
													_snake_case						:     Any				=    max_position_embeddings
													_snake_case						:     List[str]				=    type_vocab_size
													_snake_case						:     List[Any]				=    task_type_vocab_size
													_snake_case						:     Optional[int]				=    use_task_id
													_snake_case						:     Tuple				=    initializer_range
													_snake_case						:     Union[str, Any]				=    layer_norm_eps
													_snake_case						:     Optional[Any]				=    position_embedding_type
													_snake_case						:     int				=    use_cache
													_snake_case						:     Optional[Any]				=    classifier_dropout




class    lowercase_    (     __snake_case		):



							@property
							def        UpperCamelCase       (						self				):
													if self.task == "multiple-choice":
																			_snake_case						:     str				=    {0: "batch", 1: "choice", 2: "sequence"}
													else:
																			_snake_case						:     Optional[int]				=    {0: "batch", 1: "sequence"}
													return OrderedDict(
													    [
													        ("input_ids", dynamic_axis),
													        ("attention_mask", dynamic_axis),
													        ("token_type_ids", dynamic_axis),
													        ("task_type_ids", dynamic_axis),
													    ]				)