






import math
import os
import unittest

from transformers import MegatronBertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_sentencepiece, require_tokenizers, 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,
				    MegatronBertForCausalLM,
				    MegatronBertForMaskedLM,
				    MegatronBertForMultipleChoice,
				    MegatronBertForNextSentencePrediction,
				    MegatronBertForPreTraining,
				    MegatronBertForQuestionAnswering,
				    MegatronBertForSequenceClassification,
				    MegatronBertForTokenClassification,
				    MegatronBertModel,
				)


class 							__a							:





		'''simple docstring'''



		def __init__(						self ,    UpperCamelCase__ ,    UpperCamelCase__=13 ,    UpperCamelCase__=7 ,    UpperCamelCase__=True ,    UpperCamelCase__=True ,    UpperCamelCase__=True ,    UpperCamelCase__=True ,    UpperCamelCase__=99 ,    UpperCamelCase__=64 ,    UpperCamelCase__=32 ,    UpperCamelCase__=5 ,    UpperCamelCase__=4 ,    UpperCamelCase__=37 ,    UpperCamelCase__="gelu" ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=512 ,    UpperCamelCase__=16 ,    UpperCamelCase__=2 ,    UpperCamelCase__=0.02 ,    UpperCamelCase__=3 ,    UpperCamelCase__=4 ,    UpperCamelCase__=None ,    ):
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   parent
						SCREAMING_SNAKE_CASE_   :	Tuple													=   batch_size
						SCREAMING_SNAKE_CASE_   :	Any													=   seq_length
						SCREAMING_SNAKE_CASE_   :	int													=   is_training
						SCREAMING_SNAKE_CASE_   :	str													=   use_input_mask
						SCREAMING_SNAKE_CASE_   :	str													=   use_token_type_ids
						SCREAMING_SNAKE_CASE_   :	Dict													=   use_labels
						SCREAMING_SNAKE_CASE_   :	str													=   vocab_size
						SCREAMING_SNAKE_CASE_   :	List[str]													=   hidden_size
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   embedding_size
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   num_hidden_layers
						SCREAMING_SNAKE_CASE_   :	Any													=   num_attention_heads
						SCREAMING_SNAKE_CASE_   :	Tuple													=   intermediate_size
						SCREAMING_SNAKE_CASE_   :	List[str]													=   hidden_act
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   hidden_dropout_prob
						SCREAMING_SNAKE_CASE_   :	Tuple													=   attention_probs_dropout_prob
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   max_position_embeddings
						SCREAMING_SNAKE_CASE_   :	int													=   type_vocab_size
						SCREAMING_SNAKE_CASE_   :	List[str]													=   type_sequence_label_size
						SCREAMING_SNAKE_CASE_   :	Any													=   initializer_range
						SCREAMING_SNAKE_CASE_   :	str													=   num_labels
						SCREAMING_SNAKE_CASE_   :	int													=   num_choices
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   scope


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[str]													=   ids_tensor([self.batch_size, self.seq_length] ,    self.vocab_size       )

						SCREAMING_SNAKE_CASE_   :	List[str]													=   None
						if self.use_input_mask:
										SCREAMING_SNAKE_CASE_   :	Dict													=   random_attention_mask([self.batch_size, self.seq_length]       )

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

						SCREAMING_SNAKE_CASE_   :	Dict													=   None
						SCREAMING_SNAKE_CASE_   :	Tuple													=   None
						SCREAMING_SNAKE_CASE_   :	int													=   None
						if self.use_labels:
										SCREAMING_SNAKE_CASE_   :	Dict													=   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_   :	Optional[int]													=   self.get_config()

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


		def   __snake_case			(						self       ):
						return MegatronBertConfig(
						    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 ,    embedding_size=self.embedding_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=UpperCamelCase__ ,    initializer_range=self.initializer_range ,    )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Tuple													=   MegatronBertModel(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   model(UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	str													=   model(UpperCamelCase__ ,    token_type_ids=UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	Dict													=   model(UpperCamelCase__       )

						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   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   MegatronBertForMaskedLM(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   model(UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__       )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Any													=   MegatronBertForCausalLM(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Dict													=   model(UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__       )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	int													=   MegatronBertForNextSentencePrediction(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   model(
						    UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__ ,    )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, 2)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   MegatronBertForPreTraining(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	List[str]													=   model(
						    UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__ ,    next_sentence_label=UpperCamelCase__ ,    )
						self.parent.assertEqual(result.prediction_logits.shape ,    (self.batch_size, self.seq_length, self.vocab_size)       )
						self.parent.assertEqual(result.seq_relationship_logits.shape ,    (self.batch_size, 2)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	int													=   MegatronBertForQuestionAnswering(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	int													=   model(
						    UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    start_positions=UpperCamelCase__ ,    end_positions=UpperCamelCase__ ,    )
						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   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Optional[int]													=   self.num_labels
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   MegatronBertForSequenceClassification(UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   model(UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__       )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.num_labels)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   self.num_labels
						SCREAMING_SNAKE_CASE_   :	str													=   MegatronBertForTokenClassification(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Dict													=   model(UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__       )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.seq_length, self.num_labels)       )


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_   :	Tuple													=   self.num_choices
						SCREAMING_SNAKE_CASE_   :	List[str]													=   MegatronBertForMultipleChoice(config=UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.eval()
						SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   input_ids.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
						SCREAMING_SNAKE_CASE_   :	Tuple													=   token_type_ids.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
						SCREAMING_SNAKE_CASE_   :	int													=   input_mask.unsqueeze(1       ).expand(-1 ,    self.num_choices ,    -1       ).contiguous()
						SCREAMING_SNAKE_CASE_   :	Tuple													=   model(
						    UpperCamelCase__ ,    attention_mask=UpperCamelCase__ ,    token_type_ids=UpperCamelCase__ ,    labels=UpperCamelCase__ ,    )
						self.parent.assertEqual(result.logits.shape ,    (self.batch_size, self.num_choices)       )






		def   __snake_case			(						self       ):
						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_
						)							,       
						)   :	List[Any]													=   config_and_inputs
						SCREAMING_SNAKE_CASE_   :	Tuple													=   {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
						return config, inputs_dict






@require_torch
class 							__a							(  __A ,	__A ,	unittest.TestCase						):





		'''simple docstring'''



		UpperCAmelCase__      :				Any				    =						(
		    (
		        MegatronBertModel,
		        MegatronBertForMaskedLM,
		        MegatronBertForCausalLM,
		        MegatronBertForMultipleChoice,
		        MegatronBertForNextSentencePrediction,
		        MegatronBertForPreTraining,
		        MegatronBertForQuestionAnswering,
		        MegatronBertForSequenceClassification,
		        MegatronBertForTokenClassification,
		    )
		    if is_torch_available()
		    else ()
		)
		UpperCAmelCase__      :				int				    =						(
		    {
		        """feature-extraction""": MegatronBertModel,
		        """fill-mask""": MegatronBertForMaskedLM,
		        """question-answering""": MegatronBertForQuestionAnswering,
		        """text-classification""": MegatronBertForSequenceClassification,
		        """text-generation""": MegatronBertForCausalLM,
		        """token-classification""": MegatronBertForTokenClassification,
		        """zero-shot""": MegatronBertForSequenceClassification,
		    }
		    if is_torch_available()
		    else {}
		)
		UpperCAmelCase__      :				str				    =						True
		# test_resize_embeddings = False
		UpperCAmelCase__      :				int				    =						False


		def   __snake_case			(						self ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__=False       ):
						SCREAMING_SNAKE_CASE_   :	str													=   super()._prepare_for_class(UpperCamelCase__ ,    UpperCamelCase__ ,    return_labels=UpperCamelCase__       )

						if return_labels:
										if model_class in get_values(UpperCamelCase__       ):
														SCREAMING_SNAKE_CASE_   :	int													=   torch.zeros(
														    (self.model_tester.batch_size, self.model_tester.seq_length) ,    dtype=torch.long ,    device=UpperCamelCase__       )
														SCREAMING_SNAKE_CASE_   :	str													=   torch.zeros(
														    self.model_tester.batch_size ,    dtype=torch.long ,    device=UpperCamelCase__       )
						return inputs_dict


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[str]													=   MegatronBertModelTester(self       )
						SCREAMING_SNAKE_CASE_   :	str													=   ConfigTester(self ,    config_class=UpperCamelCase__ ,    hidden_size=37       )


		def   __snake_case			(						self       ):
						self.config_tester.run_common_tests()


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	int													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_model(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[str]													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_masked_lm(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Dict													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_multiple_choice(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Tuple													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_next_sequence_prediction(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Tuple													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_pretraining(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	int													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_question_answering(*UpperCamelCase__       )


		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	str													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_sequence_classification(*UpperCamelCase__       )






		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Dict													=   self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_megatron_bert_for_token_classification(*UpperCamelCase__       )






def 					_lowerCamelCase(			lowerCAmelCase__				:		Dict      ):





				'''simple docstring'''







				return torch.tensor(
				    lowerCAmelCase__    ,    dtype=torch.long    ,    device=lowerCAmelCase__    ,    )


A        =			1E-4


@require_torch
@require_sentencepiece
@require_tokenizers
class 							__a							(  unittest.TestCase						):





		'''simple docstring'''



		@slow
		@unittest.skip('Model is not available.'       )
		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	Dict													=   'nvidia/megatron-bert-uncased-345m'
						if "MYDIR" in os.environ:
										SCREAMING_SNAKE_CASE_   :	Any													=   os.path.join(os.environ['MYDIR'] ,    UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   MegatronBertModel.from_pretrained(UpperCamelCase__       )
						model.to(UpperCamelCase__       )
						model.half()
						SCREAMING_SNAKE_CASE_   :	List[str]													=   _long_tensor([[101, 7110, 1005, 1056, 2023, 11333, 17413, 1029, 102]]       )
						with torch.no_grad():
										SCREAMING_SNAKE_CASE_   :	int													=   model(UpperCamelCase__       )[0]
						SCREAMING_SNAKE_CASE_   :	Tuple													=   torch.Size((1, 9, 1024)       )
						self.assertEqual(output.shape ,    UpperCamelCase__       )

						SCREAMING_SNAKE_CASE_   :	Any													=   [-0.60_40, -0.25_17, -0.10_25, 0.34_20, -0.67_58, -0.00_17, -0.10_89, -0.19_90, 0.57_28]
						for ii in range(3       ):
										for jj in range(3       ):
														SCREAMING_SNAKE_CASE_   :	int													=   output[0, ii, jj]
														SCREAMING_SNAKE_CASE_   :	Union[str, Any]													=   expected[3 * ii + jj]
														SCREAMING_SNAKE_CASE_   :	int													=   'ii={} jj={} a={} b={}'.format(UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__ ,    UpperCamelCase__       )
														self.assertTrue(math.isclose(UpperCamelCase__ ,    UpperCamelCase__ ,    rel_tol=UpperCamelCase__ ,    abs_tol=UpperCamelCase__       ) ,    msg=UpperCamelCase__       )







import colorsys

from PIL import Image  # type: ignore



def 					_lowerCamelCase(			lowerCAmelCase__				:		float    ,    lowerCAmelCase__				:		float    ,    lowerCAmelCase__				:		int      ):





				'''simple docstring'''







				SCREAMING_SNAKE_CASE_   :	Any													=   x
				SCREAMING_SNAKE_CASE_   :	Tuple													=   y
				for step in range(lowerCAmelCase__      ):  # noqa: B007
								SCREAMING_SNAKE_CASE_   :	str													=   a * a - b * b + x
								SCREAMING_SNAKE_CASE_   :	Any													=   2 * a * b + y
								SCREAMING_SNAKE_CASE_   :	int													=   a_new

								# divergence happens for all complex number with an absolute value
								# greater than 4
								if a * a + b * b > 4:
												break
				return step / (max_step - 1)



def 					_lowerCamelCase(			lowerCAmelCase__				:		float      ):





				'''simple docstring'''







				if distance == 1:
								return (0, 0, 0)
				else:
								return (255, 255, 255)



def 					_lowerCamelCase(			lowerCAmelCase__				:		float      ):





				'''simple docstring'''







				if distance == 1:
								return (0, 0, 0)
				else:
								return tuple(round(i * 255      ) for i in colorsys.hsv_to_rgb(lowerCAmelCase__    ,    1    ,    1      )      )



def 					_lowerCamelCase(			lowerCAmelCase__				:		int = 800    ,    lowerCAmelCase__				:		int = 600    ,    lowerCAmelCase__				:		float = -0.6    ,    lowerCAmelCase__				:		float = 0    ,    lowerCAmelCase__				:		float = 3.2    ,    lowerCAmelCase__				:		int = 50    ,    lowerCAmelCase__				:		bool = True    ,    ):





				'''simple docstring'''







				SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   Image.new('RGB'    ,    (image_width, image_height)      )
				SCREAMING_SNAKE_CASE_   :	List[str]													=   img.load()

				# loop through the image-coordinates
				for image_x in range(lowerCAmelCase__      ):
								for image_y in range(lowerCAmelCase__      ):
												# determine the figure-coordinates based on the image-coordinates
												SCREAMING_SNAKE_CASE_   :	List[str]													=   figure_width / image_width * image_height
												SCREAMING_SNAKE_CASE_   :	List[Any]													=   figure_center_x + (image_x / image_width - 0.5) * figure_width
												SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   figure_center_y + (image_y / image_height - 0.5) * figure_height

												SCREAMING_SNAKE_CASE_   :	str													=   get_distance(lowerCAmelCase__    ,    lowerCAmelCase__    ,    lowerCAmelCase__      )

												# color the corresponding pixel based on the selected coloring-function
												if use_distance_color_coding:
																SCREAMING_SNAKE_CASE_   :	int													=   get_color_coded_rgb(lowerCAmelCase__      )
												else:
																SCREAMING_SNAKE_CASE_   :	Dict													=   get_black_and_white_rgb(lowerCAmelCase__      )

				return img


if __name__ == "__main__":
				import doctest

				doctest.testmod()

				# colored version, full figure
				A        =			get_image()

				# uncomment for colored version, different section, zoomed in
				# img = get_image(figure_center_x = -0.6, figure_center_y = -0.4,
				# figure_width = 0.8)

				# uncomment for black and white version, full figure
				# img = get_image(use_distance_color_coding = False)

				# uncomment to save the image
				# img.save("mandelbrot.png")

				img.show()