






import PIL.Image
import PIL.ImageOps
from packaging import version
from PIL import Image


if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""):
	__lowerCamelCase :      List[Any]										=				{
	    """linear""": PIL.Image.Resampling.BILINEAR,
	    """bilinear""": PIL.Image.Resampling.BILINEAR,
	    """bicubic""": PIL.Image.Resampling.BICUBIC,
	    """lanczos""": PIL.Image.Resampling.LANCZOS,
	    """nearest""": PIL.Image.Resampling.NEAREST,
	}
else:
	__lowerCamelCase :      int										=				{
	    """linear""": PIL.Image.LINEAR,
	    """bilinear""": PIL.Image.BILINEAR,
	    """bicubic""": PIL.Image.BICUBIC,
	    """lanczos""": PIL.Image.LANCZOS,
	    """nearest""": PIL.Image.NEAREST,
	}







def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							str       ):
	snake_case__			:				str       =  (images / 2 + 0.5).clamp(0					,  1       )
	snake_case__			:				Any       =  images.cpu().permute(0					,  2					,  3					,  1       ).float().numpy()
	snake_case__			:				List[Any]       =  numpy_to_pil(snake_case_       )
	return images







def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							Any       ):
	if images.ndim == 3:
		snake_case__			:				Optional[int]       =  images[None, ...]
	snake_case__			:				Optional[int]       =  (images * 255).round().astype("uint8"       )
	if images.shape[-1] == 1:
		# special case for grayscale (single channel) images
		snake_case__			:				Dict       =  [Image.fromarray(image.squeeze()					,  mode="L"       ) for image in images]
	else:
		snake_case__			:				List[str]       =  [Image.fromarray(snake_case_       ) for image in images]

	return pil_images











from __future__ import annotations







def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							float					,  snake_case_ :							float					,  snake_case_ :							float       ):
	if days_between_payments <= 0:
		raise ValueError("days_between_payments must be > 0"       )
	if daily_interest_rate < 0:
		raise ValueError("daily_interest_rate must be >= 0"       )
	if principal <= 0:
		raise ValueError("principal must be > 0"       )
	return principal * daily_interest_rate * days_between_payments







def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							float					,  snake_case_ :							float					,  snake_case_ :							float					,  ):
	if number_of_compounding_periods <= 0:
		raise ValueError("number_of_compounding_periods must be > 0"       )
	if nominal_annual_interest_rate_percentage < 0:
		raise ValueError("nominal_annual_interest_rate_percentage must be >= 0"       )
	if principal <= 0:
		raise ValueError("principal must be > 0"       )

	return principal * (
	    (1 + nominal_annual_interest_rate_percentage) ** number_of_compounding_periods
	    - 1
	)







def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							float					,  snake_case_ :							float					,  snake_case_ :							float					,  ):
	if number_of_years <= 0:
		raise ValueError("number_of_years must be > 0"       )
	if nominal_annual_percentage_rate < 0:
		raise ValueError("nominal_annual_percentage_rate must be >= 0"       )
	if principal <= 0:
		raise ValueError("principal must be > 0"       )

	return compound_interest(
	    snake_case_					,  nominal_annual_percentage_rate / 365					,  number_of_years * 365       )


if __name__ == "__main__":
	import doctest

	doctest.testmod()



