
"""simple docstring"""




import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch

					from transformers import (
					    MODEL_FOR_PRETRAINING_MAPPING,
					    AlbertForMaskedLM,
					    AlbertForMultipleChoice,
					    AlbertForPreTraining,
					    AlbertForQuestionAnswering,
					    AlbertForSequenceClassification,
					    AlbertForTokenClassification,
					    AlbertModel,
					)
					from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST



class 			lowerCAmelCase_		:


				"""simple docstring"""



				def __init__(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__=13     , SCREAMING_SNAKE_CASE__=7     , SCREAMING_SNAKE_CASE__=True     , SCREAMING_SNAKE_CASE__=True     , SCREAMING_SNAKE_CASE__=True     , SCREAMING_SNAKE_CASE__=True     , SCREAMING_SNAKE_CASE__=99     , SCREAMING_SNAKE_CASE__=16     , SCREAMING_SNAKE_CASE__=36     , SCREAMING_SNAKE_CASE__=6     , SCREAMING_SNAKE_CASE__=6     , SCREAMING_SNAKE_CASE__=6     , SCREAMING_SNAKE_CASE__=37     , SCREAMING_SNAKE_CASE__="gelu"     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=5_12     , SCREAMING_SNAKE_CASE__=16     , SCREAMING_SNAKE_CASE__=2     , SCREAMING_SNAKE_CASE__=0.02     , SCREAMING_SNAKE_CASE__=3     , SCREAMING_SNAKE_CASE__=4     , SCREAMING_SNAKE_CASE__=None     , )      ->	Optional[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Any     =     parent
											SCREAMING_SNAKE_CASE__		: Tuple     =     batch_size
											SCREAMING_SNAKE_CASE__		: int     =     seq_length
											SCREAMING_SNAKE_CASE__		: str     =     is_training
											SCREAMING_SNAKE_CASE__		: Any     =     use_input_mask
											SCREAMING_SNAKE_CASE__		: int     =     use_token_type_ids
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     use_labels
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     vocab_size
											SCREAMING_SNAKE_CASE__		: List[str]     =     embedding_size
											SCREAMING_SNAKE_CASE__		: Tuple     =     hidden_size
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     num_hidden_layers
											SCREAMING_SNAKE_CASE__		: int     =     num_hidden_groups
											SCREAMING_SNAKE_CASE__		: List[str]     =     num_attention_heads
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     intermediate_size
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     hidden_act
											SCREAMING_SNAKE_CASE__		: Dict     =     hidden_dropout_prob
											SCREAMING_SNAKE_CASE__		: Dict     =     attention_probs_dropout_prob
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     max_position_embeddings
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     type_vocab_size
											SCREAMING_SNAKE_CASE__		: str     =     type_sequence_label_size
											SCREAMING_SNAKE_CASE__		: int     =     initializer_range
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     num_labels
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     num_choices
											SCREAMING_SNAKE_CASE__		: int     =     scope



				def 			__magic_name__					(self					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[str]     =     ids_tensor([self.batch_size, self.seq_length]     , self.vocab_size					)

											SCREAMING_SNAKE_CASE__		: List[Any]     =     None
											if self.use_input_mask:
																		SCREAMING_SNAKE_CASE__		: Optional[Any]     =     random_attention_mask([self.batch_size, self.seq_length]					)

											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     None
											if self.use_token_type_ids:
																		SCREAMING_SNAKE_CASE__		: Optional[int]     =     ids_tensor([self.batch_size, self.seq_length]     , self.type_vocab_size					)

											SCREAMING_SNAKE_CASE__		: List[str]     =     None
											SCREAMING_SNAKE_CASE__		: List[str]     =     None
											SCREAMING_SNAKE_CASE__		: str     =     None
											if self.use_labels:
																		SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     ids_tensor([self.batch_size]     , self.type_sequence_label_size					)
																		SCREAMING_SNAKE_CASE__		: Optional[Any]     =     ids_tensor([self.batch_size, self.seq_length]     , self.num_labels					)
																		SCREAMING_SNAKE_CASE__		: List[Any]     =     ids_tensor([self.batch_size]     , self.num_choices					)

											SCREAMING_SNAKE_CASE__		: str     =     self.get_config()

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels



				def 			__magic_name__					(self					)      ->	str:



											"""simple docstring"""




											return AlbertConfig(
											    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     , initializer_range=self.initializer_range     , num_hidden_groups=self.num_hidden_groups     , )



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	Tuple:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Any     =     AlbertModel(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: str     =     model(SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: Any     =     model(SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: List[str]     =     model(SCREAMING_SNAKE_CASE__					)
											self.parent.assertEqual(result.last_hidden_state.shape     , (self.batch_size, self.seq_length, self.hidden_size)					)
											self.parent.assertEqual(result.pooler_output.shape     , (self.batch_size, self.hidden_size)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[Any]     =     AlbertForPreTraining(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     model(
											    SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , labels=SCREAMING_SNAKE_CASE__     , sentence_order_label=SCREAMING_SNAKE_CASE__     , )
											self.parent.assertEqual(result.prediction_logits.shape     , (self.batch_size, self.seq_length, self.vocab_size)					)
											self.parent.assertEqual(result.sop_logits.shape     , (self.batch_size, config.num_labels)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[int]     =     AlbertForMaskedLM(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: Any     =     model(SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , labels=SCREAMING_SNAKE_CASE__					)
											self.parent.assertEqual(result.logits.shape     , (self.batch_size, self.seq_length, self.vocab_size)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     AlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: List[Any]     =     model(
											    SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , start_positions=SCREAMING_SNAKE_CASE__     , end_positions=SCREAMING_SNAKE_CASE__     , )
											self.parent.assertEqual(result.start_logits.shape     , (self.batch_size, self.seq_length)					)
											self.parent.assertEqual(result.end_logits.shape     , (self.batch_size, self.seq_length)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: int     =     self.num_labels
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     AlbertForSequenceClassification(SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     model(SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , labels=SCREAMING_SNAKE_CASE__					)
											self.parent.assertEqual(result.logits.shape     , (self.batch_size, self.num_labels)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	str:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: int     =     self.num_labels
											SCREAMING_SNAKE_CASE__		: Any     =     AlbertForTokenClassification(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: List[str]     =     model(SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , labels=SCREAMING_SNAKE_CASE__					)
											self.parent.assertEqual(result.logits.shape     , (self.batch_size, self.seq_length, self.num_labels)					)



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__					)      ->	Optional[Any]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[str]     =     self.num_choices
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     AlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE__					)
											model.to(SCREAMING_SNAKE_CASE__					)
											model.eval()
											SCREAMING_SNAKE_CASE__		: List[Any]     =     input_ids.unsqueeze(1					).expand(-1     , self.num_choices     , -1					).contiguous()
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     token_type_ids.unsqueeze(1					).expand(-1     , self.num_choices     , -1					).contiguous()
											SCREAMING_SNAKE_CASE__		: List[Any]     =     input_mask.unsqueeze(1					).expand(-1     , self.num_choices     , -1					).contiguous()
											SCREAMING_SNAKE_CASE__		: List[str]     =     model(
											    SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__     , token_type_ids=SCREAMING_SNAKE_CASE__     , labels=SCREAMING_SNAKE_CASE__     , )
											self.parent.assertEqual(result.logits.shape     , (self.batch_size, self.num_choices)					)



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



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Dict     =     self.prepare_config_and_inputs()
											(
											    (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   (
											    SCREAMING_SNAKE_CASE__
											)   ,   
											)		: str     =     config_and_inputs
											SCREAMING_SNAKE_CASE__		: Any     =     {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
											return config, inputs_dict






@require_torch
class 			lowerCAmelCase_		(a__				,      a__				,      unittest.TestCase						):


				"""simple docstring"""



				__UpperCamelCase   :		str       =     (
				    (
				        AlbertModel,
				        AlbertForPreTraining,
				        AlbertForMaskedLM,
				        AlbertForMultipleChoice,
				        AlbertForSequenceClassification,
				        AlbertForTokenClassification,
				        AlbertForQuestionAnswering,
				    )
				    if is_torch_available()
				    else ()
				)
				__UpperCamelCase   :		Optional[Any]       =     (
				    {
				        '''feature-extraction''': AlbertModel,
				        '''fill-mask''': AlbertForMaskedLM,
				        '''question-answering''': AlbertForQuestionAnswering,
				        '''text-classification''': AlbertForSequenceClassification,
				        '''token-classification''': AlbertForTokenClassification,
				        '''zero-shot''': AlbertForSequenceClassification,
				    }
				    if is_torch_available()
				    else {}
				)
				__UpperCamelCase   :		Union[str, Any]       =     True



				def 			__magic_name__					(self     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__=False					)      ->	Dict:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[int]     =     super()._prepare_for_class(SCREAMING_SNAKE_CASE__     , SCREAMING_SNAKE_CASE__     , return_labels=SCREAMING_SNAKE_CASE__					)

											if return_labels:
																		if model_class in get_values(SCREAMING_SNAKE_CASE__					):
																									SCREAMING_SNAKE_CASE__		: Optional[int]     =     torch.zeros(
																									    (self.model_tester.batch_size, self.model_tester.seq_length)     , dtype=torch.long     , device=SCREAMING_SNAKE_CASE__					)
																									SCREAMING_SNAKE_CASE__		: Dict     =     torch.zeros(
																									    self.model_tester.batch_size     , dtype=torch.long     , device=SCREAMING_SNAKE_CASE__					)
											return inputs_dict



				def 			__magic_name__					(self					)      ->	int:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Any     =     AlbertModelTester(self					)
											SCREAMING_SNAKE_CASE__		: List[Any]     =     ConfigTester(self     , config_class=SCREAMING_SNAKE_CASE__     , hidden_size=37					)



				def 			__magic_name__					(self					)      ->	Optional[Any]:



											"""simple docstring"""




											self.config_tester.run_common_tests()



				def 			__magic_name__					(self					)      ->	Optional[int]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Dict     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	Optional[int]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Dict     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_pretraining(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Tuple     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: List[str]     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_multiple_choice(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: int     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Optional[int]     =     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__					)



				def 			__magic_name__					(self					)      ->	List[str]:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Any     =     self.model_tester.prepare_config_and_inputs()
											for type in ["absolute", "relative_key", "relative_key_query"]:
																		SCREAMING_SNAKE_CASE__		: List[Any]     =     type
																		self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__					)



				@slow
				def 			__magic_name__					(self					)      ->	Optional[int]:



											"""simple docstring"""




											for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																		SCREAMING_SNAKE_CASE__		: Tuple     =     AlbertModel.from_pretrained(SCREAMING_SNAKE_CASE__					)
																		self.assertIsNotNone(SCREAMING_SNAKE_CASE__					)






@require_torch
class 			lowerCAmelCase_		(unittest.TestCase						):


				"""simple docstring"""



				@slow
				def 			__magic_name__					(self					)      ->	Any:



											"""simple docstring"""




											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     AlbertModel.from_pretrained("""albert-base-v2"""					)
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     torch.tensor([[0, 3_45, 2_32, 3_28, 7_40, 1_40, 16_95, 69, 60_78, 15_88, 2]]					)
											SCREAMING_SNAKE_CASE__		: Tuple     =     torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]					)
											with torch.no_grad():
																		SCREAMING_SNAKE_CASE__		: int     =     model(SCREAMING_SNAKE_CASE__     , attention_mask=SCREAMING_SNAKE_CASE__					)[0]
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     torch.Size((1, 11, 7_68)					)
											self.assertEqual(output.shape     , SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: int     =     torch.tensor(
											    [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]					)

											self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     , SCREAMING_SNAKE_CASE__     , atol=1E-4					)					)






"""simple docstring"""




from math import pi, sqrt, tan

def lowercase_						(     _snake_case		):
							if side_length < 0:
														raise ValueError("""surface_area_cube() only accepts non-negative values"""		)
							return 6 * side_length**2

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							if length < 0 or breadth < 0 or height < 0:
														raise ValueError("""surface_area_cuboid() only accepts non-negative values"""		)
							return 2 * ((length * breadth) + (breadth * height) + (length * height))

def lowercase_						(     _snake_case		):
							if radius < 0:
														raise ValueError("""surface_area_sphere() only accepts non-negative values"""		)
							return 4 * pi * radius**2

def lowercase_						(     _snake_case		):
							if radius < 0:
														raise ValueError("""surface_area_hemisphere() only accepts non-negative values"""		)
							return 3 * pi * radius**2

def lowercase_						(     _snake_case     ,_snake_case		):
							if radius < 0 or height < 0:
														raise ValueError("""surface_area_cone() only accepts non-negative values"""		)
							return pi * radius * (radius + (height**2 + radius**2) ** 0.5)

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							if radius_a < 0 or radius_a < 0 or height < 0:
														raise ValueError(
														    """surface_area_conical_frustum() only accepts non-negative values"""		)
							SCREAMING_SNAKE_CASE__		: int     =     (height**2 + (radius_a - radius_a) ** 2) ** 0.5
							return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)

def lowercase_						(     _snake_case     ,_snake_case		):
							if radius < 0 or height < 0:
														raise ValueError("""surface_area_cylinder() only accepts non-negative values"""		)
							return 2 * pi * radius * (height + radius)

def lowercase_						(     _snake_case     ,_snake_case		):
							if torus_radius < 0 or tube_radius < 0:
														raise ValueError("""surface_area_torus() only accepts non-negative values"""		)
							if torus_radius < tube_radius:
														raise ValueError(
														    """surface_area_torus() does not support spindle or self intersecting tori"""		)
							return 4 * pow(_snake_case     ,2		) * torus_radius * tube_radius

def lowercase_						(     _snake_case     ,_snake_case		):
							if length < 0 or width < 0:
														raise ValueError("""area_rectangle() only accepts non-negative values"""		)
							return length * width

def lowercase_						(     _snake_case		):
							if side_length < 0:
														raise ValueError("""area_square() only accepts non-negative values"""		)
							return side_length**2

def lowercase_						(     _snake_case     ,_snake_case		):
							if base < 0 or height < 0:
														raise ValueError("""area_triangle() only accepts non-negative values"""		)
							return (base * height) / 2

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							if sidea < 0 or sidea < 0 or sidea < 0:
														raise ValueError("""area_triangle_three_sides() only accepts non-negative values"""		)
							elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
														raise ValueError("""Given three sides do not form a triangle"""		)
							SCREAMING_SNAKE_CASE__		: List[str]     =     (sidea + sidea + sidea) / 2
							SCREAMING_SNAKE_CASE__		: List[Any]     =     sqrt(
							    semi_perimeter
							    * (semi_perimeter - sidea)
							    * (semi_perimeter - sidea)
							    * (semi_perimeter - sidea)		)
							return area

def lowercase_						(     _snake_case     ,_snake_case		):
							if base < 0 or height < 0:
														raise ValueError("""area_parallelogram() only accepts non-negative values"""		)
							return base * height

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							if basea < 0 or basea < 0 or height < 0:
														raise ValueError("""area_trapezium() only accepts non-negative values"""		)
							return 1 / 2 * (basea + basea) * height

def lowercase_						(     _snake_case		):
							if radius < 0:
														raise ValueError("""area_circle() only accepts non-negative values"""		)
							return pi * radius**2

def lowercase_						(     _snake_case     ,_snake_case		):
							if radius_x < 0 or radius_y < 0:
														raise ValueError("""area_ellipse() only accepts non-negative values"""		)
							return pi * radius_x * radius_y

def lowercase_						(     _snake_case     ,_snake_case		):
							if diagonal_a < 0 or diagonal_a < 0:
														raise ValueError("""area_rhombus() only accepts non-negative values"""		)
							return 1 / 2 * diagonal_a * diagonal_a

def lowercase_						(     _snake_case     ,_snake_case		):
							if not isinstance(_snake_case     ,_snake_case		) or sides < 3:
														raise ValueError(
														    """area_reg_polygon() only accepts integers greater than or \
equal to three as number of sides"""		)
							elif length < 0:
														raise ValueError(
														    """area_reg_polygon() only accepts non-negative values as \
length of a side"""		)
							return (sides * length**2) / (4 * tan(pi / sides		))
							return (sides * length**2) / (4 * tan(pi / sides		))


if __name__ == "__main__":
					import doctest

					doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

					print('[DEMO] Areas of various geometric shapes: \n')
					print(f"""Rectangle: {area_rectangle(1_0, 2_0) = }""")
					print(f"""Square: {area_square(1_0) = }""")
					print(f"""Triangle: {area_triangle(1_0, 1_0) = }""")
					print(f"""Triangle: {area_triangle_three_sides(5, 1_2, 1_3) = }""")
					print(f"""Parallelogram: {area_parallelogram(1_0, 2_0) = }""")
					print(f"""Rhombus: {area_rhombus(1_0, 2_0) = }""")
					print(f"""Trapezium: {area_trapezium(1_0, 2_0, 3_0) = }""")
					print(f"""Circle: {area_circle(2_0) = }""")
					print(f"""Ellipse: {area_ellipse(1_0, 2_0) = }""")
					print('\nSurface Areas of various geometric shapes: \n')
					print(f"""Cube: {surface_area_cube(2_0) = }""")
					print(f"""Cuboid: {surface_area_cuboid(1_0, 2_0, 3_0) = }""")
					print(f"""Sphere: {surface_area_sphere(2_0) = }""")
					print(f"""Hemisphere: {surface_area_hemisphere(2_0) = }""")
					print(f"""Cone: {surface_area_cone(1_0, 2_0) = }""")
					print(f"""Conical Frustum: {surface_area_conical_frustum(1_0, 2_0, 3_0) = }""")
					print(f"""Cylinder: {surface_area_cylinder(1_0, 2_0) = }""")
					print(f"""Torus: {surface_area_torus(2_0, 1_0) = }""")
					print(f"""Equilateral Triangle: {area_reg_polygon(3, 1_0) = }""")
					print(f"""Square: {area_reg_polygon(4, 1_0) = }""")
					print(f"""Reqular Pentagon: {area_reg_polygon(5, 1_0) = }""")




