




import numpy as np

class 						__lowerCAmelCase      :
							def __init__(		self		:str						, __magic_name__		:Union[str, Any]=None						, __magic_name__		:Union[str, Any]=None						, __magic_name__		:str=None						, __magic_name__		:Dict=None						, __magic_name__		:List[Any]=None							):







								'''simple docstring'''







								self.set_matricies(red=_SCREAMING_SNAKE_CASE						, green=_SCREAMING_SNAKE_CASE						, blue=_SCREAMING_SNAKE_CASE						, red_edge=_SCREAMING_SNAKE_CASE						, nir=_SCREAMING_SNAKE_CASE							)
							def  lowerCamelCase__				(		self		:str						, __magic_name__		:Any=None						, __magic_name__		:Optional[int]=None						, __magic_name__		:Any=None						, __magic_name__		:List[str]=None						, __magic_name__		:List[Any]=None							):







								'''simple docstring'''







								if red is not None:
									a									=				red
								if green is not None:
									a									=				green
								if blue is not None:
									a									=				blue
								if red_edge is not None:
									a									=				red_edge
								if nir is not None:
									a									=				nir
								return True
							def  lowerCamelCase__				(		self		:int						, __magic_name__		:str=""						, __magic_name__		:List[Any]=None						, __magic_name__		:List[Any]=None						, __magic_name__		:Union[str, Any]=None						, __magic_name__		:Optional[int]=None						, __magic_name__		:List[Any]=None							):







								'''simple docstring'''







								self.set_matricies(red=_SCREAMING_SNAKE_CASE						, green=_SCREAMING_SNAKE_CASE						, blue=_SCREAMING_SNAKE_CASE						, red_edge=_SCREAMING_SNAKE_CASE						, nir=_SCREAMING_SNAKE_CASE							)
								a									=				{
								    'ARVI2': self.arvaa,
								    'CCCI': self.ccci,
								    'CVI': self.cvi,
								    'GLI': self.gli,
								    'NDVI': self.ndvi,
								    'BNDVI': self.bndvi,
								    'redEdgeNDVI': self.red_edge_ndvi,
								    'GNDVI': self.gndvi,
								    'GBNDVI': self.gbndvi,
								    'GRNDVI': self.grndvi,
								    'RBNDVI': self.rbndvi,
								    'PNDVI': self.pndvi,
								    'ATSAVI': self.atsavi,
								    'BWDRVI': self.bwdrvi,
								    'CIgreen': self.ci_green,
								    'CIrededge': self.ci_rededge,
								    'CI': self.ci,
								    'CTVI': self.ctvi,
								    'GDVI': self.gdvi,
								    'EVI': self.evi,
								    'GEMI': self.gemi,
								    'GOSAVI': self.gosavi,
								    'GSAVI': self.gsavi,
								    'Hue': self.hue,
								    'IVI': self.ivi,
								    'IPVI': self.ipvi,
								    'I': self.i,
								    'RVI': self.rvi,
								    'MRVI': self.mrvi,
								    'MSAVI': self.m_savi,
								    'NormG': self.norm_g,
								    'NormNIR': self.norm_nir,
								    'NormR': self.norm_r,
								    'NGRDI': self.ngrdi,
								    'RI': self.ri,
								    'S': self.s,
								    'IF': self._if,
								    'DVI': self.dvi,
								    'TVI': self.tvi,
								    'NDRE': self.ndre,
								}

								try:
									return funcs[index]()
								except KeyError:
									print("""Index not in the list!"""							)
									return False
							def  lowerCamelCase__				(		self		:Optional[Any]							):







								'''simple docstring'''







								return -0.18 + (1.17 * ((self.nir - self.red) / (self.nir + self.red)))
							def  lowerCamelCase__				(		self		:Dict							):







								'''simple docstring'''







								return ((self.nir - self.redEdge) / (self.nir + self.redEdge)) / (
								    (self.nir - self.red) / (self.nir + self.red)
								)
							def  lowerCamelCase__				(		self		:Union[str, Any]							):







								'''simple docstring'''







								return self.nir * (self.red / (self.green**2))
							def  lowerCamelCase__				(		self		:Dict							):







								'''simple docstring'''







								return (2 * self.green - self.red - self.blue) / (
								    2 * self.green + self.red + self.blue
								)
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return (self.nir - self.red) / (self.nir + self.red)
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return (self.nir - self.blue) / (self.nir + self.blue)
							def  lowerCamelCase__				(		self		:Any							):







								'''simple docstring'''







								return (self.redEdge - self.red) / (self.redEdge + self.red)
							def  lowerCamelCase__				(		self		:str							):







								'''simple docstring'''







								return (self.nir - self.green) / (self.nir + self.green)
							def  lowerCamelCase__				(		self		:Any							):







								'''simple docstring'''







								return (self.nir - (self.green + self.blue)) / (
								    self.nir + (self.green + self.blue)
								)
							def  lowerCamelCase__				(		self		:str							):







								'''simple docstring'''







								return (self.nir - (self.green + self.red)) / (
								    self.nir + (self.green + self.red)
								)
							def  lowerCamelCase__				(		self		:Optional[Any]							):







								'''simple docstring'''







								return (self.nir - (self.blue + self.red)) / (self.nir + (self.blue + self.red))
							def  lowerCamelCase__				(		self		:Optional[Any]							):







								'''simple docstring'''







								return (self.nir - (self.green + self.red + self.blue)) / (
								    self.nir + (self.green + self.red + self.blue)
								)
							def  lowerCamelCase__				(		self		:List[str]						, __magic_name__		:Union[str, Any]=0.08						, __magic_name__		:Optional[Any]=1.22						, __magic_name__		:Union[str, Any]=0.03							):







								'''simple docstring'''







								return a * (
								    (self.nir - a * self.red - b)
								    / (a * self.nir + self.red - a * b + x * (1 + a**2))
								)
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								return (0.1 * self.nir - self.blue) / (0.1 * self.nir + self.blue)
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								return (self.nir / self.green) - 1
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return (self.nir / self.redEdge) - 1
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return (self.red - self.blue) / self.red
							def  lowerCamelCase__				(		self		:Dict							):







								'''simple docstring'''







								a									=				self.ndvi()
								return ((ndvi + 0.5) / (abs(ndvi + 0.5							))) * (abs(ndvi + 0.5							) ** (1 / 2))
							def  lowerCamelCase__				(		self		:Optional[Any]							):







								'''simple docstring'''







								return self.nir - self.green
							def  lowerCamelCase__				(		self		:Any							):







								'''simple docstring'''







								return 2.5 * (
								    (self.nir - self.red) / (self.nir + 6 * self.red - 7.5 * self.blue + 1)
								)
							def  lowerCamelCase__				(		self		:List[str]							):







								'''simple docstring'''







								a									=				(2 * (self.nir**2 - self.red**2) + 1.5 * self.nir + 0.5 * self.red) / (
								    self.nir + self.red + 0.5
								)
								return n * (1 - 0.25 * n) - (self.red - 0.125) / (1 - self.red)
							def  lowerCamelCase__				(		self		:List[str]						, __magic_name__		:Optional[int]=0.16							):







								'''simple docstring'''







								return (self.nir - self.green) / (self.nir + self.green + y)
							def  lowerCamelCase__				(		self		:str						, __magic_name__		:int=0.5							):







								'''simple docstring'''







								return ((self.nir - self.green) / (self.nir + self.green + n)) * (1 + n)
							def  lowerCamelCase__				(		self		:Union[str, Any]							):







								'''simple docstring'''







								return np.arctan(
								    ((2 * self.red - self.green - self.blue) / 30.5) * (self.green - self.blue)							)
							def  lowerCamelCase__				(		self		:Dict						, __magic_name__		:Tuple=None						, __magic_name__		:str=None							):







								'''simple docstring'''







								return (self.nir - b) / (a * self.red)
							def  lowerCamelCase__				(		self		:int							):







								'''simple docstring'''







								return (self.nir / ((self.nir + self.red) / 2)) * (self.ndvi() + 1)
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return (self.red + self.green + self.blue) / 30.5
							def  lowerCamelCase__				(		self		:Optional[int]							):







								'''simple docstring'''







								return self.nir / self.red
							def  lowerCamelCase__				(		self		:Union[str, Any]							):







								'''simple docstring'''







								return (self.rvi() - 1) / (self.rvi() + 1)
							def  lowerCamelCase__				(		self		:Any							):







								'''simple docstring'''







								return (
								    (2 * self.nir + 1)
								    - ((2 * self.nir + 1) ** 2 - 8 * (self.nir - self.red)) ** (1 / 2)
								) / 2
							def  lowerCamelCase__				(		self		:Optional[int]							):







								'''simple docstring'''







								return self.green / (self.nir + self.red + self.green)
							def  lowerCamelCase__				(		self		:Tuple							):







								'''simple docstring'''







								return self.nir / (self.nir + self.red + self.green)
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								return self.red / (self.nir + self.red + self.green)
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								return (self.green - self.red) / (self.green + self.red)
							def  lowerCamelCase__				(		self		:Dict							):







								'''simple docstring'''







								return (self.red - self.green) / (self.red + self.green)
							def  lowerCamelCase__				(		self		:List[Any]							):







								'''simple docstring'''







								a									=				np.max([np.max(self.red							), np.max(self.green							), np.max(self.blue							)]							)
								a									=				np.min([np.min(self.red							), np.min(self.green							), np.min(self.blue							)]							)
								return (max_value - min_value) / max_value
							def  lowerCamelCase__				(		self		:Optional[int]							):







								'''simple docstring'''







								return (2 * self.red - self.green - self.blue) / (self.green - self.blue)
							def  lowerCamelCase__				(		self		:Optional[int]							):







								'''simple docstring'''







								return self.nir / self.red
							def  lowerCamelCase__				(		self		:Union[str, Any]							):







								'''simple docstring'''







								return (self.ndvi() + 0.5) ** (1 / 2)





							def  lowerCamelCase__				(		self		:List[str]							):







								'''simple docstring'''







								return (self.nir - self.redEdge) / (self.nir + self.redEdge)






"""simple docstring"""

import gc
import unittest

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()
@slow
@require_torch_gpu
class     lowerCAmelCase__						(	unittest.TestCase ):


	'''simple docstring'''







	def 			_lowerCAmelCase     (      self				:       List[Any]    )						->	str:





					"""simple docstring"""


					super().tearDown()
					gc.collect()
					torch.cuda.empty_cache()





	def 			_lowerCAmelCase     (      self				:       Any    )						->	str:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							int							=     StableDiffusionKDiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4'    )
					SCREAMING_SNAKE_CASE						:							Dict							=     sd_pipe.to(_SCREAMING_SNAKE_CASE    )
					sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					sd_pipe.set_scheduler('sample_euler'    )

					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     'A painting of a squirrel eating a burger'
					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     torch.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     sd_pipe([prompt]     ,       generator=_SCREAMING_SNAKE_CASE     ,       guidance_scale=9.0     ,       num_inference_steps=20     ,       output_type='np'    )

					SCREAMING_SNAKE_CASE						:							str							=     output.images

					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     image[0, -3:, -3:, -1]

					assert image.shape == (1, 512, 512, 3)
					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     np.array([0.0_4_4_7, 0.0_4_9_2, 0.0_4_6_8, 0.0_4_0_8, 0.0_3_8_3, 0.0_4_0_8, 0.0_3_5_4, 0.0_3_8_0, 0.0_3_3_9]    )

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





	def 			_lowerCAmelCase     (      self				:       Dict    )						->	Optional[int]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'    )
					SCREAMING_SNAKE_CASE						:							List[Any]							=     sd_pipe.to(_SCREAMING_SNAKE_CASE    )
					sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					sd_pipe.set_scheduler('sample_euler'    )

					SCREAMING_SNAKE_CASE						:							List[str]							=     'A painting of a squirrel eating a burger'
					SCREAMING_SNAKE_CASE						:							Optional[int]							=     torch.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							Dict							=     sd_pipe([prompt]     ,       generator=_SCREAMING_SNAKE_CASE     ,       guidance_scale=9.0     ,       num_inference_steps=20     ,       output_type='np'    )

					SCREAMING_SNAKE_CASE						:							Optional[int]							=     output.images

					SCREAMING_SNAKE_CASE						:							List[str]							=     image[0, -3:, -3:, -1]

					assert image.shape == (1, 512, 512, 3)
					SCREAMING_SNAKE_CASE						:							List[Any]							=     np.array([0.1_2_3_7, 0.1_3_2_0, 0.1_4_3_8, 0.1_3_5_9, 0.1_3_9_0, 0.1_1_3_2, 0.1_2_7_7, 0.1_1_7_5, 0.1_1_1_2]    )

					assert np.abs(image_slice.flatten() - expected_slice    ).max() < 5E-1







	def 			_lowerCAmelCase     (      self				:       Dict    )						->	Optional[Any]:





					"""simple docstring"""


					SCREAMING_SNAKE_CASE						:							Optional[int]							=     StableDiffusionKDiffusionPipeline.from_pretrained('stabilityai/stable-diffusion-2-1-base'    )
					SCREAMING_SNAKE_CASE						:							Union[str, Any]							=     sd_pipe.to(_SCREAMING_SNAKE_CASE    )
					sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE    )

					sd_pipe.set_scheduler('sample_dpmpp_2m'    )

					SCREAMING_SNAKE_CASE						:							Optional[int]							=     'A painting of a squirrel eating a burger'
					SCREAMING_SNAKE_CASE						:							str							=     torch.manual_seed(0    )
					SCREAMING_SNAKE_CASE						:							Optional[Any]							=     sd_pipe(
					    [prompt]     ,       generator=_SCREAMING_SNAKE_CASE     ,       guidance_scale=7.5     ,       num_inference_steps=15     ,       output_type='np'     ,       use_karras_sigmas=_SCREAMING_SNAKE_CASE     ,       )

					SCREAMING_SNAKE_CASE						:							int							=     output.images

					SCREAMING_SNAKE_CASE						:							List[Any]							=     image[0, -3:, -3:, -1]

					assert image.shape == (1, 512, 512, 3)
					SCREAMING_SNAKE_CASE						:							int							=     np.array(
					    [0.1_1_3_8_1_6_8_9, 0.1_2_1_1_2_9_2_1, 0.1_3_8_9_4_5_7, 0.1_2_5_4_9_6_0_6, 0.1_2_4_4_9_6_4, 0.1_0_8_3_1_5_1_7, 0.1_1_5_6_2_8_6_6, 0.1_0_8_6_7_8_1_6, 0.1_0_4_9_9_0_4_8]    )

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





