




import torch

from transformers import AutoModel




class 		__A      (			torch.nn.Module			):

						def __init__(		self   :List[Any]    , __snake_case   :Tuple="sayef/fsner-bert-base-uncased" ):
										'''simple docstring'''

										super(__snake_case    , self ).__init__()

										__magic_name__	:	int								=AutoModel.from_pretrained(__snake_case    , return_dict=__snake_case )
										__magic_name__	:	Optional[int]								=torch.nn.CosineSimilarity(3    , 1E-08 )
										__magic_name__	:	Optional[int]								=torch.nn.Softmax(dim=1 )

						def     A__						(		self   :List[Any]    , **__snake_case   :List[str] ):
										'''simple docstring'''

										return self.bert(**__snake_case ).last_hidden_state

						def     A__						(		self   :Optional[Any]    , __snake_case   :List[Any] ):
										'''simple docstring'''

										return token_embeddings.sum(2    , keepdim=__snake_case )

						def     A__						(		self   :Dict    , __snake_case   :List[Any]    , __snake_case   :Optional[Any]    , __snake_case   :Dict=1 ):
										'''simple docstring'''

										return self.softmax(T * self.cos(__snake_case    , __snake_case ) )


						def     A__						(		self   :Tuple    , __snake_case   :Optional[int]    , __snake_case   :List[Any] ):
										'''simple docstring'''

										__magic_name__	:	Tuple								=W_supports["""sizes"""].tolist()
										__magic_name__	:	Dict								=W_supports["""start_token_id"""].item()
										__magic_name__	:	Dict								=W_supports["""end_token_id"""].item()

										del W_supports["sizes"]
										del W_supports["start_token_id"]
										del W_supports["end_token_id"]

										__magic_name__	:	Dict								=self.BERT(**__snake_case )
										__magic_name__	:	int								=self.BERT(**__snake_case )

										__magic_name__	:	int								=None
										__magic_name__	:	Tuple								=None

										__magic_name__	:	List[str]								=W_supports["""input_ids"""] == start_token_id
										__magic_name__	:	List[str]								=W_supports["""input_ids"""] == end_token_id

										for i, size in enumerate(__snake_case ):
														if i == 0:
																		__magic_name__	:	Union[str, Any]								=0
														else:
																		__magic_name__	:	Dict								=support_sizes[i - 1]

														__magic_name__	:	Any								=S[s : s + size][start_token_masks[s : s + size]]
														__magic_name__	:	List[Any]								=S[s : s + size][end_token_masks[s : s + size]]

														__magic_name__	:	str								=torch.matmul(q[i]    , s_start.T ).sum(1 ).softmax(0 )
														__magic_name__	:	Any								=torch.matmul(q[i]    , s_end.T ).sum(1 ).softmax(0 )

														if p_starts is not None:
																		__magic_name__	:	List[Any]								=torch.vstack((p_starts, p_start) )
																		__magic_name__	:	Tuple								=torch.vstack((p_ends, p_end) )
														else:
																		__magic_name__	:	str								=p_start
																		__magic_name__	:	Union[str, Any]								=p_end

										return p_starts, p_ends










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

from .haversine_distance import haversine_distance

UpperCAmelCase_		:				Dict									=     637_8137.0
UpperCAmelCase_		:				List[Any]									=     635_6752.31_4245
UpperCAmelCase_		:				List[str]									=     6378137




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				__magic_name__	:	str								=(AXIS_A - AXIS_B) / AXIS_A
				# Parametric latitudes
				# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
				__magic_name__	:	str								=atan((1 - flattening) * tan(radians(lowerCamelCase   )   )   )
				__magic_name__	:	List[Any]								=atan((1 - flattening) * tan(radians(lowerCamelCase   )   )   )

				# Compute central angle between two points
				# using haversine theta. sigma =  haversine_distance / equatorial radius
				__magic_name__	:	List[Any]								=haversine_distance(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ) / EQUATORIAL_RADIUS

				# Intermediate P and Q values
				__magic_name__	:	Tuple								=(b_lata + b_lata) / 2
				__magic_name__	:	int								=(b_lata - b_lata) / 2

				# Intermediate X value
				# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
				__magic_name__	:	Optional[int]								=(sin(lowerCamelCase   ) ** 2) * (cos(lowerCamelCase   ) ** 2)
				__magic_name__	:	Any								=cos(sigma / 2   ) ** 2
				__magic_name__	:	List[Any]								=(sigma - sin(lowerCamelCase   )) * (x_numerator / x_demonimator)

				# Intermediate Y value
				# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
				__magic_name__	:	Any								=(cos(lowerCamelCase   ) ** 2) * (sin(lowerCamelCase   ) ** 2)
				__magic_name__	:	Optional[Any]								=sin(sigma / 2   ) ** 2
				__magic_name__	:	str								=(sigma + sin(lowerCamelCase   )) * (y_numerator / y_denominator)

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


if __name__ == "__main__":
							import doctest

							doctest.testmod()




