






'''simple docstring'''







import torch
from torch import nn

from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin

class _lowercase	(				_lowercase				,      _lowercase		):




							@register_to_config
							def __init__(							self:				Optional[Any]			,							*,
							    UpperCamelCase__:				int = 4			,							UpperCamelCase__:				int = 768			,							UpperCamelCase__:				int			,							UpperCamelCase__:				int			,							):
														super().__init__()

														lowerCamelCase__					:	Dict         =       nn.Parameter(torch.zeros(UpperCamelCase__     )     )

														# parameters for additional clip time embeddings
														lowerCamelCase__					:	int         =       nn.Linear(UpperCamelCase__			,							UpperCamelCase__     )
														lowerCamelCase__					:	Tuple         =       nn.Linear(UpperCamelCase__			,							UpperCamelCase__     )

														# parameters for encoder hidden states
														lowerCamelCase__					:	Optional[int]         =       clip_extra_context_tokens
														lowerCamelCase__					:	Optional[int]         =       nn.Linear(
														    UpperCamelCase__			,							self.clip_extra_context_tokens * cross_attention_dim     )
														lowerCamelCase__					:	List[Any]         =       nn.Linear(UpperCamelCase__			,							UpperCamelCase__     )
														lowerCamelCase__					:	List[Any]         =       nn.LayerNorm(UpperCamelCase__     )




							def 		lowerCamelCase_				(							self:				int			,							*, UpperCamelCase__:				Union[str, Any]			,							UpperCamelCase__:				str			,							UpperCamelCase__:				int			,							UpperCamelCase__:				Union[str, Any]     ):
														if do_classifier_free_guidance:
																					# Add the classifier free guidance embeddings to the image embeddings
																					lowerCamelCase__					:	Dict         =       image_embeddings.shape[0]
																					lowerCamelCase__					:	Optional[int]         =       self.learned_classifier_free_guidance_embeddings.unsqueeze(0     )
																					lowerCamelCase__					:	List[str]         =       classifier_free_guidance_embeddings.expand(
																					    UpperCamelCase__			,							-1     )
																					lowerCamelCase__					:	str         =       torch.cat([classifier_free_guidance_embeddings, image_embeddings]			,							dim=0     )

														# The image embeddings batch size and the text embeddings batch size are equal
														assert image_embeddings.shape[0] == prompt_embeds.shape[0]

														lowerCamelCase__					:	Dict         =       prompt_embeds.shape[0]

														# "Specifically, we modify the architecture described in Nichol et al. (2021) by projecting and
														# adding CLIP embeddings to the existing timestep embedding, ...
														lowerCamelCase__					:	List[Any]         =       self.embedding_proj(UpperCamelCase__     )
														lowerCamelCase__					:	List[str]         =       self.clip_image_embeddings_project_to_time_embeddings(UpperCamelCase__     )
														lowerCamelCase__					:	Dict         =       time_projected_image_embeddings + time_projected_prompt_embeds

														# ... and by projecting CLIP embeddings into four
														# extra tokens of context that are concatenated to the sequence of outputs from the GLIDE text encoder"
														lowerCamelCase__					:	List[str]         =       self.clip_extra_context_tokens_proj(UpperCamelCase__     )
														lowerCamelCase__					:	Optional[int]         =       clip_extra_context_tokens.reshape(UpperCamelCase__			,							-1			,							self.clip_extra_context_tokens     )
														lowerCamelCase__					:	int         =       clip_extra_context_tokens.permute(0			,							2			,							1     )

														lowerCamelCase__					:	Optional[int]         =       self.encoder_hidden_states_proj(UpperCamelCase__     )
														lowerCamelCase__					:	str         =       self.text_encoder_hidden_states_norm(UpperCamelCase__     )
														lowerCamelCase__					:	Optional[int]         =       torch.cat([clip_extra_context_tokens, text_encoder_hidden_states]			,							dim=1     )

														return text_encoder_hidden_states, additive_clip_time_embeddings






"""simple docstring"""







def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      List[Any]:
		print('''\nThe shortest path matrix using Floyd Warshall algorithm\n'''	)
		for i in range(__lowerCamelCase	):
				for j in range(__lowerCamelCase	):
						if dist[i][j] != float('''inf'''	):
								print(int(dist[i][j]	)						,     end='''\t'''	)
						else:
								print('''INF'''						,     end='''\t'''	)
				print()



def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Optional[Any]:
		lowercase__   :    str				=			[[float('''inf'''	) for _ in range(__lowerCamelCase	)] for _ in range(__lowerCamelCase	)]

		for i in range(__lowerCamelCase	):
				for j in range(__lowerCamelCase	):
						lowercase__   :    List[str]				=			graph[i][j]

						# check vertex k against all other vertices (i, j)
		for k in range(__lowerCamelCase	):
				# looping through rows of graph array
				for i in range(__lowerCamelCase	):
						# looping through columns of graph array
						for j in range(__lowerCamelCase	):
								if (
								    dist[i][k] != float('''inf'''	)
								    and dist[k][j] != float('''inf'''	)
								    and dist[i][k] + dist[k][j] < dist[i][j]
								):
										lowercase__   :    str				=			dist[i][k] + dist[k][j]

		_print_dist(__lowerCamelCase						,     __lowerCamelCase	)
		return dist, v


if __name__ == "__main__":
							lowerCAmelCase_   						=   int(input('Enter number of vertices: '))
							lowerCAmelCase_   						=   int(input('Enter number of edges: '))

							lowerCAmelCase_   						=   [[float('inf') for i in range(v)] for j in range(v)]

							for i in range(v):
														lowerCAmelCase_   						=   0.0

														# src and dst are indices that must be within the array size graph[e][v]
														# failure to follow this will result in an error
							for i in range(e):
														print('\nEdge ', i + 1)
														lowerCAmelCase_   						=   int(input('Enter source:'))
														lowerCAmelCase_   						=   int(input('Enter destination:'))
														lowerCAmelCase_   						=   float(input('Enter weight:'))
														lowerCAmelCase_   						=   weight

							floyd_warshall(graph, v)

							# Example Input
							# Enter number of vertices: 3
							# Enter number of edges: 2

							# # generated graph from vertex and edge inputs
							# [[inf, inf, inf], [inf, inf, inf], [inf, inf, inf]]
							# [[0.0, inf, inf], [inf, 0.0, inf], [inf, inf, 0.0]]

							# specify source, destination and weight for edge #1
							# Edge  1
							# Enter source:1
							# Enter destination:2
							# Enter weight:2

							# specify source, destination and weight for edge #2
							# Edge  2
							# Enter source:2
							# Enter destination:1
							# Enter weight:1

							# # Expected Output from the vertice, edge and src, dst, weight inputs!!
							# 0		INF	INF
							# INF	0	2
							# INF	1	0
