






'''simple docstring'''



import math


def 				lowercase_					(     )							->   None:



 """simple docstring"""




 lowercase       : Union[str, Any]						=input('''Enter message: '''      )
 lowercase       : List[Any]						=int(input(F'Enter key [2-{len(__A      ) - 1}]: '      )      )
 lowercase       : int						=input('''Encryption/Decryption [e/d]: '''      )

 if mode.lower().startswith('''e'''      ):
  lowercase       : Union[str, Any]						=encrypt_message(__A       ,   __A      )
 elif mode.lower().startswith('''d'''      ):
  lowercase       : Dict						=decrypt_message(__A       ,   __A      )

 # Append pipe symbol (vertical bar) to identify spaces at the end.
 print(F'Output:\n{text + "|"}'      )


def 				lowercase_					(     __A			:							int       ,   __A			:							str      )							->   str:



 """simple docstring"""




 lowercase       : Union[str, Any]						=[''''''] * key
 for col in range(__A      ):
  lowercase       : Optional[Any]						=col
  while pointer < len(__A      ):
   cipher_text[col] += message[pointer]
   pointer += key
 return "".join(__A      )


def 				lowercase_					(     __A			:							int       ,   __A			:							str      )							->   str:



 """simple docstring"""




 lowercase       : Tuple						=math.ceil(len(__A      ) / key      )
 lowercase       : Union[str, Any]						=key
 lowercase       : Optional[int]						=(num_cols * num_rows) - len(__A      )
 lowercase       : List[Any]						=[''''''] * num_cols
 lowercase       : Dict						=0
 lowercase       : List[str]						=0

 for symbol in message:
  plain_text[col] += symbol
  col += 1

  if (
      (col == num_cols)
      or (col == num_cols - 1)
      and (row >= num_rows - num_shaded_boxes)
  ):
   lowercase       : Optional[int]						=0
   row += 1

 return "".join(__A      )


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      main()








import numpy as np
import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel

from ...utils import logging


a      :  Union[str, Any]			     =			logging.get_logger(__name__)







class 				_a				(   _lowerCAmelCase					):
			A      		=	CLIPConfig

			A      		=	['''CLIPEncoderLayer''']

			def __init__(self,   SCREAMING_SNAKE_CASE_					)       ->   Optional[Any]:
						super().__init__(SCREAMING_SNAKE_CASE_					)

						UpperCAmelCase_:		Tuple							      =     CLIPVisionModelWithProjection(config.vision_config					)

						UpperCAmelCase_:		Tuple							      =     nn.Linear(config.vision_config.projection_dim,   1					)
						UpperCAmelCase_:		Tuple							      =     nn.Linear(config.vision_config.projection_dim,   1					)

			@torch.no_grad()
			def      __snake_case       (self,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_,   SCREAMING_SNAKE_CASE_=0.5,   SCREAMING_SNAKE_CASE_=0.5					)       ->   Tuple:
						UpperCAmelCase_:		Optional[Any]							      =     self.vision_model(SCREAMING_SNAKE_CASE_					)[0]

						UpperCAmelCase_:		List[str]							      =     self.p_head(SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Any							      =     nsfw_detected.flatten()
						UpperCAmelCase_:		List[Any]							      =     nsfw_detected > p_threshold
						UpperCAmelCase_:		Any							      =     nsfw_detected.tolist()

						if any(SCREAMING_SNAKE_CASE_					):
									logger.warning(
									    """Potential NSFW content was detected in one or more images. A black image will be returned instead."""
									    """ Try again with a different prompt and/or seed."""					)

						for idx, nsfw_detected_ in enumerate(SCREAMING_SNAKE_CASE_					):
									if nsfw_detected_:
												UpperCAmelCase_:		Tuple							      =     np.zeros(images[idx].shape					)

						UpperCAmelCase_:		str							      =     self.w_head(SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		List[Any]							      =     watermark_detected.flatten()
						UpperCAmelCase_:		Tuple							      =     watermark_detected > w_threshold
						UpperCAmelCase_:		int							      =     watermark_detected.tolist()

						if any(SCREAMING_SNAKE_CASE_					):
									logger.warning(
									    """Potential watermarked content was detected in one or more images. A black image will be returned instead."""
									    """ Try again with a different prompt and/or seed."""					)

						for idx, watermark_detected_ in enumerate(SCREAMING_SNAKE_CASE_					):
									if watermark_detected_:
												UpperCAmelCase_:		Any							      =     np.zeros(images[idx].shape					)

						return images, nsfw_detected, watermark_detected






