


'''simple docstring'''


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
UpperCAmelCase_		:   str							   =		0B10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_11_10_11_00_01_10_01_11_10
# bin(x)[2:] gives bits of x as str, use int to convert them to 0/1
UpperCAmelCase_		:   Tuple							   =		[int(bit) for bit in bin(WATERMARK_MESSAGE)[2:]]





class     lowercase__  :





							'''simple docstring'''


							def __init__(    self  ):
											_SCREAMING_SNAKE_CASE :       Any     		=      WATERMARK_BITS
											_SCREAMING_SNAKE_CASE :       Dict     		=      WatermarkEncoder()

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






							def UpperCAmelCase_	(    self    ,					__snake_case  ):
											# can't encode images that are smaller than 256
											if images.shape[-1] < 256:
															return images

											_SCREAMING_SNAKE_CASE :       Optional[Any]     		=      (255 * (images / 2 + 0.5)).cpu().permute(0    ,					2    ,					3    ,					1  ).float().numpy()

											_SCREAMING_SNAKE_CASE :       List[Any]     		=      [self.encoder.encode(__snake_case    ,					"""dwtDct"""  ) for image in images]

											_SCREAMING_SNAKE_CASE :       str     		=      torch.from_numpy(np.array(__snake_case  )  ).permute(0    ,					3    ,					1    ,					2  )

											_SCREAMING_SNAKE_CASE :       List[Any]     		=      torch.clamp(2 * (images / 255 - 0.5)    ,					min=-1.0    ,					max=1.0  )
											return images








'''simple docstring'''


def 			snake_case_   (  SCREAMING_SNAKE_CASE__							,      SCREAMING_SNAKE_CASE__     ):







				"""simple docstring"""





				return int((input_a, input_a).count(0     ) != 0     )







def 			snake_case_   (  ):







				"""simple docstring"""





				assert nand_gate(0							,      0     ) == 1
				assert nand_gate(0							,      1     ) == 1
				assert nand_gate(1							,      0     ) == 1
				assert nand_gate(1							,      1     ) == 0


if __name__ == "__main__":
				print(nand_gate(0, 0))
				print(nand_gate(0, 1))
				print(nand_gate(1, 0))
				print(nand_gate(1, 1))




