





"""simple docstring"""





def      UpperCAmelCase__				(    SCREAMING_SNAKE_CASE	:		float				,		SCREAMING_SNAKE_CASE	:		list[float]     ):







      '''simple docstring'''




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


if __name__ == "__main__":
       import doctest

       doctest.testmod()














from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


_UpperCamelCase			:	Any								=logging.get_logger(__name__)


if is_vision_available():
	import PIL






class 						UpperCAmelCase__ (							__snake_case							):
		__snake_case      :       Union[str, Any]     =   ["pixel_values"]







		def __init__(					self       ,A__ = True       ,A__ = None       ,A__ = PILImageResampling.BICUBIC       ,A__ = True       ,A__ = None       ,A__ = True       ,A__ = 1 / 255       ,A__ = True       ,A__ = None       ,A__ = None       ,A__ = True       ,**A__       ,):
						super().__init__(**A__		)
						_A	:				List[str]   =      size if size is not None else {'''shortest_edge''': 224}
						_A	:				int   =      get_size_dict(A__       ,default_to_square=A__		)
						_A	:				Optional[int]   =      crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
						_A	:				Dict   =      get_size_dict(A__       ,default_to_square=A__       ,param_name='''crop_size'''		)

						_A	:				List[str]   =      do_resize
						_A	:				List[str]   =      size
						_A	:				Tuple   =      resample
						_A	:				List[Any]   =      do_center_crop
						_A	:				Dict   =      crop_size
						_A	:				Any   =      do_rescale
						_A	:				Optional[Any]   =      rescale_factor
						_A	:				Dict   =      do_normalize
						_A	:				Optional[int]   =      image_mean if image_mean is not None else OPENAI_CLIP_MEAN
						_A	:				Optional[int]   =      image_std if image_std is not None else OPENAI_CLIP_STD
						_A	:				Any   =      do_convert_rgb







		def  A__      (					self       ,A__       ,A__       ,A__ = PILImageResampling.BICUBIC       ,A__ = None       ,**A__       ,):
						_A	:				List[Any]   =      get_size_dict(A__       ,default_to_square=A__		)
						if "shortest_edge" not in size:
										raise ValueError(f"""The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}"""		)
						_A	:				Any   =      get_resize_output_image_size(A__       ,size=size['''shortest_edge''']       ,default_to_square=A__		)
						return resize(A__       ,size=A__       ,resample=A__       ,data_format=A__       ,**A__		)







		def  A__      (					self       ,A__       ,A__       ,A__ = None       ,**A__       ,):
						_A	:				Union[str, Any]   =      get_size_dict(A__		)
						if "height" not in size or "width" not in size:
										raise ValueError(f"""The `size` parameter must contain the keys (height, width). Got {size.keys()}"""		)
						return center_crop(A__       ,size=(size['''height'''], size['''width'''])       ,data_format=A__       ,**A__		)







		def  A__      (					self       ,A__       ,A__       ,A__ = None       ,**A__       ,):
						return rescale(A__       ,scale=A__       ,data_format=A__       ,**A__		)







		def  A__      (					self       ,A__       ,A__       ,A__       ,A__ = None       ,**A__       ,):
						return normalize(A__       ,mean=A__       ,std=A__       ,data_format=A__       ,**A__		)







		def  A__      (					self       ,A__       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = None       ,A__ = ChannelDimension.FIRST       ,**A__       ,):
						_A	:				str   =      do_resize if do_resize is not None else self.do_resize
						_A	:				List[str]   =      size if size is not None else self.size
						_A	:				List[str]   =      get_size_dict(A__       ,param_name='''size'''       ,default_to_square=A__		)
						_A	:				Optional[Any]   =      resample if resample is not None else self.resample
						_A	:				int   =      do_center_crop if do_center_crop is not None else self.do_center_crop
						_A	:				Any   =      crop_size if crop_size is not None else self.crop_size
						_A	:				int   =      get_size_dict(A__       ,param_name='''crop_size'''       ,default_to_square=A__		)
						_A	:				int   =      do_rescale if do_rescale is not None else self.do_rescale
						_A	:				List[str]   =      rescale_factor if rescale_factor is not None else self.rescale_factor
						_A	:				Tuple   =      do_normalize if do_normalize is not None else self.do_normalize
						_A	:				Union[str, Any]   =      image_mean if image_mean is not None else self.image_mean
						_A	:				int   =      image_std if image_std is not None else self.image_std
						_A	:				Optional[Any]   =      do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

						_A	:				Optional[Any]   =      make_list_of_images(A__		)

						if not valid_images(A__		):
										raise ValueError(
										    '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
										    '''torch.Tensor, tf.Tensor or jax.ndarray.'''		)

						if do_resize and size is None:
										raise ValueError('''Size must be specified if do_resize is True.'''		)

						if do_center_crop and crop_size is None:
										raise ValueError('''Crop size must be specified if do_center_crop is True.'''		)

						if do_rescale and rescale_factor is None:
										raise ValueError('''Rescale factor must be specified if do_rescale is True.'''		)

						if do_normalize and (image_mean is None or image_std is None):
										raise ValueError('''Image mean and std must be specified if do_normalize is True.'''		)

						# PIL RGBA images are converted to RGB
						if do_convert_rgb:
										_A	:				int   =      [convert_to_rgb(A__		) for image in images]

						# All transformations expect numpy arrays.
						_A	:				int   =      [to_numpy_array(A__		) for image in images]

						if do_resize:
										_A	:				List[str]   =      [self.resize(image=A__       ,size=A__       ,resample=A__		) for image in images]

						if do_center_crop:
										_A	:				Union[str, Any]   =      [self.center_crop(image=A__       ,size=A__		) for image in images]

						if do_rescale:
										_A	:				Tuple   =      [self.rescale(image=A__       ,scale=A__		) for image in images]

						if do_normalize:
										_A	:				Dict   =      [self.normalize(image=A__       ,mean=A__       ,std=A__		) for image in images]

						_A	:				Dict   =      [to_channel_dimension_format(A__       ,A__		) for image in images]

						_A	:				Dict   =      {'''pixel_values''': images}
						return BatchFeature(data=A__       ,tensor_type=A__		)



