





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

from ...utils import logging


_snake_case           =			logging.get_logger(__name__)





class  lowerCAmelCase							(       lowercase_ ):
  __lowerCamelCase		=      CLIPConfig

  __lowerCamelCase		=      ['CLIPEncoderLayer']







  def __init__(      self  :Dict   ,							_lowercase  :CLIPConfig ):






     '''simple docstring'''





     super().__init__(_lowercase )

     lowercase__			       =  CLIPVisionModelWithProjection(config.vision_config )

     lowercase__			       =  nn.Linear(config.vision_config.projection_dim   ,							1 )
     lowercase__			       =  nn.Linear(config.vision_config.projection_dim   ,							1 )







  @torch.no_grad()
  def   UpperCAmelCase					(      self  :Tuple   ,							_lowercase  :Optional[int]   ,							_lowercase  :Optional[Any]   ,							_lowercase  :Optional[Any]=0.5   ,							_lowercase  :int=0.5 ):






     '''simple docstring'''





     lowercase__			       =  self.vision_model(_lowercase )[0]

     lowercase__			       =  self.p_head(_lowercase )
     lowercase__			       =  nsfw_detected.flatten()
     lowercase__			       =  nsfw_detected > p_threshold
     lowercase__			       =  nsfw_detected.tolist()

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

     lowercase__			       =  self.w_head(_lowercase )
     lowercase__			       =  watermark_detected.flatten()
     lowercase__			       =  watermark_detected > w_threshold
     lowercase__			       =  watermark_detected.tolist()

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

     return images, nsfw_detected, watermark_detected













from __future__ import annotations


def _A       (   __magic_name__  , __magic_name__	):
   lowercase__			       =  []
   create_all_state(1  , __magic_name__  , __magic_name__  , []  , __magic_name__	)
   return result


def _A       (   __magic_name__  , __magic_name__  , __magic_name__  , __magic_name__  , __magic_name__  , ):
   if level == 0:
      total_list.append(current_list[:]	)
      return

   for i in range(__magic_name__  , total_number - level + 2	):
      current_list.append(__magic_name__	)
      create_all_state(i + 1  , __magic_name__  , level - 1  , __magic_name__  , __magic_name__	)
      current_list.pop()


def _A       (   __magic_name__	):
   for i in total_list:
      print(*__magic_name__	)


if __name__ == "__main__":
  _snake_case           =			4
  _snake_case           =			2
  _snake_case           =			generate_all_combinations(n, k)
  print_all_state(total_list)






