
"""simple docstring"""



import doctest
import sys
import warnings
from os.path import abspath, dirname, join

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
a					:	Optional[int]							=		abspath(join(dirname(__file__), '''src'''))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='''ignore''', category=FutureWarning)


def  _UpperCamelCase	(						_A      )    ->  str:





    """simple docstring"""

    config.addinivalue_line(
        """markers"""					,      """is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested"""      )
    config.addinivalue_line(
        """markers"""					,      """is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested"""      )
    config.addinivalue_line("""markers"""					,      """is_pipeline_test: mark test to run only when pipelines are tested"""      )
    config.addinivalue_line("""markers"""					,      """is_staging_test: mark test to run only in the staging environment"""      )
    config.addinivalue_line("""markers"""					,      """accelerate_tests: mark test that require accelerate"""      )
    config.addinivalue_line("""markers"""					,      """tool_tests: mark the tool tests that are run on their specific schedule"""      )


def  _UpperCamelCase	(						_A      )    ->  Any:





    """simple docstring"""

    from transformers.testing_utils import pytest_addoption_shared

    pytest_addoption_shared(__SCREAMING_SNAKE_CASE      )


def  _UpperCamelCase	(						_A      )    ->  Tuple:





    """simple docstring"""

    from transformers.testing_utils import pytest_terminal_summary_main

    _UpperCAmelCase          =   terminalreporter.config.getoption("""--make-reports"""      )
    if make_reports:
        pytest_terminal_summary_main(__SCREAMING_SNAKE_CASE					,      id=__SCREAMING_SNAKE_CASE      )


def  _UpperCamelCase	(						_A					,      _A      )    ->  Union[str, Any]:





    """simple docstring"""

    if exitstatus == 5:
        _UpperCAmelCase          =   0


# Doctest custom flag to ignore output.
a					:	Any							=		doctest.register_optionflag('''IGNORE_RESULT''')

a					:	int							=		doctest.OutputChecker




class 		a_						( snake_case__	):







    def      _snake_case					(			self			:       Union[str, Any]     ,					__UpperCamelCase			:       Union[str, Any]     ,					__UpperCamelCase			:       Union[str, Any]     ,					__UpperCamelCase			:       List[Any]     )		->Dict:






        '''simple docstring'''






        if IGNORE_RESULT & optionflags:
            return True
        return OutputChecker.check_output(self     ,					lowercase_     ,					lowercase_     ,					lowercase_     )







a					:	List[str]							=		CustomOutputChecker
a					:	Any							=		HfDoctestModule







a					:	int							=		HfDocTestParser

"""simple docstring"""



import colorsys

from PIL import Image  # type: ignore


def  _UpperCamelCase	(						_A					,      _A					,      _A      )    ->  float:





    """simple docstring"""

    _UpperCAmelCase          =   x
    _UpperCAmelCase          =   y
    for step in range(_A      ):  # noqa: B007
        _UpperCAmelCase          =   a * a - b * b + x
        _UpperCAmelCase          =   2 * a * b + y
        _UpperCAmelCase          =   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	(						_A      )    ->  tuple:





    """simple docstring"""

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


def  _UpperCamelCase	(						_A      )    ->  tuple:





    """simple docstring"""

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


def  _UpperCamelCase	(						_A = 8_0_0					,      _A = 6_0_0					,      _A = -0.6					,      _A = 0					,      _A = 3.2					,      _A = 5_0					,      _A = True					,      )    ->  Image.Image:





    """simple docstring"""

    _UpperCAmelCase          =   Image.new("""RGB"""					,      (image_width, image_height)      )
    _UpperCAmelCase          =   img.load()

    # loop through the image-coordinates
    for image_x in range(_A      ):
        for image_y in range(_A      ):
            # determine the figure-coordinates based on the image-coordinates
            _UpperCAmelCase          =   figure_width / image_width * image_height
            _UpperCAmelCase          =   figure_center_x + (image_x / image_width - 0.5) * figure_width
            _UpperCAmelCase          =   figure_center_y + (image_y / image_height - 0.5) * figure_height

            _UpperCAmelCase          =   get_distance(_A					,      _A					,      _A      )

            # color the corresponding pixel based on the selected coloring-function
            if use_distance_color_coding:
                _UpperCAmelCase          =   get_color_coded_rgb(_A      )
            else:
                _UpperCAmelCase          =   get_black_and_white_rgb(_A      )

    return img


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 # colored version, full figure
 a					:	List[str]							=		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()