"""simple docstring"""


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    a__    (   unittest.TestCase	):


     def 	snake_case__	(     self  ):
          '''simple docstring'''



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


     def 	snake_case__	(     self  ):
          '''simple docstring'''



          lowercase__				 =							StableDiffusionKDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4"  )
          lowercase__				 =							sd_pipe.to(__lowerCamelCase  )
          sd_pipe.set_progress_bar_config(disable=__lowerCamelCase  )

          sd_pipe.set_scheduler("sample_euler"  )

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

          lowercase__				 =							output.images

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

          assert image.shape == (1, 512, 512, 3)
          lowercase__				 =							np.array([0.0_447, 0.0_492, 0.0_468, 0.0_408, 0.0_383, 0.0_408, 0.0_354, 0.0_380, 0.0_339]  )

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


     def 	snake_case__	(     self  ):
          '''simple docstring'''



          lowercase__				 =							StableDiffusionKDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base"  )
          lowercase__				 =							sd_pipe.to(__lowerCamelCase  )
          sd_pipe.set_progress_bar_config(disable=__lowerCamelCase  )

          sd_pipe.set_scheduler("sample_euler"  )

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

          lowercase__				 =							output.images

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

          assert image.shape == (1, 512, 512, 3)
          lowercase__				 =							np.array([0.1_237, 0.1_320, 0.1_438, 0.1_359, 0.1_390, 0.1_132, 0.1_277, 0.1_175, 0.1_112]  )

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


     def 	snake_case__	(     self  ):
          '''simple docstring'''



          lowercase__				 =							StableDiffusionKDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base"  )
          lowercase__				 =							sd_pipe.to(__lowerCamelCase  )
          sd_pipe.set_progress_bar_config(disable=__lowerCamelCase  )

          sd_pipe.set_scheduler("sample_dpmpp_2m"  )

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

          lowercase__				 =							output.images

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

          assert image.shape == (1, 512, 512, 3)
          lowercase__				 =							np.array(
              [0.11_381_689, 0.12_112_921, 0.1_389_457, 0.12_549_606, 0.1_244_964, 0.10_831_517, 0.11_562_866, 0.10_867_816, 0.10_499_048]  )

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





"""simple docstring"""


from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase_:					List[Any]     =					logging.get_logger(__name__)

lowerCAmelCase_:					int     =					{
    "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json",
    "microsoft/markuplm-large": "https://huggingface.co/microsoft/markuplm-large/resolve/main/config.json",
}






class    a__    (   _a	):
   snake_case_							=      "markuplm"


   def __init__(     self,				_UpperCAmelCase=3_0522,				_UpperCAmelCase=768,				_UpperCAmelCase=12,				_UpperCAmelCase=12,				_UpperCAmelCase=3072,				_UpperCAmelCase="gelu",				_UpperCAmelCase=0.1,				_UpperCAmelCase=0.1,				_UpperCAmelCase=512,				_UpperCAmelCase=2,				_UpperCAmelCase=0.02,				_UpperCAmelCase=1E-12,				_UpperCAmelCase=0,				_UpperCAmelCase=0,				_UpperCAmelCase=2,				_UpperCAmelCase=256,				_UpperCAmelCase=1024,				_UpperCAmelCase=216,				_UpperCAmelCase=1001,				_UpperCAmelCase=32,				_UpperCAmelCase=50,				_UpperCAmelCase="absolute",				_UpperCAmelCase=True,				_UpperCAmelCase=None,				**_UpperCAmelCase,				):
        '''simple docstring'''



        super().__init__(
            pad_token_id=_UpperCAmelCase,				bos_token_id=_UpperCAmelCase,				eos_token_id=_UpperCAmelCase,				**_UpperCAmelCase,				)
        lowercase__				 =							vocab_size
        lowercase__				 =							hidden_size
        lowercase__				 =							num_hidden_layers
        lowercase__				 =							num_attention_heads
        lowercase__				 =							hidden_act
        lowercase__				 =							intermediate_size
        lowercase__				 =							hidden_dropout_prob
        lowercase__				 =							attention_probs_dropout_prob
        lowercase__				 =							max_position_embeddings
        lowercase__				 =							type_vocab_size
        lowercase__				 =							initializer_range
        lowercase__				 =							layer_norm_eps
        lowercase__				 =							position_embedding_type
        lowercase__				 =							use_cache
        lowercase__				 =							classifier_dropout
        # additional properties
        lowercase__				 =							max_depth
        lowercase__				 =							max_xpath_tag_unit_embeddings
        lowercase__				 =							max_xpath_subs_unit_embeddings
        lowercase__				 =							tag_pad_id
        lowercase__				 =							subs_pad_id
        lowercase__				 =							xpath_unit_hidden_size




