"""simple docstring"""





import unittest

from diffusers.models.unet_ad_blocks import *  # noqa F403
from diffusers.utils import torch_device

from .test_unet_blocks_common import UNetBlockTesterMixin
class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			DownBlockaD  # noqa F405
						snake_case__			  =			"down"






						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		str		   =     [-0.0_2_3_2, -0.9_8_6_9, 0.8_0_5_4, -0.0_6_3_7, -0.1_6_8_8, -1.4_2_6_4, 0.4_4_7_0, -1.3_3_9_4, 0.0_9_0_4]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			ResnetDownsampleBlockaD  # noqa F405
						snake_case__			  =			"down"






						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		Optional[int]		   =     [0.0_7_1_0, 0.2_4_1_0, -0.7_3_2_0, -1.0_7_5_7, -1.1_3_4_3, 0.3_5_4_0, -0.0_1_3_3, -0.2_5_7_6, 0.0_9_4_8]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnDownBlockaD  # noqa F405
						snake_case__			  =			"down"






						def       lowerCamelCase__     (       self      :			List[Any]    ):
													__lowerCamelCase					:		Any		   =     [0.0_6_3_6, 0.8_9_6_4, -0.6_2_3_4, -1.0_1_3_1, 0.0_8_4_4, 0.4_9_3_5, 0.3_4_3_7, 0.0_9_1_1, -0.2_9_5_7]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			CrossAttnDownBlockaD  # noqa F405
						snake_case__			  =			"down"






						def       lowerCamelCase__     (       self      :			List[Any]    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		Union[str, Any]		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		Optional[Any]		   =     32
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Tuple    ):
													__lowerCamelCase					:		int		   =     [0.2_2_3_8, -0.7_3_9_6, -0.2_2_5_5, -0.3_8_2_9, 0.1_9_2_5, 1.1_6_6_5, 0.0_6_0_3, -0.7_2_9_5, 0.1_9_8_3]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			SimpleCrossAttnDownBlockaD  # noqa F405
						snake_case__			  =			"down"






						@property
						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													return super().get_dummy_input(include_encoder_hidden_states=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		Dict		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		Union[str, Any]		   =     32
													return init_dict, inputs_dict







						@unittest.skipIf(torch_device == "mps"							,					"MPS result is not consistent"    )
						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		Optional[Any]		   =     [0.7_9_2_1, -0.0_9_9_2, -0.1_9_6_2, -0.7_6_9_5, -0.4_2_4_2, 0.7_8_0_4, 0.4_7_3_7, 0.2_7_6_5, 0.3_3_3_8]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			SkipDownBlockaD  # noqa F405
						snake_case__			  =			"down"






						@property
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													return super().get_dummy_input(include_skip_sample=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		List[str]		   =     [-0.0_8_4_5, -0.2_0_8_7, -0.2_4_6_5, 0.0_9_7_1, 0.1_9_0_0, -0.0_4_8_4, 0.2_6_6_4, 0.4_1_7_9, 0.5_0_6_9]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnSkipDownBlockaD  # noqa F405
						snake_case__			  =			"down"






						@property
						def       lowerCamelCase__     (       self      :			str    ):
													return super().get_dummy_input(include_skip_sample=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			str    ):
													__lowerCamelCase					:		Dict		   =     [0.5_5_3_9, 0.1_6_0_9, 0.4_9_2_4, 0.0_5_3_7, -0.1_9_9_5, 0.4_0_5_0, 0.0_9_7_9, -0.2_7_2_1, -0.0_6_4_2]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			DownEncoderBlockaD  # noqa F405
						snake_case__			  =			"down"






						@property
						def       lowerCamelCase__     (       self      :			List[Any]    ):
													return super().get_dummy_input(include_temb=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		int		   =     {
													    "in_channels": 32,
													    "out_channels": 32,
													}
													__lowerCamelCase					:		Optional[int]		   =     self.dummy_input
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													__lowerCamelCase					:		int		   =     [1.1_1_0_2, 0.5_3_0_2, 0.4_8_7_2, -0.0_0_2_3, -0.8_0_4_2, 0.0_4_8_3, -0.3_4_8_9, -0.5_6_3_2, 0.7_6_2_6]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnDownEncoderBlockaD  # noqa F405
						snake_case__			  =			"down"






						@property
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													return super().get_dummy_input(include_temb=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													__lowerCamelCase					:		List[Any]		   =     {
													    "in_channels": 32,
													    "out_channels": 32,
													}
													__lowerCamelCase					:		Union[str, Any]		   =     self.dummy_input
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			str    ):
													__lowerCamelCase					:		int		   =     [0.8_9_6_6, -0.1_4_8_6, 0.8_5_6_8, 0.8_1_4_1, -0.9_0_4_6, -0.1_3_4_2, -0.0_9_7_2, -0.7_4_1_7, 0.1_5_3_8]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			UNetMidBlockaD  # noqa F405
						snake_case__			  =			"mid"






						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													__lowerCamelCase					:		List[Any]		   =     {
													    "in_channels": 32,
													    "temb_channels": 128,
													}
													__lowerCamelCase					:		List[str]		   =     self.dummy_input
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase					:		List[str]		   =     [-0.1_0_6_2, 1.7_2_4_8, 0.3_4_9_4, 1.4_5_6_9, -0.0_9_1_0, -1.2_4_2_1, -0.9_9_8_4, 0.6_7_3_6, 1.0_0_2_8]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			UNetMidBlockaDCrossAttn  # noqa F405
						snake_case__			  =			"mid"






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		int		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		Dict		   =     32
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase					:		Union[str, Any]		   =     [0.0_1_8_7, 2.4_2_2_0, 0.4_4_8_4, 1.1_2_0_3, -0.6_1_2_1, -1.5_1_2_2, -0.8_2_7_0, 0.7_8_5_1, 1.8_3_3_5]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			UNetMidBlockaDSimpleCrossAttn  # noqa F405
						snake_case__			  =			"mid"






						@property
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													return super().get_dummy_input(include_encoder_hidden_states=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			str    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		Any		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		List[str]		   =     32
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Optional[int]		   =     [0.7_1_4_3, 1.9_9_7_4, 0.5_4_4_8, 1.3_9_7_7, 0.1_2_8_2, -1.1_2_3_7, -1.4_2_3_8, 0.5_5_3_0, 0.8_8_8_0]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			UpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Dict    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		Optional[int]		   =     [-0.2_0_4_1, -0.4_1_6_5, -0.3_0_2_2, 0.0_0_4_1, -0.6_6_2_8, -0.7_0_5_3, 0.1_9_2_8, -0.0_3_2_5, 0.0_5_2_3]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			ResnetUpsampleBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Optional[int]		   =     [0.2_2_8_7, 0.3_5_4_9, -0.1_3_4_6, 0.4_7_9_7, -0.1_7_1_5, -0.9_6_4_9, 0.7_3_0_5, -0.5_8_6_4, -0.6_2_4_4]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			CrossAttnUpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			int    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		List[str]		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		Any		   =     32
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		Tuple		   =     [-0.1_4_0_3, -0.3_5_1_5, -0.0_4_2_0, -0.1_4_2_5, 0.3_1_6_7, 0.5_0_9_4, -0.2_1_8_1, 0.5_9_3_1, 0.5_5_8_2]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			SimpleCrossAttnUpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase							,					include_encoder_hidden_states=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase   ,  __lowerCamelCase					:		str		   =     super().prepare_init_args_and_inputs_for_common()
													__lowerCamelCase					:		Dict		   =     32
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													__lowerCamelCase					:		List[Any]		   =     [0.2_6_4_5, 0.1_4_8_0, 0.0_9_0_9, 0.8_0_4_4, -0.9_7_5_8, -0.9_0_8_3, 0.0_9_9_4, -1.1_4_5_3, -0.7_4_0_2]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnUpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			str    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )







						@unittest.skipIf(torch_device == "mps"							,					"MPS result is not consistent"    )
						def       lowerCamelCase__     (       self      :			Tuple    ):
													__lowerCamelCase					:		List[str]		   =     [0.0_9_7_9, 0.1_3_2_6, 0.0_0_2_1, 0.0_6_5_9, 0.2_2_4_9, 0.0_0_5_9, 0.1_1_3_2, 0.5_9_5_2, 0.1_0_3_3]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			SkipUpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			List[str]    ):
													__lowerCamelCase					:		str		   =     [-0.0_8_9_3, -0.1_2_3_4, -0.1_5_0_6, -0.0_3_3_2, 0.0_1_2_3, -0.0_2_1_1, 0.0_5_6_6, 0.0_1_4_3, 0.0_3_6_2]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnSkipUpBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													return super().get_dummy_input(include_res_hidden_states_tuple=_UpperCAmelCase    )







						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		Optional[Any]		   =     [0.0_3_6_1, 0.0_6_1_7, 0.2_7_8_7, -0.0_3_5_0, 0.0_3_4_2, 0.3_4_2_1, -0.0_8_4_3, 0.0_9_1_3, 0.3_0_1_5]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			UpDecoderBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													return super().get_dummy_input(include_temb=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Any    ):
													__lowerCamelCase					:		Tuple		   =     {"in_channels": 32, "out_channels": 32}

													__lowerCamelCase					:		Dict		   =     self.dummy_input
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			int    ):
													__lowerCamelCase					:		Optional[Any]		   =     [0.4_4_0_4, 0.1_9_9_8, -0.9_8_8_6, -0.3_3_2_0, -0.3_1_2_8, -0.7_0_3_4, -0.6_9_5_5, -0.2_3_3_8, -0.3_1_3_7]
													super().test_output(_UpperCAmelCase    )

class  _snake_case     (					a__				, unittest.TestCase		):
						snake_case__			  =			AttnUpDecoderBlockaD  # noqa F405
						snake_case__			  =			"up"






						@property
						def       lowerCamelCase__     (       self      :			Optional[int]    ):
													return super().get_dummy_input(include_temb=_UpperCAmelCase    )






						def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
													__lowerCamelCase					:		Dict		   =     {"in_channels": 32, "out_channels": 32}

													__lowerCamelCase					:		Optional[Any]		   =     self.dummy_input
													return init_dict, inputs_dict







						def       lowerCamelCase__     (       self      :			Optional[Any]    ):
													__lowerCamelCase					:		Any		   =     [0.6_7_3_8, 0.4_4_9_1, 0.1_0_5_5, 1.0_7_1_0, 0.7_3_1_6, 0.3_3_3_9, 0.3_3_5_2, 0.1_0_2_3, 0.3_5_6_8]
													super().test_output(_UpperCAmelCase    )






"""simple docstring"""





from typing import Dict, List, Optional, Tuple, Union

import torch

from ...models import AutoencoderKL, TransformeraDModel
from ...schedulers import KarrasDiffusionSchedulers
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
class  _snake_case     (					a__		):






						def __init__(       self      :			str							,					UpperCAmelCase      :			TransformeraDModel							,					UpperCAmelCase      :			AutoencoderKL							,					UpperCAmelCase      :			KarrasDiffusionSchedulers							,					UpperCAmelCase      :			Optional[Dict[int, str]] = None							,					):
													super().__init__()
													self.register_modules(transformer=UpperCAmelCase							,					vae=UpperCAmelCase							,					scheduler=UpperCAmelCase    )

													# create a imagenet -> id dictionary for easier use
													__lowerCamelCase					:		Optional[Any]		   =     {}
													if idalabel is not None:
																				for key, value in idalabel.items():
																											for label in value.split(","    ):
																																		__lowerCamelCase					:		List[str]		   =     int(UpperCAmelCase    )
																				__lowerCamelCase					:		Union[str, Any]		   =     dict(sorted(self.labels.items()    )    )






						def       lowerCamelCase__     (       self      :			List[str]							,					UpperCAmelCase      :			Union[str, List[str]]    ):

													if not isinstance(UpperCAmelCase							,					UpperCAmelCase    ):
																				__lowerCamelCase					:		List[str]		   =     list(UpperCAmelCase    )

													for l in label:
																				if l not in self.labels:
																											raise ValueError(
																											    F"""{l} does not exist. Please make sure to select one of the following labels: \n {self.labels}."""    )

													return [self.labels[l] for l in label]







						@torch.no_grad()
						def __call__(       self      :			int							,					UpperCAmelCase      :			List[int]							,					UpperCAmelCase      :			float = 4.0							,					UpperCAmelCase      :			Optional[Union[torch.Generator, List[torch.Generator]]] = None							,					UpperCAmelCase      :			int = 50							,					UpperCAmelCase      :			Optional[str] = "pil"							,					UpperCAmelCase      :			bool = True							,					):
													__lowerCamelCase					:		int		   =     len(UpperCAmelCase    )
													__lowerCamelCase					:		Any		   =     self.transformer.config.sample_size
													__lowerCamelCase					:		Dict		   =     self.transformer.config.in_channels

													__lowerCamelCase					:		Any		   =     randn_tensor(
													    shape=(batch_size, latent_channels, latent_size, latent_size)							,					generator=UpperCAmelCase							,					device=self.device							,					dtype=self.transformer.dtype							,					)
													__lowerCamelCase					:		Optional[Any]		   =     torch.cat([latents] * 2    ) if guidance_scale > 1 else latents

													__lowerCamelCase					:		Optional[int]		   =     torch.tensor(UpperCAmelCase							,					device=self.device    ).reshape(-1    )
													__lowerCamelCase					:		Optional[int]		   =     torch.tensor([1000] * batch_size							,					device=self.device    )
													__lowerCamelCase					:		Any		   =     torch.cat([class_labels, class_null]							,					0    ) if guidance_scale > 1 else class_labels

													# set step values
													self.scheduler.set_timesteps(UpperCAmelCase    )

													for t in self.progress_bar(self.scheduler.timesteps    ):
																				if guidance_scale > 1:
																											__lowerCamelCase					:		str		   =     latent_model_input[: len(UpperCAmelCase    ) // 2]
																											__lowerCamelCase					:		Optional[Any]		   =     torch.cat([half, half]							,					dim=0    )
																				__lowerCamelCase					:		Dict		   =     self.scheduler.scale_model_input(UpperCAmelCase							,					UpperCAmelCase    )

																				__lowerCamelCase					:		Dict		   =     t
																				if not torch.is_tensor(UpperCAmelCase    ):
																											# TODO: this requires sync between CPU and GPU. So try to pass timesteps as tensors if you can
																											# This would be a good case for the `match` statement (Python 3.10+)
																											__lowerCamelCase					:		List[str]		   =     latent_model_input.device.type == "mps"
																											if isinstance(UpperCAmelCase							,					UpperCAmelCase    ):
																																		__lowerCamelCase					:		List[Any]		   =     torch.floataa if is_mps else torch.floataa
																											else:
																																		__lowerCamelCase					:		Optional[Any]		   =     torch.intaa if is_mps else torch.intaa
																											__lowerCamelCase					:		Union[str, Any]		   =     torch.tensor([timesteps]							,					dtype=UpperCAmelCase							,					device=latent_model_input.device    )
																				elif len(timesteps.shape    ) == 0:
																											__lowerCamelCase					:		Union[str, Any]		   =     timesteps[None].to(latent_model_input.device    )
																				# broadcast to batch dimension in a way that's compatible with ONNX/Core ML
																				__lowerCamelCase					:		List[Any]		   =     timesteps.expand(latent_model_input.shape[0]    )
																				# predict noise model_output
																				__lowerCamelCase					:		Union[str, Any]		   =     self.transformer(
																				    UpperCAmelCase							,					timestep=UpperCAmelCase							,					class_labels=UpperCAmelCase    ).sample

																				# perform guidance
																				if guidance_scale > 1:
																											__lowerCamelCase   ,  __lowerCamelCase					:		str		   =     noise_pred[:, :latent_channels], noise_pred[:, latent_channels:]
																											__lowerCamelCase   ,  __lowerCamelCase					:		Union[str, Any]		   =     torch.split(UpperCAmelCase							,					len(UpperCAmelCase    ) // 2							,					dim=0    )

																											__lowerCamelCase					:		List[str]		   =     uncond_eps + guidance_scale * (cond_eps - uncond_eps)
																											__lowerCamelCase					:		Union[str, Any]		   =     torch.cat([half_eps, half_eps]							,					dim=0    )

																											__lowerCamelCase					:		Optional[Any]		   =     torch.cat([eps, rest]							,					dim=1    )

																				# learned sigma
																				if self.transformer.config.out_channels // 2 == latent_channels:
																											__lowerCamelCase   ,  __lowerCamelCase					:		int		   =     torch.split(UpperCAmelCase							,					UpperCAmelCase							,					dim=1    )
																				else:
																											__lowerCamelCase					:		int		   =     noise_pred

																				# compute previous image: x_t -> x_t-1
																				__lowerCamelCase					:		Optional[Any]		   =     self.scheduler.step(UpperCAmelCase							,					UpperCAmelCase							,					UpperCAmelCase    ).prev_sample

													if guidance_scale > 1:
																				__lowerCamelCase   ,  __lowerCamelCase					:		List[str]		   =     latent_model_input.chunk(2							,					dim=0    )
													else:
																				__lowerCamelCase					:		Optional[Any]		   =     latent_model_input

													__lowerCamelCase					:		Tuple		   =     1 / self.vae.config.scaling_factor * latents
													__lowerCamelCase					:		Any		   =     self.vae.decode(UpperCAmelCase    ).sample

													__lowerCamelCase					:		Tuple		   =     (samples / 2 + 0.5).clamp(0							,					1    )

													# we always cast to float32 as this does not cause significant overhead and is compatible with bfloat16
													__lowerCamelCase					:		Optional[int]		   =     samples.cpu().permute(0							,					2							,					3							,					1    ).float().numpy()

													if output_type == "pil":
																				__lowerCamelCase					:		Dict		   =     self.numpy_to_pil(UpperCAmelCase    )

													if not return_dict:
																				return (samples,)

													return ImagePipelineOutput(images=UpperCAmelCase    )