

import unittest

from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


__snake_case				:      List[Any]   		=			get_tests_dir("""fixtures/spiece.model""")



@require_sentencepiece
@require_tokenizers
class        A__(a_,  unittest.TestCase							):
						"""simple docstring"""






						_A    :				Tuple       					=			DebertaVaTokenizer
						_A    :				Dict       					=			DebertaVaTokenizerFast
						_A    :				Optional[int]       					=			True
						_A    :				Optional[Any]       					=			True





						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									super().setUp()

									# We have a SentencePiece fixture for testing
									a_						:						str 							= DebertaVaTokenizer(_lowercase  ,      unk_token="""<unk>"""    )
									tokenizer.save_pretrained(self.tmpdirname    )





						def 			UpperCamelCase__					(    self  ,      _lowercase    )     -> Union[str, Any]:
									a_						:						Optional[Any] 							= """this is a test"""
									a_						:						str 							= """this is a test"""
									return input_text, output_text





						def 			UpperCamelCase__					(    self    )     -> str:
									a_						:						Dict 							= """<pad>"""
									a_						:						Union[str, Any] 							= 0

									self.assertEqual(self.get_tokenizer()._convert_token_to_id(_lowercase    )  ,      _lowercase    )
									self.assertEqual(self.get_tokenizer()._convert_id_to_token(_lowercase    )  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> List[str]:
									a_						:						List[Any] 							= list(self.get_tokenizer().get_vocab().keys()    )
									self.assertEqual(vocab_keys[0]  ,      """<pad>"""    )
									self.assertEqual(vocab_keys[1]  ,      """<unk>"""    )
									self.assertEqual(vocab_keys[-1]  ,      """[PAD]"""    )
									self.assertEqual(len(_lowercase    )  ,      30_001    )





						def 			UpperCamelCase__					(    self    )     -> str:
									self.assertEqual(self.get_tokenizer().vocab_size  ,      30_000    )





						def 			UpperCamelCase__					(    self    )     -> Optional[Any]:
									# fmt: off
									a_						:						Tuple 							= """ \tHeLLo!how  \n Are yoU?  """
									a_						:						Tuple 							= ["""▁hello""", """!""", """how""", """▁are""", """▁you""", """?"""]
									# fmt: on

									a_						:						Optional[Any] 							= DebertaVaTokenizer(_lowercase  ,      do_lower_case=_lowercase    )
									a_						:						Tuple 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Any 							= DebertaVaTokenizerFast(_lowercase  ,      do_lower_case=_lowercase    )
									a_						:						str 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )





						@unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""    )
						def 			UpperCamelCase__					(    self    )     -> Tuple:
									pass





						@unittest.skip("""There is an inconsistency between slow and fast tokenizer due to a bug in the fast one."""    )
						def 			UpperCamelCase__					(    self    )     -> Optional[Any]:
									pass





						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									# fmt: off
									a_						:						Dict 							= """I was born in 92000, and this is falsé."""
									a_						:						Union[str, Any] 							= ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
									# fmt: on

									a_						:						Dict 							= DebertaVaTokenizer(_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Optional[Any] 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						str 							= DebertaVaTokenizerFast(_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						List[str] 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> Any:
									# fmt: off
									a_						:						Union[str, Any] 							= """I was born in 92000, and this is falsé."""
									a_						:						Optional[int] 							= ["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
									# fmt: on

									a_						:						Any 							= DebertaVaTokenizer(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Union[str, Any] 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						str 							= DebertaVaTokenizerFast(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Optional[Any] 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )
									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> str:
									# fmt: off
									a_						:						List[str] 							= """I was born in 92000, and this is falsé."""
									a_						:						Any 							= ["""▁i""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """.""", ]
									# fmt: on

									a_						:						int 							= DebertaVaTokenizer(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						str 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Tuple 							= DebertaVaTokenizerFast(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						int 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> Optional[Any]:
									# fmt: off
									a_						:						Tuple 							= """I was born in 92000, and this is falsé."""
									a_						:						Any 							= ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """▁""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """▁""", """.""", ]
									# fmt: on

									a_						:						List[Any] 							= DebertaVaTokenizer(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						str 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Union[str, Any] 							= DebertaVaTokenizerFast(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Optional[int] 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> Any:
									# fmt: off
									a_						:						List[Any] 							= """ \tHeLLo!how  \n Are yoU?  """
									a_						:						Tuple 							= ["""▁""", """<unk>""", """e""", """<unk>""", """o""", """!""", """how""", """▁""", """<unk>""", """re""", """▁yo""", """<unk>""", """?"""]
									# fmt: on

									a_						:						Any 							= DebertaVaTokenizer(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Optional[int] 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Dict 							= DebertaVaTokenizerFast(_lowercase  ,      do_lower_case=_lowercase  ,      split_by_punct=_lowercase    )
									a_						:						Optional[Any] 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )

									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									a_						:						Tuple 							= self.get_tokenizer()
									a_						:						Optional[int] 							= self.get_rust_tokenizer()

									a_						:						str 							= """I was born in 92000, and this is falsé."""

									a_						:						Any 							= tokenizer.convert_ids_to_tokens(tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )
									a_						:						List[str] 							= rust_tokenizer.convert_ids_to_tokens(rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Tuple 							= tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									a_						:						str 							= rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Optional[Any] 							= self.get_rust_tokenizer()
									a_						:						Optional[Any] 							= tokenizer.encode(_lowercase    )
									a_						:						Optional[int] 							= rust_tokenizer.encode(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> int:
									a_						:						Union[str, Any] 							= """This is a test"""
									a_						:						List[Any] 							= [13, 1, 4_398, 25, 21, 1_289]
									a_						:						str 							= ["""▁""", """T""", """his""", """▁is""", """▁a""", """▁test"""]
									a_						:						Union[str, Any] 							= ["""▁""", """<unk>""", """his""", """▁is""", """▁a""", """▁test"""]

									a_						:						int 							= DebertaVaTokenizer(_lowercase  ,      keep_accents=_lowercase    )
									a_						:						Union[str, Any] 							= DebertaVaTokenizerFast(_lowercase  ,      keep_accents=_lowercase    )

									a_						:						int 							= tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Tuple 							= tokenizer.tokenize(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Optional[int] 							= tokenizer.convert_ids_to_tokens(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Optional[Any] 							= rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Optional[Any] 							= rust_tokenizer.tokenize(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Any 							= rust_tokenizer.convert_ids_to_tokens(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									# fmt: off
									a_						:						List[Any] 							= """I was born in 92000, and this is falsé."""
									a_						:						int 							= [13, 1, 23, 386, 19, 561, 3_050, 15, 17, 48, 25, 8_256, 18, 1, 9]
									a_						:						Tuple 							= ["""▁""", """I""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """é""", """.""", ]
									a_						:						str 							= ["""▁""", """<unk>""", """▁was""", """▁born""", """▁in""", """▁9""", """2000""", """,""", """▁and""", """▁this""", """▁is""", """▁fal""", """s""", """<unk>""", """.""", ]
									# fmt: on

									a_						:						Any 							= tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Union[str, Any] 							= tokenizer.tokenize(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Tuple 							= tokenizer.convert_ids_to_tokens(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )

									a_						:						Tuple 							= rust_tokenizer.encode(_lowercase  ,      add_special_tokens=_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						int 							= rust_tokenizer.tokenize(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )
									a_						:						Any 							= rust_tokenizer.convert_ids_to_tokens(_lowercase    )
									self.assertListEqual(_lowercase  ,      _lowercase    )





						def 			UpperCamelCase__					(    self    )     -> Any:
									a_						:						Any 							= DebertaVaTokenizer(_lowercase    )

									a_						:						Optional[Any] 							= tokenizer.encode("""sequence builders"""    )
									a_						:						int 							= tokenizer.encode("""multi-sequence build"""    )

									a_						:						Dict 							= tokenizer.build_inputs_with_special_tokens(_lowercase    )
									a_						:						Optional[Any] 							= tokenizer.build_inputs_with_special_tokens(_lowercase  ,      _lowercase    )

									self.assertEqual([tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]  ,      _lowercase    )
									self.assertEqual(
									    [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [tokenizer.sep_token_id]  ,      _lowercase  ,      )





						@slow
						def 			UpperCamelCase__					(    self    )     -> int:
									# fmt: off
									a_						:						Union[str, Any] 							= {"""input_ids""": [[1, 39_867, 36, 19_390, 486, 27, 35_052, 81_436, 18, 60_685, 1_225, 7, 35_052, 81_436, 18, 9_367, 16_899, 18, 15_937, 53, 594, 773, 18, 16_287, 30_465, 36, 15_937, 6, 41_139, 38, 36_979, 60_763, 191, 6, 34_132, 99, 6, 50_538, 390, 43_230, 6, 34_132, 2_779, 20_850, 14, 699, 1_072, 1_194, 36, 382, 10_901, 53, 7, 699, 1_072, 2_084, 36, 20_422, 630, 53, 19, 105, 3_049, 1_896, 1_053, 16_899, 1_506, 11, 37_978, 4_243, 7, 1_237, 31_869, 200, 16_566, 654, 6, 35_052, 81_436, 7, 55_630, 13_593, 4, 2], [1, 26, 15_011, 13, 667, 8, 1_053, 18, 23_611, 1_237, 72_356, 12_820, 34, 104_134, 1_209, 35, 13_313, 6_627, 21, 202, 347, 7, 164, 2_399, 11, 46, 4_485, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 5, 1_232, 2_864, 15_785, 14_951, 105, 5, 8_581, 1_250, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], """token_type_ids""": [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], """attention_mask""": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
									# fmt: on

									self.tokenizer_integration_test_util(
									    expected_encoding=_lowercase  ,      model_name="""microsoft/deberta-v2-xlarge"""  ,      revision="""ad6e42c1532ddf3a15c39246b63f5559d558b670"""  ,      )





import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    StableDiffusionSAGPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()



class        A__(a_,  a_,  unittest.TestCase							):
						"""simple docstring"""






						_A    :				Optional[Any]       					=			StableDiffusionSAGPipeline
						_A    :				Any       					=			TEXT_TO_IMAGE_PARAMS
						_A    :				Dict       					=			TEXT_TO_IMAGE_BATCH_PARAMS
						_A    :				Dict       					=			TEXT_TO_IMAGE_IMAGE_PARAMS
						_A    :				int       					=			TEXT_TO_IMAGE_IMAGE_PARAMS
						_A    :				Optional[int]       					=			False





						def 			UpperCamelCase__					(    self    )     -> List[Any]:
									torch.manual_seed(0    )
									a_						:						Tuple 							= UNetaDConditionModel(
									    block_out_channels=(32, 64)  ,      layers_per_block=2  ,      sample_size=32  ,      in_channels=4  ,      out_channels=4  ,      down_block_types=("""DownBlock2D""", """CrossAttnDownBlock2D""")  ,      up_block_types=("""CrossAttnUpBlock2D""", """UpBlock2D""")  ,      cross_attention_dim=32  ,      )
									a_						:						int 							= DDIMScheduler(
									    beta_start=0.0_0_0_8_5  ,      beta_end=0.0_1_2  ,      beta_schedule="""scaled_linear"""  ,      clip_sample=_lowercase  ,      set_alpha_to_one=_lowercase  ,      )
									torch.manual_seed(0    )
									a_						:						Tuple 							= AutoencoderKL(
									    block_out_channels=[32, 64]  ,      in_channels=3  ,      out_channels=3  ,      down_block_types=["""DownEncoderBlock2D""", """DownEncoderBlock2D"""]  ,      up_block_types=["""UpDecoderBlock2D""", """UpDecoderBlock2D"""]  ,      latent_channels=4  ,      )
									torch.manual_seed(0    )
									a_						:						str 							= CLIPTextConfig(
									    bos_token_id=0  ,      eos_token_id=2  ,      hidden_size=32  ,      intermediate_size=37  ,      layer_norm_eps=1e-05  ,      num_attention_heads=4  ,      num_hidden_layers=5  ,      pad_token_id=1  ,      vocab_size=1_000  ,      )
									a_						:						Union[str, Any] 							= CLIPTextModel(_lowercase    )
									a_						:						int 							= CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""    )

									a_						:						Union[str, Any] 							= {
									    """unet""": unet,
									    """scheduler""": scheduler,
									    """vae""": vae,
									    """text_encoder""": text_encoder,
									    """tokenizer""": tokenizer,
									    """safety_checker""": None,
									    """feature_extractor""": None,
									}
									return components





						def 			UpperCamelCase__					(    self  ,      _lowercase  ,      _lowercase=0    )     -> Dict:
									if str(_lowercase    ).startswith("""mps"""    ):
												a_						:						Optional[int] 							= torch.manual_seed(_lowercase    )
									else:
												a_						:						str 							= torch.Generator(device=_lowercase    ).manual_seed(_lowercase    )
									a_						:						Tuple 							= {
									    """prompt""": """.""",
									    """generator""": generator,
									    """num_inference_steps""": 2,
									    """guidance_scale""": 1.0,
									    """sag_scale""": 1.0,
									    """output_type""": """numpy""",
									}
									return inputs





						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									super().test_inference_batch_single_identical(expected_max_diff=3e-3    )







@slow
@require_torch_gpu
class        A__(unittest.TestCase							):
						"""simple docstring"""






						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									# clean up the VRAM after each test
									super().tearDown()
									gc.collect()
									torch.cuda.empty_cache()





						def 			UpperCamelCase__					(    self    )     -> Optional[int]:
									a_						:						Tuple 							= StableDiffusionSAGPipeline.from_pretrained("""CompVis/stable-diffusion-v1-4"""    )
									a_						:						List[str] 							= sag_pipe.to(_lowercase    )
									sag_pipe.set_progress_bar_config(disable=_lowercase    )

									a_						:						Optional[int] 							= """."""
									a_						:						int 							= torch.manual_seed(0    )
									a_						:						Any 							= sag_pipe(
									    [prompt]  ,      generator=_lowercase  ,      guidance_scale=7.5  ,      sag_scale=1.0  ,      num_inference_steps=20  ,      output_type="""np"""    )

									a_						:						Any 							= output.images

									a_						:						Optional[int] 							= image[0, -3:, -3:, -1]

									assert image.shape == (1, 512, 512, 3)
									a_						:						str 							= np.array([0.1_5_6_8, 0.1_7_3_8, 0.1_6_9_5, 0.1_6_9_3, 0.1_5_0_7, 0.1_7_0_5, 0.1_5_4_7, 0.1_7_5_1, 0.1_9_4_9]    )

									assert np.abs(image_slice.flatten() - expected_slice    ).max() < 5e-2





						def 			UpperCamelCase__					(    self    )     -> List[Any]:
									a_						:						Optional[int] 							= StableDiffusionSAGPipeline.from_pretrained("""stabilityai/stable-diffusion-2-1-base"""    )
									a_						:						List[str] 							= sag_pipe.to(_lowercase    )
									sag_pipe.set_progress_bar_config(disable=_lowercase    )

									a_						:						int 							= """."""
									a_						:						Dict 							= torch.manual_seed(0    )
									a_						:						Union[str, Any] 							= sag_pipe(
									    [prompt]  ,      generator=_lowercase  ,      guidance_scale=7.5  ,      sag_scale=1.0  ,      num_inference_steps=20  ,      output_type="""np"""    )

									a_						:						Optional[Any] 							= output.images

									a_						:						int 							= image[0, -3:, -3:, -1]

									assert image.shape == (1, 512, 512, 3)
									a_						:						Dict 							= np.array([0.3_4_5_9, 0.2_8_7_6, 0.2_5_3_7, 0.3_0_0_2, 0.2_6_7_1, 0.2_1_6_0, 0.3_0_2_6, 0.2_2_6_2, 0.2_3_7_1]    )

									assert np.abs(image_slice.flatten() - expected_slice    ).max() < 5e-2





						def 			UpperCamelCase__					(    self    )     -> Any:
									a_						:						int 							= StableDiffusionSAGPipeline.from_pretrained("""stabilityai/stable-diffusion-2-1-base"""    )
									a_						:						Optional[Any] 							= sag_pipe.to(_lowercase    )
									sag_pipe.set_progress_bar_config(disable=_lowercase    )

									a_						:						List[Any] 							= """."""
									a_						:						str 							= torch.manual_seed(0    )
									a_						:						int 							= sag_pipe(
									    [prompt]  ,      width=768  ,      height=512  ,      generator=_lowercase  ,      guidance_scale=7.5  ,      sag_scale=1.0  ,      num_inference_steps=20  ,      output_type="""np"""  ,      )

									a_						:						Any 							= output.images

									assert image.shape == (1, 512, 768, 3)


