






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

from ...utils import logging


lowerCamelCase_       			=   logging.get_logger(__name__)







class     UpperCamelCase_ (__A  ):
	__magic_name__			   =       CLIPConfig

	__magic_name__			   =       ['''CLIPEncoderLayer''']





	def __init__(   self      :				Optional[int]			,			lowerCAmelCase_      :				CLIPConfig		)		->    str:
				super().__init__(lowerCAmelCase_		)

				UpperCAmelCase_  :				str      =      CLIPVisionModelWithProjection(config.vision_config		)

				UpperCAmelCase_  :				Any      =      nn.Linear(config.vision_config.projection_dim			,			1		)
				UpperCAmelCase_  :				List[Any]      =      nn.Linear(config.vision_config.projection_dim			,			1		)





	@torch.no_grad()
	def   _SCREAMING_SNAKE_CASE   (   self      :				str			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Tuple			,			lowerCAmelCase_      :				Optional[int]=0.5			,			lowerCAmelCase_      :				List[Any]=0.5		)		->    Any:
				UpperCAmelCase_  :				Union[str, Any]      =      self.vision_model(lowerCAmelCase_		)[0]

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

				if any(lowerCAmelCase_		):
							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(lowerCAmelCase_		):
							if nsfw_detected_:
										UpperCAmelCase_  :				int      =      np.zeros(images[idx].shape		)

				UpperCAmelCase_  :				Union[str, Any]      =      self.w_head(lowerCAmelCase_		)
				UpperCAmelCase_  :				List[Any]      =      watermark_detected.flatten()
				UpperCAmelCase_  :				str      =      watermark_detected > w_threshold
				UpperCAmelCase_  :				Any      =      watermark_detected.tolist()

				if any(lowerCAmelCase_		):
							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(lowerCAmelCase_		):
							if watermark_detected_:
										UpperCAmelCase_  :				Optional[int]      =      np.zeros(images[idx].shape		)

				return images, nsfw_detected, watermark_detected











"""simple docstring"""
from __future__ import annotations

import math

def        snake_case   (     A__		):

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5			,int(math.sqrt(A__		) + 1		)			,6		):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True


lowerCamelCase_       			=   [num for num in range(3, 10_0001, 2) if not is_prime(num)]

def        snake_case   (     A__		):
			if not isinstance(A__			,A__		):
						raise ValueError("n must be an integer"		)
			if n <= 0:
						raise ValueError("n must be >= 0"		)

			UpperCAmelCase_  :				List[str]      =      []
			for num in range(len(A__		)		):
						UpperCAmelCase_  :				Dict      =      0
						while 2 * i * i <= odd_composites[num]:
									UpperCAmelCase_  :				List[str]      =      odd_composites[num] - 2 * i * i
									if is_prime(A__		):
												break
									i += 1
						else:
									list_nums.append(odd_composites[num]		)
									if len(A__		) == n:
												return list_nums

			return []

def        snake_case   (     ):
			return compute_nums(1		)[0]


if __name__ == "__main__":
			print(f'{solution() = }')



