





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

from ...utils import logging


lowercase :			int     		=    logging.get_logger(__name__)





class 					A__       (				a__      ):




   """simple docstring"""



   __A  :							str			    =    CLIPConfig

   __A  :							Optional[int]			    =    ['''CLIPEncoderLayer''']

   def __init__(   self   ,    lowercase)     ->		Union[str, Any]:







          '''simple docstring'''

          super().__init__(__a)

          a__		:      List[Any]					=							CLIPVisionModelWithProjection(config.vision_config)

          a__		:      int					=							nn.Linear(config.vision_config.projection_dim   ,    1)
          a__		:      int					=							nn.Linear(config.vision_config.projection_dim   ,    1)

   @torch.no_grad()
   def 				__lowercase						(   self   ,    lowercase   ,    lowercase   ,    lowercase=0.5   ,    lowercase=0.5)     ->		Union[str, Any]:







          '''simple docstring'''

          a__		:      Dict					=							self.vision_model(__a)[0]

          a__		:      str					=							self.p_head(__a)
          a__		:      Union[str, Any]					=							nsfw_detected.flatten()
          a__		:      Tuple					=							nsfw_detected > p_threshold
          a__		:      Dict					=							nsfw_detected.tolist()

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

          a__		:      Union[str, Any]					=							self.w_head(__a)
          a__		:      List[str]					=							watermark_detected.flatten()
          a__		:      Dict					=							watermark_detected > w_threshold
          a__		:      Optional[int]					=							watermark_detected.tolist()

          if any(__a):
                 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(__a):
                 if watermark_detected_:
                        a__		:      Tuple					=							np.zeros(images[idx].shape)

          return images, nsfw_detected, watermark_detected






def    __lowerCamelCase   (      A__						: int						,						A__						: int					)     ->    int:
   return int((input_a, input_a).count(0					) == 0					)


def    __lowerCamelCase   (      )     ->    None:
   assert and_gate(0						,						0					) == 0
   assert and_gate(0						,						1					) == 0
   assert and_gate(1						,						0					) == 0
   assert and_gate(1						,						1					) == 1


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





