

import gc
import unittest

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()

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







	def 	_SCREAMING_SNAKE_CASE							(   self: List[Any]      ):

						'''simple docstring'''





						super().tearDown()
						gc.collect()
						torch.cuda.empty_cache()







	def 	_SCREAMING_SNAKE_CASE							(   self: Any      ):

						'''simple docstring'''





						__magic_name__							=    StableDiffusionKDiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4'      )
						__magic_name__							=    sd_pipe.to(__UpperCamelCase      )
						sd_pipe.set_progress_bar_config(disable=__UpperCamelCase      )

						sd_pipe.set_scheduler('sample_euler'      )

						__magic_name__							=    'A painting of a squirrel eating a burger'
						__magic_name__							=    torch.manual_seed(0      )
						__magic_name__							=    sd_pipe([prompt]  , generator=__UpperCamelCase  , guidance_scale=9.0  , num_inference_steps=20  , output_type='np'      )

						__magic_name__							=    output.images

						__magic_name__							=    image[0, -3:, -3:, -1]

						assert image.shape == (1, 5_12, 5_12, 3)
						__magic_name__							=    np.array([0.0447, 0.0492, 0.0468, 0.0408, 0.0383, 0.0408, 0.0354, 0.0380, 0.0339]      )

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







	def 	_SCREAMING_SNAKE_CASE							(   self: List[Any]      ):

						'''simple docstring'''





						__magic_name__							=    StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'      )
						__magic_name__							=    sd_pipe.to(__UpperCamelCase      )
						sd_pipe.set_progress_bar_config(disable=__UpperCamelCase      )

						sd_pipe.set_scheduler('sample_euler'      )

						__magic_name__							=    'A painting of a squirrel eating a burger'
						__magic_name__							=    torch.manual_seed(0      )
						__magic_name__							=    sd_pipe([prompt]  , generator=__UpperCamelCase  , guidance_scale=9.0  , num_inference_steps=20  , output_type='np'      )

						__magic_name__							=    output.images

						__magic_name__							=    image[0, -3:, -3:, -1]

						assert image.shape == (1, 5_12, 5_12, 3)
						__magic_name__							=    np.array([0.1237, 0.1320, 0.1438, 0.1359, 0.1390, 0.1132, 0.1277, 0.1175, 0.1112]      )

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







	def 	_SCREAMING_SNAKE_CASE							(   self: str      ):

						'''simple docstring'''





						__magic_name__							=    StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'      )
						__magic_name__							=    sd_pipe.to(__UpperCamelCase      )
						sd_pipe.set_progress_bar_config(disable=__UpperCamelCase      )

						sd_pipe.set_scheduler('sample_dpmpp_2m'      )

						__magic_name__							=    'A painting of a squirrel eating a burger'
						__magic_name__							=    torch.manual_seed(0      )
						__magic_name__							=    sd_pipe(
						    [prompt]  , generator=__UpperCamelCase  , guidance_scale=7.5  , num_inference_steps=15  , output_type='np'  , use_karras_sigmas=__UpperCamelCase  , )

						__magic_name__							=    output.images

						__magic_name__							=    image[0, -3:, -3:, -1]

						assert image.shape == (1, 5_12, 5_12, 3)
						__magic_name__							=    np.array(
						    [0.11381689, 0.12112921, 0.1389457, 0.12549606, 0.1244964, 0.10831517, 0.11562866, 0.10867816, 0.10499048]      )

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







import os
import unittest

from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast
from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class 				__UpperCamelCase				(					SCREAMING_SNAKE_CASE  ,						unittest.TestCase			):
	_lowercase  :   Tuple       				=  LayoutLMTokenizer
	_lowercase  :   List[str]       				=  LayoutLMTokenizerFast
	_lowercase  :   List[Any]       				=  True
	_lowercase  :   Optional[int]       				=  True







	def 	_SCREAMING_SNAKE_CASE							(   self: Any      ):

						'''simple docstring'''





						super().setUp()

						__magic_name__							=    [
						    '[UNK]',
						    '[CLS]',
						    '[SEP]',
						    'want',
						    '##want',
						    '##ed',
						    'wa',
						    'un',
						    'runn',
						    '##ing',
						    ',',
						    'low',
						    'lowest',
						]
						__magic_name__							=    os.path.join(self.tmpdirname  , VOCAB_FILES_NAMES['vocab_file']      )
						with open(self.vocab_file  , 'w'  , encoding='utf-8'      ) as vocab_writer:
											vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]      )      )







	def 	_SCREAMING_SNAKE_CASE							(   self: Union[str, Any]  , **__UpperCamelCase: Union[str, Any]      ):

						'''simple docstring'''





						return LayoutLMTokenizer.from_pretrained(self.tmpdirname  , **__UpperCamelCase      )







	def 	_SCREAMING_SNAKE_CASE							(   self: Tuple  , __UpperCamelCase: List[str]      ):

						'''simple docstring'''





						__magic_name__							=    'UNwant\u00E9d,running'
						__magic_name__							=    'unwanted, running'
						return input_text, output_text







	def 	_SCREAMING_SNAKE_CASE							(   self: List[Any]      ):

						'''simple docstring'''





						__magic_name__							=    self.tokenizer_class(self.vocab_file      )

						__magic_name__							=    tokenizer.tokenize('UNwant\u00E9d,running'      )
						self.assertListEqual(__UpperCamelCase  , ['un', '##want', '##ed', ',', 'runn', '##ing']      )
						self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCamelCase      )  , [7, 4, 5, 10, 8, 9]      )







	def 	_SCREAMING_SNAKE_CASE							(   self: Dict      ):

						'''simple docstring'''





						pass




