
"""simple docstring"""





import unittest

import numpy as np

from transformers import RobertaConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_flax_available():
		from transformers.models.roberta.modeling_flax_roberta import (
		    FlaxRobertaForCausalLM,
		    FlaxRobertaForMaskedLM,
		    FlaxRobertaForMultipleChoice,
		    FlaxRobertaForQuestionAnswering,
		    FlaxRobertaForSequenceClassification,
		    FlaxRobertaForTokenClassification,
		    FlaxRobertaModel,
		)



class __lowerCAmelCase				(					unittest.TestCase   ):




			"""simple docstring"""







			def __init__(				self						:					int       ,   _snake_case						:					Dict       ,   _snake_case						:					int=13       ,   _snake_case						:					Optional[int]=7       ,   _snake_case						:					Optional[Any]=True       ,   _snake_case						:					Tuple=True       ,   _snake_case						:					Tuple=True       ,   _snake_case						:					Optional[Any]=True       ,   _snake_case						:					Dict=99       ,   _snake_case						:					Any=32       ,   _snake_case						:					Any=5       ,   _snake_case						:					Optional[int]=4       ,   _snake_case						:					Optional[Any]=37       ,   _snake_case						:					List[Any]="gelu"       ,   _snake_case						:					Tuple=0.1       ,   _snake_case						:					int=0.1       ,   _snake_case						:					str=512       ,   _snake_case						:					Optional[Any]=16       ,   _snake_case						:					Tuple=2       ,   _snake_case						:					str=0.0_2       ,   _snake_case						:					List[Any]=4       ,   )      -> Any:







								"""simple docstring"""
								A_				 =						parent
								A_				 =						batch_size
								A_				 =						seq_length
								A_				 =						is_training
								A_				 =						use_attention_mask
								A_				 =						use_token_type_ids
								A_				 =						use_labels
								A_				 =						vocab_size
								A_				 =						hidden_size
								A_				 =						num_hidden_layers
								A_				 =						num_attention_heads
								A_				 =						intermediate_size
								A_				 =						hidden_act
								A_				 =						hidden_dropout_prob
								A_				 =						attention_probs_dropout_prob
								A_				 =						max_position_embeddings
								A_				 =						type_vocab_size
								A_				 =						type_sequence_label_size
								A_				 =						initializer_range
								A_				 =						num_choices




			def      lowerCamelCase__     (				self						:					Any	)      -> Optional[int]:







								"""simple docstring"""
								A_				 =						ids_tensor([self.batch_size, self.seq_length]       ,   self.vocab_size	)

								A_				 =						None
								if self.use_attention_mask:
													A_				 =						random_attention_mask([self.batch_size, self.seq_length]	)

								A_				 =						None
								if self.use_token_type_ids:
													A_				 =						ids_tensor([self.batch_size, self.seq_length]       ,   self.type_vocab_size	)

								A_				 =						RobertaConfig(
								    vocab_size=self.vocab_size       ,   hidden_size=self.hidden_size       ,   num_hidden_layers=self.num_hidden_layers       ,   num_attention_heads=self.num_attention_heads       ,   intermediate_size=self.intermediate_size       ,   hidden_act=self.hidden_act       ,   hidden_dropout_prob=self.hidden_dropout_prob       ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,   max_position_embeddings=self.max_position_embeddings       ,   type_vocab_size=self.type_vocab_size       ,   is_decoder=_snake_case       ,   initializer_range=self.initializer_range       ,   )

								return config, input_ids, token_type_ids, attention_mask




			def      lowerCamelCase__     (				self						:					List[str]	)      -> Tuple:







								"""simple docstring"""
								A_				 =						self.prepare_config_and_inputs()
								A_				 =						config_and_inputs
								A_				 =						{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': attention_mask}
								return config, inputs_dict






			def      lowerCamelCase__     (				self						:					Union[str, Any]	)      -> Optional[int]:







								"""simple docstring"""
								A_				 =						self.prepare_config_and_inputs()
								A_				 =						config_and_inputs

								A_				 =						True
								A_				 =						floats_tensor([self.batch_size, self.seq_length, self.hidden_size]	)
								A_				 =						ids_tensor([self.batch_size, self.seq_length]       ,   vocab_size=2	)

								return (
								    config,
								    input_ids,
								    token_type_ids,
								    encoder_hidden_states,
								    encoder_attention_mask,
								)





@require_flax
class __lowerCAmelCase				(					__A     ,				unittest.TestCase   ):




			"""simple docstring"""







			snake_case	      =				True

			snake_case	      =				(
			    (
			        FlaxRobertaModel,
			        FlaxRobertaForCausalLM,
			        FlaxRobertaForMaskedLM,
			        FlaxRobertaForSequenceClassification,
			        FlaxRobertaForTokenClassification,
			        FlaxRobertaForMultipleChoice,
			        FlaxRobertaForQuestionAnswering,
			    )
			    if is_flax_available()
			    else ()
			)




			def      lowerCamelCase__     (				self						:					Union[str, Any]	)      -> List[Any]:







								"""simple docstring"""
								A_				 =						FlaxRobertaModelTester(self	)






			@slow
			def      lowerCamelCase__     (				self						:					Union[str, Any]	)      -> Tuple:







								"""simple docstring"""

								for model_class_name in self.all_model_classes:
													A_				 =						model_class_name.from_pretrained("roberta-base"       ,   from_pt=_snake_case	)
													A_				 =						model(np.ones((1, 1)	)	)
													self.assertIsNotNone(_snake_case	)






"""simple docstring"""





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

from .haversine_distance import haversine_distance

UpperCamelCase_					:						Tuple				= 637_8137.0
UpperCamelCase_					:						List[str]				= 635_6752.31_4245
UpperCamelCase_					:						Dict				= 637_8137
def 							A_     (__a				,   __a				,   __a				,   __a				):

					'''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(__a				)				)				)
					A_				 =						atan((1 - flattening) * tan(radians(__a				)				)				)

					# Compute central angle between two points
					# using haversine theta. sigma =  haversine_distance / equatorial radius
					A_				 =						haversine_distance(__a				,   __a				,   __a				,   __a				) / 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(__a				) ** 2) * (cos(__a				) ** 2)
					A_				 =						cos(sigma / 2				) ** 2
					A_				 =						(sigma - sin(__a				)) * (x_numerator / x_demonimator)

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

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


if __name__ == "__main__":
		import doctest

		doctest.testmod()




