



"""simple docstring"""






import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


__UpperCAmelCase      =    False






class 	__snake_case	(     unittest.TestCase):
  pass






@slow
@require_torch_gpu
class 	__snake_case	(     unittest.TestCase):




  def 						SCREAMING_SNAKE_CASE    (			self					:						List[str]		):






         """simple docstring"""






         _lowerCamelCase						:    int         =			VersatileDiffusionImageVariationPipeline.from_pretrained('''shi-labs/versatile-diffusion'''		)
         pipe.to(UpperCAmelCase_		)
         pipe.set_progress_bar_config(disable=UpperCAmelCase_		)

         _lowerCamelCase						:    str         =			load_image(
             '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''		)
         _lowerCamelCase						:    Optional[Any]         =			torch.manual_seed(0		)
         _lowerCamelCase						:    List[Any]         =			pipe(
             image=UpperCAmelCase_						, generator=UpperCAmelCase_						, guidance_scale=7.5						, num_inference_steps=5_0						, output_type='''numpy'''						, ).images

         _lowerCamelCase						:    List[str]         =			image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

         assert image.shape == (1, 5_1_2, 5_1_2, 3)
         _lowerCamelCase						:    Any         =			np.array([0.04_41, 0.04_69, 0.05_07, 0.05_75, 0.06_32, 0.06_50, 0.08_65, 0.09_09, 0.09_45]		)

         assert np.abs(image_slice.flatten() - expected_slice		).max() < 1E-2







"""simple docstring"""






from torch import nn






class 	__snake_case	(     nn.Module):




  def __init__(			self					:						Optional[Any]						, __lowerCAmelCase					:						Dict						, __lowerCAmelCase					:						str		):






         """simple docstring"""






         super().__init__()
         _lowerCamelCase						:    List[str]         =			class_size
         _lowerCamelCase						:    List[str]         =			embed_size
         # self.mlp1 = nn.Linear(embed_size, embed_size)
         # self.mlp2 = (nn.Linear(embed_size, class_size))
         _lowerCamelCase						:    Optional[int]         =			nn.Linear(__lowerCAmelCase						, __lowerCAmelCase		)




  def 						SCREAMING_SNAKE_CASE    (			self					:						List[Any]						, __lowerCAmelCase					:						Tuple		):






         """simple docstring"""






         _lowerCamelCase						:    Optional[Any]         =			self.mlp(__lowerCAmelCase		)
         return logits


