


'''simple docstring'''



import inspect
import unittest

from transformers import is_torch_available, is_vision_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import MODEL_MAPPING, GLPNConfig, GLPNForDepthEstimation, GLPNModel
	from transformers.models.glpn.modeling_glpn import GLPN_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import GLPNImageProcessor





class 							__UpperCamelCase       (	lowerCAmelCase_      ):




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Tuple      					=						self.config_class(**self.inputs_dict							)
						self.parent.assertTrue(hasattr(__a		,       'hidden_sizes'							)							)
						self.parent.assertTrue(hasattr(__a		,       'num_attention_heads'							)							)
						self.parent.assertTrue(hasattr(__a		,       'num_encoder_blocks'							)							)





class 							__UpperCamelCase       :




	def __init__(     self		,       __a		,       __a=13		,       __a=64		,       __a=3		,       __a=4		,       __a=[2, 2, 2, 2]		,       __a=[8, 4, 2, 1]		,       __a=[16, 32, 64, 128]		,       __a=[1, 4, 8, 16]		,       __a=[1, 2, 4, 8]		,       __a=True		,       __a=True		,       __a="gelu"		,       __a=0.1		,       __a=0.1		,       __a=0.02		,       __a=16		,       __a=3		,       __a=None		,       ):

						'''simple docstring'''





						__a    : Union[str, Any]      					=						parent
						__a    : List[Any]      					=						batch_size
						__a    : List[str]      					=						image_size
						__a    : Any      					=						num_channels
						__a    : str      					=						num_encoder_blocks
						__a    : Optional[int]      					=						sr_ratios
						__a    : Any      					=						depths
						__a    : Dict      					=						hidden_sizes
						__a    : List[Any]      					=						downsampling_rates
						__a    : Optional[Any]      					=						num_attention_heads
						__a    : Union[str, Any]      					=						is_training
						__a    : List[str]      					=						use_labels
						__a    : Union[str, Any]      					=						hidden_act
						__a    : Optional[Any]      					=						hidden_dropout_prob
						__a    : Optional[Any]      					=						attention_probs_dropout_prob
						__a    : List[Any]      					=						initializer_range
						__a    : Any      					=						decoder_hidden_size
						__a    : Dict      					=						num_labels
						__a    : Union[str, Any]      					=						scope




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Optional[Any]      					=						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

						__a    : Tuple      					=						None
						if self.use_labels:
											__a    : Dict      					=						ids_tensor([self.batch_size, self.image_size, self.image_size]		,       self.num_labels							)

						__a    : int      					=						self.get_config()
						return config, pixel_values, labels




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						return GLPNConfig(
						    image_size=self.image_size		,       num_channels=self.num_channels		,       num_encoder_blocks=self.num_encoder_blocks		,       depths=self.depths		,       hidden_sizes=self.hidden_sizes		,       num_attention_heads=self.num_attention_heads		,       hidden_act=self.hidden_act		,       hidden_dropout_prob=self.hidden_dropout_prob		,       attention_probs_dropout_prob=self.attention_probs_dropout_prob		,       initializer_range=self.initializer_range		,       decoder_hidden_size=self.decoder_hidden_size		,       )




	def    __UpperCAmelCase							(     self		,       __a		,       __a		,       __a							):

						'''simple docstring'''





						__a    : Optional[int]      					=						GLPNModel(config=__a							)
						model.to(__a							)
						model.eval()
						__a    : Tuple      					=						model(__a							)
						__a    : Optional[int]      					=						self.image_size // (self.downsampling_rates[-1] * 2)
						self.parent.assertEqual(
						    result.last_hidden_state.shape		,       (self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)							)




	def    __UpperCAmelCase							(     self		,       __a		,       __a		,       __a							):

						'''simple docstring'''





						__a    : Optional[int]      					=						self.num_labels
						__a    : List[Any]      					=						GLPNForDepthEstimation(__a							)
						model.to(__a							)
						model.eval()
						__a    : List[str]      					=						model(__a							)
						self.parent.assertEqual(result.predicted_depth.shape		,       (self.batch_size, self.image_size, self.image_size)							)
						__a    : List[Any]      					=						model(__a		,       labels=__a							)
						self.parent.assertEqual(result.predicted_depth.shape		,       (self.batch_size, self.image_size, self.image_size)							)





	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Optional[Any]      					=						self.prepare_config_and_inputs()
						__a					,       __a					,       __a    : Tuple      					=						config_and_inputs
						__a    : List[str]      					=						{'pixel_values': pixel_values}
						return config, inputs_dict





@require_torch
class 							__UpperCamelCase       (	lowerCAmelCase_	,   lowerCAmelCase_	,   unittest.TestCase      ):
	A_			    =					(GLPNModel, GLPNForDepthEstimation) if is_torch_available() else ()
	A_			    =					(
	    {"depth-estimation": GLPNForDepthEstimation, "feature-extraction": GLPNModel} if is_torch_available() else {}
	)

	A_			    =					False
	A_			    =					False
	A_			    =					False




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Optional[Any]      					=						GLPNModelTester(self							)
						__a    : Tuple      					=						GLPNConfigTester(self		,       config_class=__a							)




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						self.config_tester.run_common_tests()




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Optional[int]      					=						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*__a							)




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : Tuple      					=						self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_depth_estimation(*__a							)




	@unittest.skip('GLPN does not use inputs_embeds'							)
	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						pass




	@unittest.skip('GLPN does not have get_input_embeddings method and get_output_embeddings methods'							)
	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						pass




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a					,       __a    : str      					=						self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
											__a    : Optional[int]      					=						model_class(__a							)
											__a    : Dict      					=						inspect.signature(model.forward							)
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											__a    : int      					=						[*signature.parameters.keys()]

											__a    : Tuple      					=						['pixel_values']
											self.assertListEqual(arg_names[:1]		,       __a							)




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a					,       __a    : List[Any]      					=						self.model_tester.prepare_config_and_inputs_for_common()
						__a    : Dict      					=						True

						for model_class in self.all_model_classes:
											__a    : Dict      					=						True
											__a    : Tuple      					=						False
											__a    : Tuple      					=						True
											__a    : Dict      					=						model_class(__a							)
											model.to(__a							)
											model.eval()
											with torch.no_grad():
																__a    : str      					=						model(**self._prepare_for_class(__a		,       __a							)							)
											__a    : Dict      					=						outputs.attentions

											__a    : Union[str, Any]      					=						sum(self.model_tester.depths							)
											self.assertEqual(len(__a							)		,       __a							)

											# check that output_attentions also work using config
											del inputs_dict["output_attentions"]
											__a    : List[Any]      					=						True
											__a    : str      					=						model_class(__a							)
											model.to(__a							)
											model.eval()
											with torch.no_grad():
																__a    : Dict      					=						model(**self._prepare_for_class(__a		,       __a							)							)
											__a    : Any      					=						outputs.attentions

											self.assertEqual(len(__a							)		,       __a							)

											# verify the first attentions (first block, first layer)
											__a    : Optional[Any]      					=						(self.model_tester.image_size // 4) ** 2
											__a    : int      					=						(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
											self.assertListEqual(
											    list(attentions[0].shape[-3:]							)		,       [self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]		,       )

											# verify the last attentions (last block, last layer)
											__a    : int      					=						(self.model_tester.image_size // 32) ** 2
											__a    : List[str]      					=						(self.model_tester.image_size // (32 * self.model_tester.sr_ratios[-1])) ** 2
											self.assertListEqual(
											    list(attentions[-1].shape[-3:]							)		,       [self.model_tester.num_attention_heads[-1], expected_seq_len, expected_reduced_seq_len]		,       )
											__a    : Dict      					=						len(__a							)

											# Check attention is always last and order is fine
											__a    : Tuple      					=						True
											__a    : Dict      					=						True
											__a    : int      					=						model_class(__a							)
											model.to(__a							)
											model.eval()
											with torch.no_grad():
																__a    : int      					=						model(**self._prepare_for_class(__a		,       __a							)							)

											self.assertEqual(out_len + 1		,       len(__a							)							)

											__a    : Union[str, Any]      					=						outputs.attentions

											self.assertEqual(len(__a							)		,       __a							)
											# verify the first attentions (first block, first layer)
											__a    : int      					=						(self.model_tester.image_size // 4) ** 2
											__a    : Tuple      					=						(self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
											self.assertListEqual(
											    list(self_attentions[0].shape[-3:]							)		,       [self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]		,       )




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						def check_hidden_states_output(__a		,       __a		,       __a							):
											__a    : Tuple      					=						model_class(__a							)
											model.to(__a							)
											model.eval()

											with torch.no_grad():
																__a    : int      					=						model(**self._prepare_for_class(__a		,       __a							)							)

											__a    : Dict      					=						outputs.hidden_states

											__a    : Any      					=						self.model_tester.num_encoder_blocks
											self.assertEqual(len(__a							)		,       __a							)

											# verify the first hidden states (first block)
											self.assertListEqual(
											    list(hidden_states[0].shape[-3:]							)		,       [
											        self.model_tester.hidden_sizes[0],
											        self.model_tester.image_size // 4,
											        self.model_tester.image_size // 4,
											    ]		,       )

						__a					,       __a    : Dict      					=						self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
											__a    : Optional[int]      					=						True
											check_hidden_states_output(__a		,       __a		,       __a							)

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											__a    : Optional[Any]      					=						True

											check_hidden_states_output(__a		,       __a		,       __a							)




	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						if not self.model_tester.is_training:
											return

						__a					,       __a    : Tuple      					=						self.model_tester.prepare_config_and_inputs_for_common()
						__a    : str      					=						True

						for model_class in self.all_model_classes:
											if model_class in get_values(__a							):
																continue
											# TODO: remove the following 3 lines once we have a MODEL_FOR_DEPTH_ESTIMATION_MAPPING
											# this can then be incorporated into _prepare_for_class in test_modeling_common.py
											if model_class.__name__ == "GLPNForDepthEstimation":
																__a					,       __a					,       __a					,       __a    : Any      					=						inputs_dict['pixel_values'].shape
																__a    : Dict      					=						torch.zeros(
																    [self.model_tester.batch_size, height, width]		,       device=__a							).long()
											__a    : int      					=						model_class(__a							)
											model.to(__a							)
											model.train()
											__a    : Any      					=						self._prepare_for_class(__a		,       __a		,       return_labels=__a							)
											__a    : str      					=						model(**__a							).loss
											loss.backward()





	@slow
	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						for model_name in GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											__a    : str      					=						GLPNModel.from_pretrained(__a							)
											self.assertIsNotNone(__a							)






def 						lowerCamelCase							():
					__a    : str      					=						Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'     )
					return image





@require_torch
@require_vision
@slow
class 							__UpperCamelCase       (	unittest.TestCase      ):




	@slow
	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						__a    : List[str]      					=						GLPNImageProcessor.from_pretrained(GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[0]							)
						__a    : Optional[int]      					=						GLPNForDepthEstimation.from_pretrained(GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[0]							).to(__a							)

						__a    : Union[str, Any]      					=						prepare_img()
						__a    : List[str]      					=						image_processor(images=__a		,       return_tensors='pt'							).to(__a							)

						# forward pass
						with torch.no_grad():
											__a    : Optional[Any]      					=						model(**__a							)

						# verify the predicted depth
						__a    : List[str]      					=						torch.Size([1, 480, 640]							)
						self.assertEqual(outputs.predicted_depth.shape		,       __a							)

						__a    : Union[str, Any]      					=						torch.tensor(
						    [[3.4291, 2.7865, 2.5151], [3.2841, 2.7021, 2.3502], [3.1147, 2.4625, 2.2481]]							).to(__a							)

						self.assertTrue(torch.allclose(outputs.predicted_depth[0, :3, :3]		,       __a		,       atol=1E-4							)							)







'''simple docstring'''



from typing import Callable, List, Optional, Union

import torch

from ...models import UNetaDModel
from ...schedulers import CMStochasticIterativeScheduler
from ...utils import (
    is_accelerate_available,
    is_accelerate_version,
    logging,
    randn_tensor,
    replace_example_docstring,
)
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput


__lowercase			:		List[str] =			logging.get_logger(__name__)  # pylint: disable=invalid-name


__lowercase			:		Optional[int] =			'\n    Examples:\n        ```py\n        >>> import torch\n\n        >>> from diffusers import ConsistencyModelPipeline\n\n        >>> device = "cuda"\n        >>> # Load the cd_imagenet64_l2 checkpoint.\n        >>> model_id_or_path = "openai/diffusers-cd_imagenet64_l2"\n        >>> pipe = ConsistencyModelPipeline.from_pretrained(model_id_or_path, torch_dtype=torch.float16)\n        >>> pipe.to(device)\n\n        >>> # Onestep Sampling\n        >>> image = pipe(num_inference_steps=1).images[0]\n        >>> image.save("cd_imagenet64_l2_onestep_sample.png")\n\n        >>> # Onestep sampling, class-conditional image generation\n        >>> # ImageNet-64 class label 145 corresponds to king penguins\n        >>> image = pipe(num_inference_steps=1, class_labels=145).images[0]\n        >>> image.save("cd_imagenet64_l2_onestep_sample_penguin.png")\n\n        >>> # Multistep sampling, class-conditional image generation\n        >>> # Timesteps can be explicitly specified; the particular timesteps below are from the original Github repo:\n        >>> # https://github.com/openai/consistency_models/blob/main/scripts/launch.sh#L77\n        >>> image = pipe(num_inference_steps=None, timesteps=[22, 0], class_labels=145).images[0]\n        >>> image.save("cd_imagenet64_l2_multistep_sample_penguin.png")\n        ```\n'





class 							__UpperCamelCase       (	lowerCAmelCase_      ):




	def __init__(     self		,       __a		,       __a							):

						'''simple docstring'''





						super().__init__()

						self.register_modules(
						    unet=__a		,       scheduler=__a		,       )

						__a    : List[str]      					=						None




	def    __UpperCAmelCase							(     self		,       __a=0							):

						'''simple docstring'''





						if is_accelerate_available() and is_accelerate_version('>='		,       '0.14.0'							):
											from accelerate import cpu_offload
						else:
											raise ImportError('`enable_sequential_cpu_offload` requires `accelerate v0.14.0` or higher'							)

						__a    : str      					=						torch.device(f"""cuda:{gpu_id}"""							)

						if self.device.type != "cpu":
											self.to('cpu'		,       silence_dtype_warnings=__a							)
											torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

						for cpu_offloaded_model in [self.unet]:
											cpu_offload(__a		,       __a							)

						if self.safety_checker is not None:
											cpu_offload(self.safety_checker		,       execution_device=__a		,       offload_buffers=__a							)




	def    __UpperCAmelCase							(     self		,       __a=0							):

						'''simple docstring'''





						if is_accelerate_available() and is_accelerate_version('>='		,       '0.17.0.dev0'							):
											from accelerate import cpu_offload_with_hook
						else:
											raise ImportError('`enable_model_cpu_offload` requires `accelerate v0.17.0` or higher.'							)

						__a    : Tuple      					=						torch.device(f"""cuda:{gpu_id}"""							)

						if self.device.type != "cpu":
											self.to('cpu'		,       silence_dtype_warnings=__a							)
											torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

						__a    : List[Any]      					=						None
						for cpu_offloaded_model in [self.unet]:
											__a					,       __a    : List[str]      					=						cpu_offload_with_hook(__a		,       __a		,       prev_module_hook=__a							)

						if self.safety_checker is not None:
											__a					,       __a    : str      					=						cpu_offload_with_hook(self.safety_checker		,       __a		,       prev_module_hook=__a							)

						# We'll offload the last model manually.
						__a    : List[Any]      					=						hook




	@property
	# Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._execution_device
	def    __UpperCAmelCase							(     self							):

						'''simple docstring'''





						if not hasattr(self.unet		,       '_hf_hook'							):
											return self.device
						for module in self.unet.modules():
											if (
											    hasattr(__a		,       '_hf_hook'							)
											    and hasattr(module._hf_hook		,       'execution_device'							)
											    and module._hf_hook.execution_device is not None
											):
																return torch.device(module._hf_hook.execution_device							)
						return self.device




	def    __UpperCAmelCase							(     self		,       __a		,       __a		,       __a		,       __a		,       __a		,       __a		,       __a		,       __a=None							):

						'''simple docstring'''





						__a    : str      					=						(batch_size, num_channels, height, width)
						if isinstance(__a		,       __a							) and len(__a							) != batch_size:
											raise ValueError(
											    f"""You have passed a list of generators of length {len(__a							)}, but requested an effective batch"""
											    f""" size of {batch_size}. Make sure the batch size matches the length of the generators."""							)

						if latents is None:
											__a    : Optional[Any]      					=						randn_tensor(__a		,       generator=__a		,       device=__a		,       dtype=__a							)
						else:
											__a    : Dict      					=						latents.to(device=__a		,       dtype=__a							)

						# scale the initial noise by the standard deviation required by the scheduler
						__a    : Union[str, Any]      					=						latents * self.scheduler.init_noise_sigma
						return latents




	def    __UpperCAmelCase							(     self		,       __a		,       __a = "pil"							):

						'''simple docstring'''





						if output_type not in ["pt", "np", "pil"]:
											raise ValueError(
											    f"""output_type={output_type} is not supported. Make sure to choose one of ['pt', 'np', or 'pil']"""							)

						# Equivalent to diffusers.VaeImageProcessor.denormalize
						__a    : List[Any]      					=						(sample / 2 + 0.5).clamp(0		,       1							)
						if output_type == "pt":
											return sample

						# Equivalent to diffusers.VaeImageProcessor.pt_to_numpy
						__a    : str      					=						sample.cpu().permute(0		,       2		,       3		,       1							).numpy()
						if output_type == "np":
											return sample

						# Output_type must be 'pil'
						__a    : Union[str, Any]      					=						self.numpy_to_pil(__a							)
						return sample




	def    __UpperCAmelCase							(     self		,       __a		,       __a		,       __a=None							):

						'''simple docstring'''





						if self.unet.config.num_class_embeds is not None:
											if isinstance(__a		,       __a							):
																__a    : Tuple      					=						torch.tensor(__a		,       dtype=torch.int							)
											elif isinstance(__a		,       __a							):
																assert batch_size == 1, "Batch size must be 1 if classes is an int"
																__a    : int      					=						torch.tensor([class_labels]		,       dtype=torch.int							)
											elif class_labels is None:
																# Randomly generate batch_size class labels
																# TODO: should use generator here? int analogue of randn_tensor is not exposed in ...utils
																__a    : str      					=						torch.randint(0		,       self.unet.config.num_class_embeds		,       size=(batch_size,)							)
											__a    : str      					=						class_labels.to(__a							)
						else:
											__a    : Optional[int]      					=						None
						return class_labels




	def    __UpperCAmelCase							(     self		,       __a		,       __a		,       __a		,       __a		,       __a		,       __a							):

						'''simple docstring'''





						if num_inference_steps is None and timesteps is None:
											raise ValueError('Exactly one of `num_inference_steps` or `timesteps` must be supplied.'							)

						if num_inference_steps is not None and timesteps is not None:
											logger.warning(
											    f"""Both `num_inference_steps`: {num_inference_steps} and `timesteps`: {timesteps} are supplied;"""
											    ' `timesteps` will be used over `num_inference_steps`.'							)

						if latents is not None:
											__a    : Optional[Any]      					=						(batch_size, 3, img_size, img_size)
											if latents.shape != expected_shape:
																raise ValueError(f"""The shape of latents is {latents.shape} but is expected to be {expected_shape}."""							)

						if (callback_steps is None) or (
						    callback_steps is not None and (not isinstance(__a		,       __a							) or callback_steps <= 0)
						):
											raise ValueError(
											    f"""`callback_steps` has to be a positive integer but is {callback_steps} of type"""
											    f""" {type(__a							)}."""							)





	@torch.no_grad()
	@replace_example_docstring(__a							)
	def __call__(     self		,       __a = 1		,       __a = None		,       __a = 1		,       __a = None		,       __a = None		,       __a = None		,       __a = "pil"		,       __a = True		,       __a = None		,       __a = 1		,       ):

						'''simple docstring'''





						__a    : Dict      					=						self.unet.config.sample_size
						__a    : Union[str, Any]      					=						self._execution_device

						# 1. Check inputs
						self.check_inputs(__a		,       __a		,       __a		,       __a		,       __a		,       __a							)

						# 2. Prepare image latents
						# Sample image latents x_0 ~ N(0, sigma_0^2 * I)
						__a    : Union[str, Any]      					=						self.prepare_latents(
						    batch_size=__a		,       num_channels=self.unet.config.in_channels		,       height=__a		,       width=__a		,       dtype=self.unet.dtype		,       device=__a		,       generator=__a		,       latents=__a		,       )

						# 3. Handle class_labels for class-conditional models
						__a    : Optional[Any]      					=						self.prepare_class_labels(__a		,       __a		,       class_labels=__a							)

						# 4. Prepare timesteps
						if timesteps is not None:
											self.scheduler.set_timesteps(timesteps=__a		,       device=__a							)
											__a    : Union[str, Any]      					=						self.scheduler.timesteps
											__a    : Tuple      					=						len(__a							)
						else:
											self.scheduler.set_timesteps(__a							)
											__a    : Tuple      					=						self.scheduler.timesteps

						# 5. Denoising loop
						# Multistep sampling: implements Algorithm 1 in the paper
						with self.progress_bar(total=__a							) as progress_bar:
											for i, t in enumerate(__a							):
																__a    : Optional[int]      					=						self.scheduler.scale_model_input(__a		,       __a							)
																__a    : List[str]      					=						self.unet(__a		,       __a		,       class_labels=__a		,       return_dict=__a							)[0]

																__a    : int      					=						self.scheduler.step(__a		,       __a		,       __a		,       generator=__a							)[0]

																# call the callback, if provided
																progress_bar.update()
																if callback is not None and i % callback_steps == 0:
																					callback(__a		,       __a		,       __a							)

        # 6. Post-process image sample
						__a    : Tuple      					=						self.postprocess_image(__a		,       output_type=__a							)

						# Offload last model to CPU
						if hasattr(self		,       'final_offload_hook'							) and self.final_offload_hook is not None:
											self.final_offload_hook.offload()

						if not return_dict:
											return (image,)

						return ImagePipelineOutput(images=__a							)



