





import unittest
from dataclasses import dataclass
from typing import List, Union

import numpy as np
import PIL.Image

from diffusers.utils.outputs import BaseOutput

@dataclass
class    __A  (    a     ):
				__A  =					42




class    __A  (    unittest.TestCase     ):


				def _snake_case							(		self				):
								lowerCamelCase									=CustomOutput(images=np.random.rand(1 ,			3 ,			4 ,			4				)				)

								# check every way of getting the attribute
								assert isinstance(outputs.images ,			np.ndarray				)
								assert outputs.images.shape == (1, 3, 4, 4)
								assert isinstance(outputs["""images"""] ,			np.ndarray				)
								assert outputs["images"].shape == (1, 3, 4, 4)
								assert isinstance(outputs[0] ,			np.ndarray				)
								assert outputs[0].shape == (1, 3, 4, 4)

								# test with a non-tensor attribute
								lowerCamelCase									=CustomOutput(images=[PIL.Image.new("""RGB""" ,			(4, 4)				)]				)

								# check every way of getting the attribute
								assert isinstance(outputs.images ,			UpperCAmelCase_				)
								assert isinstance(outputs.images[0] ,			PIL.Image.Image				)
								assert isinstance(outputs["""images"""] ,			UpperCAmelCase_				)
								assert isinstance(outputs["""images"""][0] ,			PIL.Image.Image				)
								assert isinstance(outputs[0] ,			UpperCAmelCase_				)
								assert isinstance(outputs[0][0] ,			PIL.Image.Image				)


				def _snake_case							(		self				):
								# test output reinitialization with a `dict` for compatibility with `accelerate`
								lowerCamelCase									=CustomOutput({"""images""": np.random.rand(1 ,			3 ,			4 ,			4				)}				)

								# check every way of getting the attribute
								assert isinstance(outputs.images ,			np.ndarray				)
								assert outputs.images.shape == (1, 3, 4, 4)
								assert isinstance(outputs["""images"""] ,			np.ndarray				)
								assert outputs["images"].shape == (1, 3, 4, 4)
								assert isinstance(outputs[0] ,			np.ndarray				)
								assert outputs[0].shape == (1, 3, 4, 4)

								# test with a non-tensor attribute
								lowerCamelCase									=CustomOutput({"""images""": [PIL.Image.new("""RGB""" ,			(4, 4)				)]}				)

								# check every way of getting the attribute
								assert isinstance(outputs.images ,			UpperCAmelCase_				)
								assert isinstance(outputs.images[0] ,			PIL.Image.Image				)
								assert isinstance(outputs["""images"""] ,			UpperCAmelCase_				)
								assert isinstance(outputs["""images"""][0] ,			PIL.Image.Image				)
								assert isinstance(outputs[0] ,			UpperCAmelCase_				)
								assert isinstance(outputs[0][0] ,			PIL.Image.Image				)












def   _lowercase       (    _UpperCAmelCase					)    ->	bool:
				if not isinstance(_UpperCAmelCase      ,   _UpperCAmelCase					):
								lowerCamelCase									=F"""Input value of [number={number}] must be an integer"""
								raise TypeError(_UpperCAmelCase					)
				if number < 0 or number % 2 == 1:
								return False
				lowerCamelCase									=int(number**0.5					)
				return number == number_sqrt * (number_sqrt + 1)


if __name__ == "__main__":
							import doctest

							doctest.testmod()





