
def 			_a		(	_SCREAMING_SNAKE_CASE		:   float	,			_SCREAMING_SNAKE_CASE		:   list[float]  ):
						if discount_rate < 0:
												raise ValueError("Discount rate cannot be negative"  )
						if not cash_flows:
												raise ValueError("Cash flows list cannot be empty"  )
						_SCREAMING_SNAKE_CASE				= sum(
						    cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_SCREAMING_SNAKE_CASE  )  )
						return round(_SCREAMING_SNAKE_CASE	,			ndigits=2  )


if __name__ == "__main__":
						import doctest

						doctest.testmod()

'''simple docstring'''







import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
						import torch

if is_vision_available():
						from PIL import Image

						from transformers import GLPNImageProcessor


class 			lowerCAmelCase (				unittest.TestCase			):




		def __init__(				self					,						UpperCamelCase					,						UpperCamelCase=7					,						UpperCamelCase=3					,						UpperCamelCase=18					,						UpperCamelCase=30					,						UpperCamelCase=400					,						UpperCamelCase=True					,						UpperCamelCase=32					,						UpperCamelCase=True					,						):
								_SCREAMING_SNAKE_CASE				= parent
								_SCREAMING_SNAKE_CASE				= batch_size
								_SCREAMING_SNAKE_CASE				= num_channels
								_SCREAMING_SNAKE_CASE				= image_size
								_SCREAMING_SNAKE_CASE				= min_resolution
								_SCREAMING_SNAKE_CASE				= max_resolution
								_SCREAMING_SNAKE_CASE				= do_resize
								_SCREAMING_SNAKE_CASE				= size_divisor
								_SCREAMING_SNAKE_CASE				= do_rescale




		def     lowercase       (				self      ):
								return {
								    "do_resize": self.do_resize,
								    "size_divisor": self.size_divisor,
								    "do_rescale": self.do_rescale,
								}


@require_torch
@require_vision
class 			lowerCAmelCase (				__UpperCAmelCase		,     unittest.TestCase			):
		a							:					Dict       =					GLPNImageProcessor if is_vision_available() else None




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= GLPNImageProcessingTester(self      )




		@property
		def     lowercase       (				self      ):
								return self.image_processor_tester.prepare_image_processor_dict()




		def     lowercase       (				self      ):
								_SCREAMING_SNAKE_CASE				= self.image_processing_class(**self.image_processor_dict      )
								self.assertTrue(hasattr(UpperCamelCase					,						"do_resize"      )      )
								self.assertTrue(hasattr(UpperCamelCase					,						"size_divisor"      )      )
								self.assertTrue(hasattr(UpperCamelCase					,						"resample"      )      )
								self.assertTrue(hasattr(UpperCamelCase					,						"do_rescale"      )      )




		def     lowercase       (				self      ):
								pass




		def     lowercase       (				self      ):
								# Initialize image_processing
								_SCREAMING_SNAKE_CASE				= self.image_processing_class(**self.image_processor_dict      )
								# create random PIL images
								_SCREAMING_SNAKE_CASE				= prepare_image_inputs(self.image_processor_tester					,						equal_resolution=UpperCamelCase      )
								for image in image_inputs:
														self.assertIsInstance(UpperCamelCase					,						Image.Image      )

								# Test not batched input (GLPNImageProcessor doesn't support batching)
								_SCREAMING_SNAKE_CASE				= image_processing(image_inputs[0]					,						return_tensors="pt"      ).pixel_values
								self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
								self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )




		def     lowercase       (				self      ):
								# Initialize image_processing
								_SCREAMING_SNAKE_CASE				= self.image_processing_class(**self.image_processor_dict      )
								# create random numpy tensors
								_SCREAMING_SNAKE_CASE				= prepare_image_inputs(self.image_processor_tester					,						equal_resolution=UpperCamelCase					,						numpify=UpperCamelCase      )
								for image in image_inputs:
														self.assertIsInstance(UpperCamelCase					,						np.ndarray      )

								# Test not batched input (GLPNImageProcessor doesn't support batching)
								_SCREAMING_SNAKE_CASE				= image_processing(image_inputs[0]					,						return_tensors="pt"      ).pixel_values
								self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
								self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )




		def     lowercase       (				self      ):
								# Initialize image_processing
								_SCREAMING_SNAKE_CASE				= self.image_processing_class(**self.image_processor_dict      )
								# create random PyTorch tensors
								_SCREAMING_SNAKE_CASE				= prepare_image_inputs(self.image_processor_tester					,						equal_resolution=UpperCamelCase					,						torchify=UpperCamelCase      )
								for image in image_inputs:
														self.assertIsInstance(UpperCamelCase					,						torch.Tensor      )

								# Test not batched input (GLPNImageProcessor doesn't support batching)
								_SCREAMING_SNAKE_CASE				= image_processing(image_inputs[0]					,						return_tensors="pt"      ).pixel_values
								self.assertTrue(encoded_images.shape[-1] % self.image_processor_tester.size_divisor == 0      )
								self.assertTrue(encoded_images.shape[-2] % self.image_processor_tester.size_divisor == 0      )