
import colorsys

from PIL import Image  # type: ignore




def    __UpperCamelCase     (				lowerCAmelCase__							:				float  ,   lowerCAmelCase__							:				float  ,   lowerCAmelCase__							:				int  ):
 __a :  Dict						=  x
 __a :  Union[str, Any]						=  y
 for step in range(lowerCAmelCase__  ):  # noqa: B007
  __a :  Optional[int]						=  a * a - b * b + x
  __a :  List[Any]						=  2 * a * b + y
  __a :  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    __UpperCamelCase     (				lowerCAmelCase__							:				float  ):



 if distance == 1:
  return (0, 0, 0)
 else:
  return (2_5_5, 2_5_5, 2_5_5)




def    __UpperCamelCase     (				lowerCAmelCase__							:				float  ):



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




def    __UpperCamelCase     (				lowerCAmelCase__							:				int = 8_0_0  ,   lowerCAmelCase__							:				int = 6_0_0  ,   lowerCAmelCase__							:				float = -0.6  ,   lowerCAmelCase__							:				float = 0  ,   lowerCAmelCase__							:				float = 3.2  ,   lowerCAmelCase__							:				int = 5_0  ,   lowerCAmelCase__							:				bool = True  ,   ):
 __a :  str						=  Image.new('''RGB'''  ,   (image_width, image_height)  )
 __a :  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
   __a :  Optional[Any]						=  figure_width / image_width * image_height
   __a :  List[Any]						=  figure_center_x + (image_x / image_width - 0.5) * figure_width
   __a :  List[Any]						=  figure_center_y + (image_y / image_height - 0.5) * figure_height

   __a :  Dict						=  get_distance(lowerCAmelCase__  ,   lowerCAmelCase__  ,   lowerCAmelCase__  )

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

 return img


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      # colored version, full figure
      lowercase__       =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()






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCamelCase				:		Optional[Any]     =   {
    "configuration_whisper": ["WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP", "WhisperConfig", "WhisperOnnxConfig"],
    "feature_extraction_whisper": ["WhisperFeatureExtractor"],
    "processing_whisper": ["WhisperProcessor"],
    "tokenization_whisper": ["WhisperTokenizer"],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		Tuple     =   ["WhisperTokenizerFast"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		str     =   [
     "WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "WhisperForConditionalGeneration",
     "WhisperModel",
     "WhisperPreTrainedModel",
     "WhisperForAudioClassification",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		List[str]     =   [
     "TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFWhisperForConditionalGeneration",
     "TFWhisperModel",
     "TFWhisperPreTrainedModel",
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		str     =   [
     "FlaxWhisperForConditionalGeneration",
     "FlaxWhisperModel",
     "FlaxWhisperPreTrainedModel",
     "FlaxWhisperForAudioClassification",
 ]


if TYPE_CHECKING:
 from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
 from .feature_extraction_whisper import WhisperFeatureExtractor
 from .processing_whisper import WhisperProcessor
 from .tokenization_whisper import WhisperTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_whisper_fast import WhisperTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_whisper import (
      WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      WhisperForAudioClassification,
      WhisperForConditionalGeneration,
      WhisperModel,
      WhisperPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_whisper import (
      TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFWhisperForConditionalGeneration,
      TFWhisperModel,
      TFWhisperPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_whisper import (
      FlaxWhisperForAudioClassification,
      FlaxWhisperForConditionalGeneration,
      FlaxWhisperModel,
      FlaxWhisperPreTrainedModel,
  )

else:
 import sys

 lowerCamelCase				:		Tuple     =   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



