
"""simple docstring"""







import unittest

import torch

from diffusers import VQModel
from diffusers.utils import floats_tensor, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin, UNetTesterMixin


enable_full_determinism()




class 			A__	(     _lowerCamelCase	,					_lowerCamelCase	,					unittest.TestCase):
		A_						:	Tuple           =     VQModel
		A_						:	List[str]           =     'sample'

		@property
		def 							__lowerCamelCase							(				self	,		_SCREAMING_SNAKE_CASE=(32, 32)			):
			__lowerCAmelCase      :						int						      =				4
			__lowerCAmelCase      :						Tuple						      =				3

			__lowerCAmelCase      :						str						      =				floats_tensor((batch_size, num_channels) + sizes			).to(_SCREAMING_SNAKE_CASE			)

			return {"sample": image}

		@property
		def 							__lowerCamelCase							(				self			):
			return (3, 32, 32)

		@property
		def 							__lowerCamelCase							(				self			):
			return (3, 32, 32)

		def 							__lowerCamelCase							(				self			):
			__lowerCAmelCase      :						List[Any]						      =				{
			    'block_out_channels': [32, 64],
			    'in_channels': 3,
			    'out_channels': 3,
			    'down_block_types': ['DownEncoderBlock2D', 'DownEncoderBlock2D'],
			    'up_block_types': ['UpDecoderBlock2D', 'UpDecoderBlock2D'],
			    'latent_channels': 3,
			}
			__lowerCAmelCase      :						Any						      =				self.dummy_input
			return init_dict, inputs_dict

		def 							__lowerCamelCase							(				self			):
			pass

		def 							__lowerCamelCase							(				self			):
			pass

		def 							__lowerCamelCase							(				self			):
			__lowerCAmelCase      ,       __lowerCAmelCase      :						Any						      =				VQModel.from_pretrained('fusing/vqgan-dummy'	,		output_loading_info=_SCREAMING_SNAKE_CASE			)
			self.assertIsNotNone(_SCREAMING_SNAKE_CASE			)
			self.assertEqual(len(loading_info['missing_keys']			)	,		0			)

			model.to(_SCREAMING_SNAKE_CASE			)
			__lowerCAmelCase      :						Any						      =				model(**self.dummy_input			)

			assert image is not None, "Make sure output is not None"







		def 							__lowerCamelCase							(				self			):
			__lowerCAmelCase      :						Any						      =				VQModel.from_pretrained('fusing/vqgan-dummy'			)
			model.to(_SCREAMING_SNAKE_CASE			).eval()

			torch.manual_seed(0			)
			if torch.cuda.is_available():
				torch.cuda.manual_seed_all(0			)

			__lowerCAmelCase      :						Optional[int]						      =				torch.randn(1	,		model.config.in_channels	,		model.config.sample_size	,		model.config.sample_size			)
			__lowerCAmelCase      :						List[str]						      =				image.to(_SCREAMING_SNAKE_CASE			)
			with torch.no_grad():
				__lowerCAmelCase      :						List[str]						      =				model(_SCREAMING_SNAKE_CASE			).sample

			__lowerCAmelCase      :						str						      =				output[0, -1, -3:, -3:].flatten().cpu()
			# fmt: off
			__lowerCAmelCase      :						List[str]						      =				torch.tensor([-0.0153, -0.4044, -0.1880, -0.5161, -0.2418, -0.4072, -0.1612, -0.0633, -0.0143]			)
			# fmt: on
			self.assertTrue(torch.allclose(_SCREAMING_SNAKE_CASE	,		_SCREAMING_SNAKE_CASE	,		atol=1E-3			)			)

"""simple docstring"""







# NOTE: This file is deprecated and will be removed in a future version.
# It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works

from ...utils import deprecate
from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline  # noqa: F401


deprecate(
    """stable diffusion controlnet""",
    """0.22.0""",
    """Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diffusion.flax_pipeline_stable_diffusion_controlnet is deprecated. Please import `from diffusers import FlaxStableDiffusionControlNetPipeline` instead.""",
    standard_warn=False,
    stacklevel=3,
)