


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,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
						import PIL


snake_case							: List[str]      =   logging.get_logger(__name__)






def 							__lowercase     (				__lowerCAmelCase							:       List[Any]     ):
							if isinstance(__lowerCAmelCase      ,					(list, tuple)     ) and isinstance(videos[0]      ,					(list, tuple)     ) and is_valid_image(videos[0][0]     ):
														return videos

							elif isinstance(__lowerCAmelCase      ,					(list, tuple)     ) and is_valid_image(videos[0]     ):
														return [videos]

							elif is_valid_image(__lowerCAmelCase     ):
														return [[videos]]

							raise ValueError(F'Could not make batched video from {videos}'     )







class  snake_case_     (snake_case__   ):
					UpperCAmelCase__      :					Dict					   =    ['''pixel_values''']
					def __init__(   self     :Any    ,__snake_case     :Any = True    ,__snake_case     :Optional[Any] = None    ,__snake_case     :Tuple = PILImageResampling.BILINEAR    ,__snake_case     :str = True    ,__snake_case     :Optional[int] = None    ,__snake_case     :Optional[Any] = True    ,__snake_case     :Tuple = 1 / 2_55    ,__snake_case     :Tuple = True    ,__snake_case     :Union[str, Any] = None    ,__snake_case     :Dict = None    ,**__snake_case     :Optional[int]    ,)      ->					Tuple:
												super().__init__(**_A   )
												a__    =  size if size is not None else {'shortest_edge': 2_24}
												a__    =  get_size_dict(_A    ,default_to_square=_A   )
												a__    =  crop_size if crop_size is not None else {'height': 2_24, 'width': 2_24}
												a__    =  get_size_dict(_A    ,param_name='crop_size'   )

												a__    =  do_resize
												a__    =  size
												a__    =  do_center_crop
												a__    =  crop_size
												a__    =  resample
												a__    =  do_rescale
												a__    =  rescale_factor
												a__    =  do_normalize
												a__    =  image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
												a__    =  image_std if image_std is not None else IMAGENET_STANDARD_STD
					def 				lowerCamelCase__(   self     :Union[str, Any]    ,__snake_case     :Union[str, Any]    ,__snake_case     :str    ,__snake_case     :int = PILImageResampling.BILINEAR    ,__snake_case     :Optional[int] = None    ,**__snake_case     :List[Any]    ,)      ->					Any:
												a__    =  get_size_dict(_A    ,default_to_square=_A   )
												if "shortest_edge" in size:
																			a__    =  get_resize_output_image_size(_A    ,size['shortest_edge']    ,default_to_square=_A   )
												elif "height" in size and "width" in size:
																			a__    =  (size['height'], size['width'])
												else:
																			raise ValueError(F'Size must have \'height\' and \'width\' or \'shortest_edge\' as keys. Got {size.keys()}'   )
												return resize(_A    ,size=_A    ,resample=_A    ,data_format=_A    ,**_A   )
					def 				lowerCamelCase__(   self     :List[Any]    ,__snake_case     :int    ,__snake_case     :Dict    ,__snake_case     :int = None    ,**__snake_case     :Union[str, Any]    ,)      ->					List[Any]:
												a__    =  get_size_dict(_A   )
												if "height" not in size or "width" not in size:
																			raise ValueError(F'Size must have \'height\' and \'width\' as keys. Got {size.keys()}'   )
												return center_crop(_A    ,size=(size['height'], size['width'])    ,data_format=_A    ,**_A   )
					def 				lowerCamelCase__(   self     :Dict    ,__snake_case     :Any    ,__snake_case     :List[str]    ,__snake_case     :List[str] = None    ,**__snake_case     :Optional[Any]    ,)      ->					Tuple:
												return rescale(_A    ,scale=_A    ,data_format=_A    ,**_A   )
					def 				lowerCamelCase__(   self     :int    ,__snake_case     :List[str]    ,__snake_case     :List[str]    ,__snake_case     :str    ,__snake_case     :Tuple = None    ,**__snake_case     :List[str]    ,)      ->					Union[str, Any]:
												return normalize(_A    ,mean=_A    ,std=_A    ,data_format=_A    ,**_A   )
					def 				lowerCamelCase__(   self     :Tuple    ,__snake_case     :int    ,__snake_case     :Any = None    ,__snake_case     :str = None    ,__snake_case     :List[Any] = None    ,__snake_case     :List[Any] = None    ,__snake_case     :Dict = None    ,__snake_case     :Optional[Any] = None    ,__snake_case     :Optional[int] = None    ,__snake_case     :Any = None    ,__snake_case     :Dict = None    ,__snake_case     :Union[str, Any] = None    ,__snake_case     :Dict = ChannelDimension.FIRST    ,)      ->					int:
												if do_resize and size is None or resample is None:
																			raise ValueError('Size and resample 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.'   )

												# All transformations expect numpy arrays.
												a__    =  to_numpy_array(_A   )

												if do_resize:
																			a__    =  self.resize(image=_A    ,size=_A    ,resample=_A   )

												if do_center_crop:
																			a__    =  self.center_crop(_A    ,size=_A   )

												if do_rescale:
																			a__    =  self.rescale(image=_A    ,scale=_A   )

												if do_normalize:
																			a__    =  self.normalize(image=_A    ,mean=_A    ,std=_A   )

												a__    =  to_channel_dimension_format(_A    ,_A   )
												return image



					def 				lowerCamelCase__(   self     :List[Any]    ,__snake_case     :Optional[int]    ,__snake_case     :List[Any] = None    ,__snake_case     :Tuple = None    ,__snake_case     :Optional[int] = None    ,__snake_case     :Any = None    ,__snake_case     :str = None    ,__snake_case     :Tuple = None    ,__snake_case     :List[Any] = None    ,__snake_case     :Optional[Any] = None    ,__snake_case     :int = None    ,__snake_case     :Any = None    ,__snake_case     :Tuple = None    ,__snake_case     :List[Any] = ChannelDimension.FIRST    ,**__snake_case     :List[str]    ,)      ->					Any:
												a__    =  do_resize if do_resize is not None else self.do_resize
												a__    =  resample if resample is not None else self.resample
												a__    =  do_center_crop if do_center_crop is not None else self.do_center_crop
												a__    =  do_rescale if do_rescale is not None else self.do_rescale
												a__    =  rescale_factor if rescale_factor is not None else self.rescale_factor
												a__    =  do_normalize if do_normalize is not None else self.do_normalize
												a__    =  image_mean if image_mean is not None else self.image_mean
												a__    =  image_std if image_std is not None else self.image_std

												a__    =  size if size is not None else self.size
												a__    =  get_size_dict(_A    ,default_to_square=_A   )
												a__    =  crop_size if crop_size is not None else self.crop_size
												a__    =  get_size_dict(_A    ,param_name='crop_size'   )

												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.'   )

												a__    =  make_batched(_A   )

												a__    =  [
												    [
												        self._preprocess_image(
												            image=_A    ,do_resize=_A    ,size=_A    ,resample=_A    ,do_center_crop=_A    ,crop_size=_A    ,do_rescale=_A    ,rescale_factor=_A    ,do_normalize=_A    ,image_mean=_A    ,image_std=_A    ,data_format=_A    ,)
												        for img in video
												    ]
												    for video in videos
												]

												a__    =  {'pixel_values': videos}
												return BatchFeature(data=_A    ,tensor_type=_A   )








from decimal import Decimal, getcontext
from math import ceil, factorial






def 							__lowercase     (				__lowerCAmelCase							:       int     ):

							if not isinstance(__lowerCAmelCase      ,					__lowerCAmelCase     ):
														raise TypeError('Undefined for non-integers'     )
							elif precision < 1:
														raise ValueError('Undefined for non-natural numbers'     )

							a__    =  precision
							a__    =  ceil(precision / 1_4     )
							a__    =  4_2_6_8_8_0 * Decimal(1_0_0_0_5     ).sqrt()
							a__    =  1
							a__    =  1_3_5_9_1_4_0_9
							a__    =  Decimal(__lowerCAmelCase     )
							for k in range(1      ,					__lowerCAmelCase     ):
														a__    =  factorial(6 * k     ) // (factorial(3 * k     ) * factorial(__lowerCAmelCase     ) ** 3)
														linear_term += 5_4_5_1_4_0_1_3_4
														exponential_term *= -2_6_2_5_3_7_4_1_2_6_4_0_7_6_8_0_0_0
														partial_sum += Decimal(multinomial_term * linear_term     ) / exponential_term
							return str(constant_term / partial_sum     )[:-1]


if __name__ == "__main__":
						snake_case							: Tuple      =   50
						print(f"""The first {n} digits of pi is: {pi(n)}""")




