






'''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


A:      Any  				=				False






class 							__magic_name__     (	unittest.TestCase				):







 """simple docstring"""



 pass






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







 """simple docstring"""



 def        lowerCamelCase__		(							self       )						->  List[Any]:
       lowercase_      :   Optional[int]        =			VersatileDiffusionImageVariationPipeline.from_pretrained('shi-labs/versatile-diffusion'       )
       pipe.to(__UpperCamelCase       )
       pipe.set_progress_bar_config(disable=__UpperCamelCase       )

       lowercase_      :   Any        =			load_image(
           'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'       )
       lowercase_      :   Optional[int]        =			torch.manual_seed(0       )
       lowercase_      :   Any        =			pipe(
           image=__UpperCamelCase  ,      generator=__UpperCamelCase  ,      guidance_scale=7.5  ,      num_inference_steps=50  ,      output_type='numpy'  ,      ).images

       lowercase_      :   Union[str, Any]        =			image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       lowercase_      :   Union[str, 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 collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


A:      Dict  				=				logging.get_logger(__name__)

A:      Optional[Any]  				=				{
    "google/vit-base-patch16-224": "https://huggingface.co/vit-base-patch16-224/resolve/main/config.json",
    # See all ViT models at https://huggingface.co/models?filter=vit
}






class 							__magic_name__     (	UpperCAmelCase_				):







	"""simple docstring"""



	SCREAMING_SNAKE_CASE_					:      Optional[Any]        =  'vit'
	def __init__(							self  ,      _lowercase=768  ,      _lowercase=12  ,      _lowercase=12  ,      _lowercase=3072  ,      _lowercase="gelu"  ,      _lowercase=0.0  ,      _lowercase=0.0  ,      _lowercase=0.02  ,      _lowercase=1E-1_2  ,      _lowercase=224  ,      _lowercase=16  ,      _lowercase=3  ,      _lowercase=True  ,      _lowercase=16  ,      **_lowercase  ,      )						->  List[str]:
							super().__init__(**_lowercase       )

							lowercase_      :   Optional[int]        =			hidden_size
							lowercase_      :   str        =			num_hidden_layers
							lowercase_      :   str        =			num_attention_heads
							lowercase_      :   int        =			intermediate_size
							lowercase_      :   List[Any]        =			hidden_act
							lowercase_      :   Any        =			hidden_dropout_prob
							lowercase_      :   List[str]        =			attention_probs_dropout_prob
							lowercase_      :   str        =			initializer_range
							lowercase_      :   List[str]        =			layer_norm_eps
							lowercase_      :   Any        =			image_size
							lowercase_      :   Tuple        =			patch_size
							lowercase_      :   Optional[Any]        =			num_channels
							lowercase_      :   str        =			qkv_bias
							lowercase_      :   List[str]        =			encoder_stride






class 							__magic_name__     (	UpperCAmelCase_				):







	"""simple docstring"""



	SCREAMING_SNAKE_CASE_					:      Any        =  version.parse('1.11'				)
	@property
	def        lowerCamelCase__		(							self       )						->  Mapping[str, Mapping[int, str]]:
							return OrderedDict(
							    [
							        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
							    ]       )







	@property
	def        lowerCamelCase__		(							self       )						->  float:
							return 1E-4
