
import numpy as np
import torch
from imwatermark import WatermarkEncoder


# Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66
_A     =  0b1011_0011_1110_1100_1001_0000_0111_1011_1011_0001_1001_1110
# bin(x)[2:] gives bits of x as str, use int to convert them to 0/1
_A     =  [int(bit) for bit in bin(WATERMARK_MESSAGE)[2:]]





class 			_lowerCAmelCase      :




				def __init__(      self  )       ->   Optional[Any]:
							lowerCAmelCase_      			=			WATERMARK_BITS
							lowerCAmelCase_      			=			WatermarkEncoder()

							self.encoder.set_watermark("bits"       ,       self.watermark  )




				def   __a		(      self       ,       _UpperCamelCase  )       ->   Dict:





							if images.shape[-1] < 256:
										return images

							lowerCAmelCase_      			=			(255 * (images / 2 + 0.5)).cpu().permute(0       ,       2       ,       3       ,       1  ).float().numpy()

							lowerCAmelCase_      			=			[self.encoder.encode(_UpperCamelCase       ,       "dwtDct"  ) for image in images]

							lowerCAmelCase_      			=			torch.from_numpy(np.array(_UpperCamelCase  )  ).permute(0       ,       3       ,       1       ,       2  )

							lowerCAmelCase_      			=			torch.clamp(2 * (images / 255 - 0.5)       ,       min=-1.0       ,       max=1.0  )
							return images





import math





class 			_lowerCAmelCase      :




				def __init__(      self       ,       _UpperCamelCase=0  )       ->   Tuple:  # a graph with Node 0,1,...,N-1
							lowerCAmelCase_      			=			n
							lowerCAmelCase_      			=			[
							    [math.inf for j in range(0       ,       _UpperCamelCase  )] for i in range(0       ,       _UpperCamelCase  )
							]  # adjacency matrix for weight
							lowerCAmelCase_      			=			[
							    [math.inf for j in range(0       ,       _UpperCamelCase  )] for i in range(0       ,       _UpperCamelCase  )
							]  # dp[i][j] stores minimum distance from i to j




				def   __a		(      self       ,       _UpperCamelCase       ,       _UpperCamelCase       ,       _UpperCamelCase  )       ->   List[Any]:
							lowerCAmelCase_      			=			w




				def   __a		(      self  )       ->   List[str]:
							for k in range(0       ,       self.n  ):
										for i in range(0       ,       self.n  ):
													for j in range(0       ,       self.n  ):
																lowerCAmelCase_      			=			min(self.dp[i][j]       ,       self.dp[i][k] + self.dp[k][j]  )




				def   __a		(      self       ,       _UpperCamelCase       ,       _UpperCamelCase  )       ->   Dict:
							return self.dp[u][v]


if __name__ == "__main__":
			_A     =  Graph(5)
			graph.add_edge(0, 2, 9)
			graph.add_edge(0, 4, 10)
			graph.add_edge(1, 3, 5)
			graph.add_edge(2, 3, 7)
			graph.add_edge(3, 0, 10)
			graph.add_edge(3, 1, 2)
			graph.add_edge(3, 2, 1)
			graph.add_edge(3, 4, 6)
			graph.add_edge(4, 1, 3)
			graph.add_edge(4, 2, 4)
			graph.add_edge(4, 3, 9)
			graph.floyd_warshall()
			graph.show_min(1, 4)
			graph.show_min(0, 3)



