





'''simple docstring'''


import colorsys

from PIL import Image  # type: ignore
def 							UpperCAmelCase_  (						__lowerCamelCase : float     ,__lowerCamelCase : float     ,__lowerCamelCase : int			):
   lowercase_      :Tuple         =			x
   lowercase_      :Dict         =			y
   for step in range(__lowerCamelCase			):  # noqa: B007
      lowercase_      :Tuple         =			a * a - b * b + x
      lowercase_      :Any         =			2 * a * b + y
      lowercase_      :Union[str, Any]         =			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_55, 2_55, 2_55)
def 							UpperCAmelCase_  (						__lowerCamelCase : float			):
   if distance == 1:
      return (0, 0, 0)
   else:
      return tuple(round(i * 2_55			) for i in colorsys.hsv_to_rgb(__lowerCamelCase     ,1     ,1			)			)
def 							UpperCAmelCase_  (						__lowerCamelCase : int = 8_00     ,__lowerCamelCase : int = 6_00     ,__lowerCamelCase : float = -0.6     ,__lowerCamelCase : float = 0     ,__lowerCamelCase : float = 3.2     ,__lowerCamelCase : int = 50     ,__lowerCamelCase : bool = True     ,):
   lowercase_      :int         =			Image.new("RGB"     ,(image_width, image_height)			)
   lowercase_      :Tuple         =			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
         lowercase_      :int         =			figure_width / image_width * image_height
         lowercase_      :int         =			figure_center_x + (image_x / image_width - 0.5) * figure_width
         lowercase_      :str         =			figure_center_y + (image_y / image_height - 0.5) * figure_height

         lowercase_      :List[Any]         =			get_distance(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			)

         # color the corresponding pixel based on the selected coloring-function
         if use_distance_color_coding:
            lowercase_      :List[str]         =			get_color_coded_rgb(__lowerCamelCase			)
         else:
            lowercase_      :Union[str, Any]         =			get_black_and_white_rgb(__lowerCamelCase			)

   return img


if __name__ == "__main__":
 import doctest

 doctest.testmod()

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









'''simple docstring'''


from typing import TYPE_CHECKING

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


lowerCAmelCase :					int 							={
    '''configuration_clip''': [
        '''CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''CLIPConfig''',
        '''CLIPOnnxConfig''',
        '''CLIPTextConfig''',
        '''CLIPVisionConfig''',
    ],
    '''processing_clip''': ['''CLIPProcessor'''],
    '''tokenization_clip''': ['''CLIPTokenizer'''],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase :					Any 							=['''CLIPTokenizerFast''']

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase :					str 							=['''CLIPFeatureExtractor''']
 lowerCAmelCase :					Optional[int] 							=['''CLIPImageProcessor''']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase :					Any 							=[
     '''CLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''CLIPModel''',
     '''CLIPPreTrainedModel''',
     '''CLIPTextModel''',
     '''CLIPTextModelWithProjection''',
     '''CLIPVisionModel''',
     '''CLIPVisionModelWithProjection''',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase :					Union[str, Any] 							=[
     '''TF_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''TFCLIPModel''',
     '''TFCLIPPreTrainedModel''',
     '''TFCLIPTextModel''',
     '''TFCLIPVisionModel''',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase :					List[Any] 							=[
     '''FlaxCLIPModel''',
     '''FlaxCLIPPreTrainedModel''',
     '''FlaxCLIPTextModel''',
     '''FlaxCLIPTextPreTrainedModel''',
     '''FlaxCLIPVisionModel''',
     '''FlaxCLIPVisionPreTrainedModel''',
 ]


if TYPE_CHECKING:
 from .configuration_clip import (
     CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
     CLIPConfig,
     CLIPOnnxConfig,
     CLIPTextConfig,
     CLIPVisionConfig,
 )
 from .processing_clip import CLIPProcessor
 from .tokenization_clip import CLIPTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_clip_fast import CLIPTokenizerFast

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_clip import CLIPFeatureExtractor
  from .image_processing_clip import CLIPImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_clip import (
      CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
      CLIPModel,
      CLIPPreTrainedModel,
      CLIPTextModel,
      CLIPTextModelWithProjection,
      CLIPVisionModel,
      CLIPVisionModelWithProjection,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_clip import (
      TF_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFCLIPModel,
      TFCLIPPreTrainedModel,
      TFCLIPTextModel,
      TFCLIPVisionModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_clip import (
      FlaxCLIPModel,
      FlaxCLIPPreTrainedModel,
      FlaxCLIPTextModel,
      FlaxCLIPTextPreTrainedModel,
      FlaxCLIPVisionModel,
      FlaxCLIPVisionPreTrainedModel,
  )


else:
 import sys

 lowerCAmelCase :					int 							=_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


