






'''simple docstring'''







from typing import List, Optional, Union

import numpy as np
import PIL.Image

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    PILImageResampling,
    get_image_size,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, logging


_A     :      Optional[Any]   					=logging.get_logger(__name__)

class _lowercase     (    _lowercase		):
							a    				=	["""pixel_values"""]




							def __init__(							self:    Any      ,							UpperCamelCase__:    bool = True      ,							UpperCamelCase__:    int = 32      ,							UpperCamelCase__:    Dict=PILImageResampling.BILINEAR      ,							UpperCamelCase__:    bool = True      ,							**UpperCamelCase__:    Any      ,							):
														lowerCamelCase__ :     int	  =	do_resize
														lowerCamelCase__ :     int	  =	do_rescale
														lowerCamelCase__ :     Tuple	  =	size_divisor
														lowerCamelCase__ :     Dict	  =	resample
														super().__init__(**UpperCamelCase__					)




							def 		lowerCamelCase_    (							self:    int      ,							UpperCamelCase__:    np.ndarray      ,							UpperCamelCase__:    int      ,							UpperCamelCase__:    Optional[Any]      ,							UpperCamelCase__:    Optional[ChannelDimension] = None      ,							**UpperCamelCase__:    Dict					):
														lowerCamelCase__  ,		lowerCamelCase__ :     Tuple	  =	get_image_size(UpperCamelCase__					)
														# Rounds the height and width down to the closest multiple of size_divisor
														lowerCamelCase__ :     int	  =	height // size_divisor * size_divisor
														lowerCamelCase__ :     Tuple	  =	width // size_divisor * size_divisor
														lowerCamelCase__ :     Any	  =	resize(UpperCamelCase__      ,							(new_h, new_w)      ,							resample=UpperCamelCase__      ,							data_format=UpperCamelCase__      ,							**UpperCamelCase__					)
														return image




							def 		lowerCamelCase_    (							self:    Optional[int]      ,							UpperCamelCase__:    np.ndarray      ,							UpperCamelCase__:    float      ,							UpperCamelCase__:    Optional[ChannelDimension] = None      ,							**UpperCamelCase__:    str					):
														return rescale(image=UpperCamelCase__      ,							scale=UpperCamelCase__      ,							data_format=UpperCamelCase__      ,							**UpperCamelCase__					)




							def 		lowerCamelCase_    (							self:    Dict      ,							UpperCamelCase__:    Union["PIL.Image.Image", TensorType, List["PIL.Image.Image"], List[TensorType]]      ,							UpperCamelCase__:    Optional[bool] = None      ,							UpperCamelCase__:    Optional[int] = None      ,							UpperCamelCase__:    Any=None      ,							UpperCamelCase__:    Optional[bool] = None      ,							UpperCamelCase__:    Optional[Union[TensorType, str]] = None      ,							UpperCamelCase__:    ChannelDimension = ChannelDimension.FIRST      ,							**UpperCamelCase__:    Dict      ,							):
														lowerCamelCase__ :     Any	  =	do_resize if do_resize is not None else self.do_resize
														lowerCamelCase__ :     str	  =	do_rescale if do_rescale is not None else self.do_rescale
														lowerCamelCase__ :     Dict	  =	size_divisor if size_divisor is not None else self.size_divisor
														lowerCamelCase__ :     Dict	  =	resample if resample is not None else self.resample

														if do_resize and size_divisor is None:
																					raise ValueError("""size_divisor is required for resizing"""					)

														lowerCamelCase__ :     Tuple	  =	make_list_of_images(UpperCamelCase__					)

														if not valid_images(UpperCamelCase__					):
																					raise ValueError("""Invalid image(s)"""					)

														# All transformations expect numpy arrays.
														lowerCamelCase__ :     List[Any]	  =	[to_numpy_array(UpperCamelCase__					) for img in images]

														if do_resize:
																					lowerCamelCase__ :     Optional[int]	  =	[self.resize(UpperCamelCase__      ,							size_divisor=UpperCamelCase__      ,							resample=UpperCamelCase__					) for image in images]

														if do_rescale:
																					lowerCamelCase__ :     Dict	  =	[self.rescale(UpperCamelCase__      ,							scale=1 / 255					) for image in images]

														lowerCamelCase__ :     Optional[Any]	  =	[to_channel_dimension_format(UpperCamelCase__      ,							UpperCamelCase__					) for image in images]

														lowerCamelCase__ :     Optional[int]	  =	{"""pixel_values""": images}
														return BatchFeature(data=UpperCamelCase__      ,							tensor_type=UpperCamelCase__					)









'''simple docstring'''







from math import asin, atan, cos, radians, sin, sqrt, tan

_A     :      List[str]   					=637_8137.0
_A     :      Dict   					=635_6752.31_4245
_A     :      int   					=6_378_137





def 			SCREAMING_SNAKE_CASE_	(UpperCamelCase    ,      UpperCamelCase    ,      UpperCamelCase    ,      UpperCamelCase				)				->	float:
							lowerCamelCase__ :     str	  =	(AXIS_A - AXIS_B) / AXIS_A
							lowerCamelCase__ :     Dict	  =	atan((1 - flattening) * tan(radians(UpperCamelCase				)				)				)
							lowerCamelCase__ :     Dict	  =	atan((1 - flattening) * tan(radians(UpperCamelCase				)				)				)
							lowerCamelCase__ :     Optional[Any]	  =	radians(UpperCamelCase				)
							lowerCamelCase__ :     List[Any]	  =	radians(UpperCamelCase				)
							# Equation
							lowerCamelCase__ :     Tuple	  =	sin((phi_a - phi_a) / 2				)
							lowerCamelCase__ :     List[Any]	  =	sin((lambda_a - lambda_a) / 2				)
							# Square both values
							sin_sq_phi *= sin_sq_phi
							sin_sq_lambda *= sin_sq_lambda
							lowerCamelCase__ :     Tuple	  =	sqrt(sin_sq_phi + (cos(UpperCamelCase				) * cos(UpperCamelCase				) * sin_sq_lambda)				)
							return 2 * RADIUS * asin(UpperCamelCase				)


if __name__ == "__main__":
			import doctest

			doctest.testmod()

