

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

from .haversine_distance import haversine_distance

lowerCAmelCase__		      =       6_3_7_8_1_3_7.0
lowerCAmelCase__		      =       6_3_5_6_7_5_2.3_1_4_2_4_5
lowerCAmelCase__		      =       6_3_7_8_1_3_7



def     lowerCAmelCase__							(		SCREAMING_SNAKE_CASE_:							float		,				SCREAMING_SNAKE_CASE_:							float		,				SCREAMING_SNAKE_CASE_:							float		,				SCREAMING_SNAKE_CASE_:							float					)	->					float:




				'''simple docstring'''





				A__						=	(AXIS_A - AXIS_B) / AXIS_A
				# Parametric latitudes
				# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
				A__						=	atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE_					)					)					)
				A__						=	atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE_					)					)					)

				# Compute central angle between two points
				# using haversine theta. sigma =  haversine_distance / equatorial radius
				A__						=	haversine_distance(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_					) / EQUATORIAL_RADIUS

				# Intermediate P and Q values
				A__						=	(b_lata + b_lata) / 2
				A__						=	(b_lata - b_lata) / 2

				# Intermediate X value
				# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
				A__						=	(sin(SCREAMING_SNAKE_CASE_					) ** 2) * (cos(SCREAMING_SNAKE_CASE_					) ** 2)
				A__						=	cos(sigma / 2					) ** 2
				A__						=	(sigma - sin(SCREAMING_SNAKE_CASE_					)) * (x_numerator / x_demonimator)

				# Intermediate Y value
				# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
				A__						=	(cos(SCREAMING_SNAKE_CASE_					) ** 2) * (sin(SCREAMING_SNAKE_CASE_					) ** 2)
				A__						=	sin(sigma / 2					) ** 2
				A__						=	(sigma + sin(SCREAMING_SNAKE_CASE_					)) * (y_numerator / y_denominator)

				return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
	import doctest

	doctest.testmod()








'''simple docstring'''







from ...configuration_utils import PretrainedConfig
from ...utils import logging


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

lowerCAmelCase_					:    List[str]      	=			{
    'microsoft/trocr-base-handwritten': (
        'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json'
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}
class 				__SCREAMING_SNAKE_CASE  (lowerCamelCase_      ):






				"""simple docstring"""







				__a            ='trocr'
				__a            =['past_key_values']
				__a            ={
				    'num_attention_heads': 'decoder_attention_heads',
				    'hidden_size': 'd_model',
				    'num_hidden_layers': 'decoder_layers',
				}




				def __init__(  self     :					Optional[int]					,				__a     :					Any=5_02_65					,				__a     :					Optional[int]=10_24					,				__a     :					List[Any]=12					,				__a     :					str=16					,				__a     :					int=40_96					,				__a     :					Optional[Any]="gelu"					,				__a     :					Union[str, Any]=5_12					,				__a     :					Dict=0.1					,				__a     :					List[str]=0.0					,				__a     :					Union[str, Any]=0.0					,				__a     :					Any=2					,				__a     :					Union[str, Any]=0.02					,				__a     :					Any=0.0					,				__a     :					List[str]=True					,				__a     :					Optional[Any]=False					,				__a     :					Union[str, Any]=True					,				__a     :					Optional[Any]=True					,				__a     :					Any=1					,				__a     :					List[Any]=0					,				__a     :					Any=2					,				**__a     :					Optional[Any]					,				):
								_a								= vocab_size
								_a								= d_model
								_a								= decoder_layers
								_a								= decoder_attention_heads
								_a								= decoder_ffn_dim
								_a								= activation_function
								_a								= max_position_embeddings
								_a								= dropout
								_a								= attention_dropout
								_a								= activation_dropout
								_a								= init_std
								_a								= decoder_layerdrop
								_a								= use_cache
								_a								= scale_embedding
								_a								= use_learned_position_embeddings
								_a								= layernorm_embedding

								super().__init__(
								    pad_token_id=__a					,				bos_token_id=__a					,				eos_token_id=__a					,				decoder_start_token_id=__a					,				**__a					,				)
