import colorsys

from PIL import Image  # type: ignore





def 		__lowerCamelCase							(UpperCAmelCase__       :							Dict ,	UpperCAmelCase__       :							Optional[int] ,	UpperCAmelCase__       :							List[Any]					):
					SCREAMING_SNAKE_CASE           =    x
					SCREAMING_SNAKE_CASE           =    y
					for step in range(_lowerCamelCase					):  # noqa: B007
										SCREAMING_SNAKE_CASE           =    a * a - b * b + x
										SCREAMING_SNAKE_CASE           =    2 * a * b + y
										SCREAMING_SNAKE_CASE           =    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							(UpperCAmelCase__       :							Dict					):


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





def 		__lowerCamelCase							(UpperCAmelCase__       :							Optional[Any]					):


					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 		__lowerCamelCase							(UpperCAmelCase__       :							Dict = 8_0_0 ,	UpperCAmelCase__       :							List[Any] = 6_0_0 ,	UpperCAmelCase__       :							Any = -0.6 ,	UpperCAmelCase__       :							Optional[int] = 0 ,	UpperCAmelCase__       :							str = 3.2 ,	UpperCAmelCase__       :							Optional[Any] = 5_0 ,	UpperCAmelCase__       :							List[Any] = True ,	):
					SCREAMING_SNAKE_CASE           =    Image.new("RGB" ,	(image_width, image_height)					)
					SCREAMING_SNAKE_CASE           =    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           =    figure_width / image_width * image_height
															SCREAMING_SNAKE_CASE           =    figure_center_x + (image_x / image_width - 0.5) * figure_width
															SCREAMING_SNAKE_CASE           =    figure_center_y + (image_y / image_height - 0.5) * figure_height

															SCREAMING_SNAKE_CASE           =    get_distance(_lowerCamelCase ,	_lowerCamelCase ,	_lowerCamelCase					)

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

					return img


if __name__ == "__main__":
							import doctest

							doctest.testmod()

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





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


_lowerCamelCase   :				Union[str, Any]     			=						logging.get_logger(__name__)

_lowerCamelCase   :				Dict     			=						{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_lowerCamelCase   :				List[Any]     			=						[
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

_lowerCamelCase   :				Optional[Any]     			=						{
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
_lowerCamelCase   :				Any     			=						{f"""funnel-transformer/{name}""": 5_12 for name in _model_names}
_lowerCamelCase   :				Optional[Any]     			=						{f"""funnel-transformer/{name}""": {'''do_lower_case''': True} for name in _model_names}


class   lowercase      (       a       ):
							lowercase__  :    Optional[int]									=							VOCAB_FILES_NAMES
							lowercase__  :    Optional[Any]									=							PRETRAINED_VOCAB_FILES_MAP
							lowercase__  :    Optional[Any]									=							PRETRAINED_INIT_CONFIGURATION
							lowercase__  :    Union[str, Any]									=							FunnelTokenizer
							lowercase__  :    List[Any]									=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowercase__  :    int									=							2




							def __init__(  self				:   str		,							_UpperCamelCase				:   str=None		,							_UpperCamelCase				:   str=None		,							_UpperCamelCase				:   Union[str, Any]=True		,							_UpperCamelCase				:   str="<unk>"		,							_UpperCamelCase				:   Optional[Any]="<sep>"		,							_UpperCamelCase				:   Optional[int]="<pad>"		,							_UpperCamelCase				:   int="<cls>"		,							_UpperCamelCase				:   Dict="<mask>"		,							_UpperCamelCase				:   Union[str, Any]="<s>"		,							_UpperCamelCase				:   Optional[int]="</s>"		,							_UpperCamelCase				:   Dict=True		,							_UpperCamelCase				:   List[Any]=True		,							_UpperCamelCase				:   Any=None		,							_UpperCamelCase				:   Dict="##"		,							**_UpperCamelCase				:   Dict		,							)   ->			Optional[int]:



												'''simple docstring'''

												super().__init__(
												    _UpperCamelCase		,							tokenizer_file=_UpperCamelCase		,							do_lower_case=_UpperCamelCase		,							unk_token=_UpperCamelCase		,							sep_token=_UpperCamelCase		,							pad_token=_UpperCamelCase		,							cls_token=_UpperCamelCase		,							mask_token=_UpperCamelCase		,							bos_token=_UpperCamelCase		,							eos_token=_UpperCamelCase		,							clean_text=_UpperCamelCase		,							tokenize_chinese_chars=_UpperCamelCase		,							strip_accents=_UpperCamelCase		,							wordpieces_prefix=_UpperCamelCase		,							**_UpperCamelCase		,							)

												SCREAMING_SNAKE_CASE           =    json.loads(self.backend_tokenizer.normalizer.__getstate__() )
												if (
												    normalizer_state.get("lowercase"		,							_UpperCamelCase ) != do_lower_case
												    or normalizer_state.get("strip_accents"		,							_UpperCamelCase ) != strip_accents
												    or normalizer_state.get("handle_chinese_chars"		,							_UpperCamelCase ) != tokenize_chinese_chars
												):
																	SCREAMING_SNAKE_CASE           =    getattr(_UpperCamelCase		,							normalizer_state.pop("type" ) )
																	SCREAMING_SNAKE_CASE           =    do_lower_case
																	SCREAMING_SNAKE_CASE           =    strip_accents
																	SCREAMING_SNAKE_CASE           =    tokenize_chinese_chars
																	SCREAMING_SNAKE_CASE           =    normalizer_class(**_UpperCamelCase )

												SCREAMING_SNAKE_CASE           =    do_lower_case




							def 		__snake_case(  self				:   Union[str, Any]		,							_UpperCamelCase				:   Union[str, Any]		,							_UpperCamelCase				:   Dict=None )   ->			List[Any]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    [self.cls_token_id] + token_ids_a + [self.sep_token_id]

												if token_ids_a:
																	output += token_ids_a + [self.sep_token_id]

												return output




							def 		__snake_case(  self				:   int		,							_UpperCamelCase				:   List[int]		,							_UpperCamelCase				:   Optional[List[int]] = None )   ->			List[int]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    [self.sep_token_id]
												SCREAMING_SNAKE_CASE           =    [self.cls_token_id]
												if token_ids_a is None:
																	return len(cls ) * [self.cls_token_type_id] + len(token_ids_a + sep ) * [0]
												return len(cls ) * [self.cls_token_type_id] + len(token_ids_a + sep ) * [0] + len(token_ids_a + sep ) * [1]





							def 		__snake_case(  self				:   Optional[Any]		,							_UpperCamelCase				:   str		,							_UpperCamelCase				:   Optional[str] = None )   ->			Tuple[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE           =    self._tokenizer.model.save(_UpperCamelCase		,							name=_UpperCamelCase )
												return tuple(_UpperCamelCase )




