

from cva import destroyAllWindows, imread, imshow, waitKey


def       __UpperCamelCase     (lowerCAmelCase       :	List[str]  )  ->	List[Any]:
      A 			=					img.shape[0], img.shape[1]

      # converting each pixel's color to its negative
      for i in range(lowerCamelCase_  ):
            for j in range(lowerCamelCase_  ):
                  A 			=					[255, 255, 255] - img[i][j]

      return img


if __name__ == "__main__":
  # read original image
  _UpperCAmelCase     						=      imread("image_data/lena.jpg", 1)

  # convert to its negative
  _UpperCAmelCase     						=      convert_to_negative(img)

  # show result image
  imshow("negative of original image", img)
  waitKey(0)
  destroyAllWindows()





'''simple docstring'''

import torch
from torch import nn
from transformers import CLIPPreTrainedModel, CLIPVisionModel

from ...models.attention import BasicTransformerBlock
from ...utils import logging


snake_case									=    logging.get_logger(__name__)  # pylint: disable=invalid-name




class    lowerCAmelCase       (     UpperCamelCase_  ):


 def __init__(    self  : Union[str, Any]			,							a__  : int			,							a__  : List[Any]=768    ):
  '''simple docstring'''

  super().__init__(a__    )
  lowerCAmelCase__     :   int     		=	proj_size

  lowerCAmelCase__     :   str     		=	CLIPVisionModel(a__    )
  lowerCAmelCase__     :   int     		=	PaintByExampleMapper(a__    )
  lowerCAmelCase__     :   Optional[int]     		=	nn.LayerNorm(config.hidden_size    )
  lowerCAmelCase__     :   Optional[Any]     		=	nn.Linear(config.hidden_size			,							self.proj_size    )

  # uncondition for scaling
  lowerCAmelCase__     :   Dict     		=	nn.Parameter(torch.randn((1, 1, self.proj_size)    )    )


 def    _A	(    self  : Tuple			,							a__  : int			,							a__  : Optional[Any]=False    ):
  '''simple docstring'''

  lowerCAmelCase__     :   List[Any]     		=	self.model(pixel_values=a__    )
  lowerCAmelCase__     :   Any     		=	clip_output.pooler_output
  lowerCAmelCase__     :   Union[str, Any]     		=	self.mapper(latent_states[:, None]    )
  lowerCAmelCase__     :   List[Any]     		=	self.final_layer_norm(a__    )
  lowerCAmelCase__     :   Optional[int]     		=	self.proj_out(a__    )
  if return_uncond_vector:
   return latent_states, self.uncond_vector

  return latent_states




class    lowerCAmelCase       (     nn.Module  ):


 def __init__(    self  : Optional[Any]			,							a__  : Optional[Any]    ):
  '''simple docstring'''

  super().__init__()
  lowerCAmelCase__     :   Optional[Any]     		=	(config.num_hidden_layers + 1) // 5
  lowerCAmelCase__     :   str     		=	config.hidden_size
  lowerCAmelCase__     :   Dict     		=	1
  lowerCAmelCase__     :   int     		=	nn.ModuleList(
      [
          BasicTransformerBlock(a__			,							a__			,							a__			,							activation_fn="gelu"			,							attention_bias=a__    )
          for _ in range(a__    )
      ]    )


 def    _A	(    self  : int			,							a__  : Union[str, Any]    ):
  '''simple docstring'''

  for block in self.blocks:
   lowerCAmelCase__     :   List[Any]     		=	block(a__    )

  return hidden_states





