


"""simple docstring"""







from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


a__    :							List[str]            =					logging.get_logger(__name__)

a__    :							str            =					{
    '''shi-labs/nat-mini-in1k-224''': '''https://huggingface.co/shi-labs/nat-mini-in1k-224/resolve/main/config.json''',
    # See all Nat models at https://huggingface.co/models?filter=nat
}




class 			UpperCamelCase_     (			UpperCamelCase      ,  UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  List[str]    =      "nat"

	snake_case__    :  str    =      {
	    "num_attention_heads": "num_heads",
	    "num_hidden_layers": "num_layers",
	}




	def __init__(			self      :    Optional[Any]      ,      UpperCAmelCase__      :    str=4      ,      UpperCAmelCase__      :    str=3      ,      UpperCAmelCase__      :    int=6_4      ,      UpperCAmelCase__      :    Optional[int]=[3, 4, 6, 5]      ,      UpperCAmelCase__      :    Optional[int]=[2, 4, 8, 1_6]      ,      UpperCAmelCase__      :    str=7      ,      UpperCAmelCase__      :    List[str]=3.0      ,      UpperCAmelCase__      :    List[str]=True      ,      UpperCAmelCase__      :    List[Any]=0.0      ,      UpperCAmelCase__      :    Dict=0.0      ,      UpperCAmelCase__      :    Union[str, Any]=0.1      ,      UpperCAmelCase__      :    Optional[int]="gelu"      ,      UpperCAmelCase__      :    Union[str, Any]=0.02      ,      UpperCAmelCase__      :    Optional[int]=1E-5      ,      UpperCAmelCase__      :    Union[str, Any]=0.0      ,      UpperCAmelCase__      :    str=None      ,      UpperCAmelCase__      :    Tuple=None      ,      **UpperCAmelCase__      :    Union[str, Any]      ,      )	->     List[str]:
						super().__init__(**UpperCAmelCase__       )

						__SCREAMING_SNAKE_CASE						       =    patch_size
						__SCREAMING_SNAKE_CASE						       =    num_channels
						__SCREAMING_SNAKE_CASE						       =    embed_dim
						__SCREAMING_SNAKE_CASE						       =    depths
						__SCREAMING_SNAKE_CASE						       =    len(UpperCAmelCase__       )
						__SCREAMING_SNAKE_CASE						       =    num_heads
						__SCREAMING_SNAKE_CASE						       =    kernel_size
						__SCREAMING_SNAKE_CASE						       =    mlp_ratio
						__SCREAMING_SNAKE_CASE						       =    qkv_bias
						__SCREAMING_SNAKE_CASE						       =    hidden_dropout_prob
						__SCREAMING_SNAKE_CASE						       =    attention_probs_dropout_prob
						__SCREAMING_SNAKE_CASE						       =    drop_path_rate
						__SCREAMING_SNAKE_CASE						       =    hidden_act
						__SCREAMING_SNAKE_CASE						       =    layer_norm_eps
						__SCREAMING_SNAKE_CASE						       =    initializer_range
						# we set the hidden_size attribute in order to make Nat work with VisionEncoderDecoderModel
						# this indicates the channel dimension after the last stage of the model
						__SCREAMING_SNAKE_CASE						       =    int(embed_dim * 2 ** (len(UpperCAmelCase__       ) - 1)       )
						__SCREAMING_SNAKE_CASE						       =    layer_scale_init_value
						__SCREAMING_SNAKE_CASE						       =    ["stem"] + [F"""stage{idx}""" for idx in range(1      ,      len(UpperCAmelCase__       ) + 1       )]
						__SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE						       =    get_aligned_output_features_output_indices(
						    out_features=UpperCAmelCase__      ,      out_indices=UpperCAmelCase__      ,      stage_names=self.stage_names       )




"""simple docstring"""







from __future__ import annotations




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					print(f"""Vertex\tShortest Distance from vertex {src}"""       )
					for i, d in enumerate(lowerCAmelCase_       ):
										print(f"""{i}\t\t{d}"""       )




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					for j in range(lowerCAmelCase_       ):
										__SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE						       =    (graph[j][k] for k in ["src", "dst", "weight"])
										if distance[u] != float("inf"       ) and distance[u] + w < distance[v]:
															return True
					return False




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    [float("inf"       )] * vertex_count
					__SCREAMING_SNAKE_CASE						       =    0.0

					for _ in range(vertex_count - 1       ):
										for j in range(lowerCAmelCase_       ):
															__SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE       ,  __SCREAMING_SNAKE_CASE						       =    (graph[j][k] for k in ["src", "dst", "weight"])

															if distance[u] != float("inf"       ) and distance[u] + w < distance[v]:
																				__SCREAMING_SNAKE_CASE						       =    distance[u] + w

					__SCREAMING_SNAKE_CASE						       =    check_negative_cycle(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_       )
					if negative_cycle_exists:
										raise Exception("Negative cycle found"       )

					return distance


if __name__ == "__main__":
		import doctest

		doctest.testmod()

		a__    :							Union[str, Any]            =					int(input('''Enter number of vertices: ''').strip())
		a__    :							Any            =					int(input('''Enter number of edges: ''').strip())

		a__    :							list[dict[str, int]]            =					[{} for _ in range(E)]

		for i in range(E):
				print('''Edge ''', i + 1)
				a__      ,					a__      ,					a__    :							str            =					(
				    int(x)
				    for x in input('''Enter source, destination, weight: ''').strip().split(''' ''')
				)
				a__    :							str            =					{'''src''': src, '''dst''': dest, '''weight''': weight}

		a__    :							str            =					int(input('''\nEnter shortest path source:''').strip())
		a__    :							List[Any]            =					bellman_ford(graph, V, E, source)
		print_distance(shortest_distance, 0)
