






"""simple docstring"""







from __future__ import annotations





def 						lowercase__(A ,		A						)    ->list[list[int]]:




						"""simple docstring"""



						lowercase__    :				list[list[int]]=	[]
						create_all_state(1 ,		A ,		A ,		[] ,		A						)
						return result





def 						lowercase__(A ,		A ,		A ,		A ,		A ,		)    ->None:




						"""simple docstring"""



						if level == 0:
												total_list.append(current_list[:]						)
												return

						for i in range(A ,		total_number - level + 2						):
												current_list.append(A						)
												create_all_state(i + 1 ,		A ,		level - 1 ,		A ,		A						)
												current_list.pop()





def 						lowercase__(A						)    ->None:




						"""simple docstring"""



						for i in total_list:
												print(*A						)


if __name__ == "__main__":
			a			:    str				 =		4
			a			:    Any				 =		2
			a			:    Optional[int]				 =		generate_all_combinations(n, k)
			print_all_state(total_list)














"""simple docstring"""







import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


a			:    Union[str, Any]				 =		False


class    __UpperCAmelCase(       unittest.TestCase							):




						"""simple docstring"""




						pass


@nightly
@require_torch_gpu
class    __UpperCAmelCase(       unittest.TestCase							):




						"""simple docstring"""




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												# clean up the VRAM after each test
												super().tearDown()
												gc.collect()
												torch.cuda.empty_cache()




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Dict=	VersatileDiffusionTextToImagePipeline.from_pretrained("shi-labs/versatile-diffusion"      )
												# remove text_unet
												pipe.remove_unused_weights()
												pipe.to(snake_case__      )
												pipe.set_progress_bar_config(disable=snake_case__      )

												lowercase__    :				Any=	"A painting of a squirrel eating a burger "
												lowercase__    :				Optional[Any]=	torch.manual_seed(0      )
												lowercase__    :				List[str]=	pipe(
												    prompt=snake_case__	,  generator=snake_case__	,  guidance_scale=7.5	,  num_inference_steps=2	,  output_type="numpy"      ).images

												with tempfile.TemporaryDirectory() as tmpdirname:
																		pipe.save_pretrained(snake_case__      )
																		lowercase__    :				Optional[Any]=	VersatileDiffusionTextToImagePipeline.from_pretrained(snake_case__      )
												pipe.to(snake_case__      )
												pipe.set_progress_bar_config(disable=snake_case__      )

												lowercase__    :				Any=	generator.manual_seed(0      )
												lowercase__    :				Tuple=	pipe(
												    prompt=snake_case__	,  generator=snake_case__	,  guidance_scale=7.5	,  num_inference_steps=2	,  output_type="numpy"      ).images

												assert np.abs(image - new_image      ).sum() < 1e-5, "Models don't have the same forward pass"




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Tuple=	VersatileDiffusionTextToImagePipeline.from_pretrained(
												    "shi-labs/versatile-diffusion"	,  torch_dtype=torch.floataa      )
												pipe.to(snake_case__      )
												pipe.set_progress_bar_config(disable=snake_case__      )

												lowercase__    :				List[str]=	"A painting of a squirrel eating a burger "
												lowercase__    :				Union[str, Any]=	torch.manual_seed(0      )
												lowercase__    :				Optional[Any]=	pipe(
												    prompt=snake_case__	,  generator=snake_case__	,  guidance_scale=7.5	,  num_inference_steps=50	,  output_type="numpy"      ).images

												lowercase__    :				List[str]=	image[0, 253:256, 253:256, -1]

												assert image.shape == (1, 512, 512, 3)
												lowercase__    :				Optional[int]=	np.array([0.33_67, 0.31_69, 0.26_56, 0.38_70, 0.47_90, 0.37_96, 0.40_09, 0.48_78, 0.47_78]      )

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






