






"""simple docstring"""
import unittest

from transformers import AlbertTokenizer, AlbertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


lowerCamelCase_       =		get_tests_dir("fixtures/spiece.model")






@require_sentencepiece
@require_tokenizers
class  _SCREAMING_SNAKE_CASE(       __lowercase   ,     unittest.TestCase  ):
       SCREAMING_SNAKE_CASE_       :				List[str]     						=  AlbertTokenizer
       SCREAMING_SNAKE_CASE_       :				Any     						=  AlbertTokenizerFast
       SCREAMING_SNAKE_CASE_       :				Any     						=  True
       SCREAMING_SNAKE_CASE_       :				str     						=  True
       SCREAMING_SNAKE_CASE_       :				Union[str, Any]     						=  True




       def    _UpperCamelCase					(						self							)      ->				Any:





             """simple docstring"""






             super().setUp()

             # We have a SentencePiece fixture for testing
             __SCREAMING_SNAKE_CASE       :List[Any]		    =  AlbertTokenizer(_a							)
             tokenizer.save_pretrained(self.tmpdirname							)




       def    _UpperCamelCase					(						self		,SCREAMING_SNAKE_CASE__							)      ->				Optional[int]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  '''this is a test'''
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  '''this is a test'''
             return input_text, output_text




       def    _UpperCamelCase					(						self							)      ->				Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :List[Any]		    =  '''<pad>'''
             __SCREAMING_SNAKE_CASE       :int		    =  0

             self.assertEqual(self.get_tokenizer()._convert_token_to_id(_a							)		,_a							)
             self.assertEqual(self.get_tokenizer()._convert_id_to_token(_a							)		,_a							)




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Any		    =  list(self.get_tokenizer().get_vocab().keys()							)

             self.assertEqual(vocab_keys[0]		,'''<pad>'''							)
             self.assertEqual(vocab_keys[1]		,'''<unk>'''							)
             self.assertEqual(vocab_keys[-1]		,'''▁eloquent'''							)
             self.assertEqual(len(_a							)		,3_00_00							)




       def    _UpperCamelCase					(						self							)      ->				Dict:





             """simple docstring"""






             self.assertEqual(self.get_tokenizer().vocab_size		,3_00_00							)




       def    _UpperCamelCase					(						self							)      ->				Tuple:





             """simple docstring"""






             if not self.test_rust_tokenizer:
                   return

             __SCREAMING_SNAKE_CASE       :int		    =  self.get_tokenizer()
             __SCREAMING_SNAKE_CASE       :Any		    =  self.get_rust_tokenizer()

             __SCREAMING_SNAKE_CASE       :Any		    =  '''I was born in 92000, and this is falsé.'''

             __SCREAMING_SNAKE_CASE       :int		    =  tokenizer.tokenize(_a							)
             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  rust_tokenizer.tokenize(_a							)
             self.assertListEqual(_a		,_a							)

             __SCREAMING_SNAKE_CASE       :Dict		    =  tokenizer.encode(_a		,add_special_tokens=_a							)
             __SCREAMING_SNAKE_CASE       :Any		    =  rust_tokenizer.encode(_a		,add_special_tokens=_a							)
             self.assertListEqual(_a		,_a							)

             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  self.get_rust_tokenizer()
             __SCREAMING_SNAKE_CASE       :List[str]		    =  tokenizer.encode(_a							)
             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  rust_tokenizer.encode(_a							)
             self.assertListEqual(_a		,_a							)




       def    _UpperCamelCase					(						self							)      ->				List[Any]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Dict		    =  AlbertTokenizer(_a		,keep_accents=_a							)

             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  tokenizer.tokenize('''This is a test'''							)
             self.assertListEqual(_a		,['''▁this''', '''▁is''', '''▁a''', '''▁test''']							)

             self.assertListEqual(tokenizer.convert_tokens_to_ids(_a							)		,[48, 25, 21, 12_89]							)

             __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  tokenizer.tokenize('''I was born in 92000, and this is falsé.'''							)
             self.assertListEqual(
                 _a		,['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''é''', '''.''']							)
             __SCREAMING_SNAKE_CASE       :Tuple		    =  tokenizer.convert_tokens_to_ids(_a							)
             self.assertListEqual(_a		,[31, 23, 3_86, 19, 5_61, 30_50, 15, 17, 48, 25, 82_56, 18, 1, 9]							)

             __SCREAMING_SNAKE_CASE       :List[Any]		    =  tokenizer.convert_ids_to_tokens(_a							)
             self.assertListEqual(
                 _a		,['''▁i''', '''▁was''', '''▁born''', '''▁in''', '''▁9''', '''2000''', ''',''', '''▁and''', '''▁this''', '''▁is''', '''▁fal''', '''s''', '''<unk>''', '''.''']		,)




       def    _UpperCamelCase					(						self							)      ->				List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  AlbertTokenizer(_a							)

             __SCREAMING_SNAKE_CASE       :str		    =  tokenizer.encode('''sequence builders'''							)
             __SCREAMING_SNAKE_CASE       :Tuple		    =  tokenizer.encode('''multi-sequence build'''							)

             __SCREAMING_SNAKE_CASE       :List[str]		    =  tokenizer.build_inputs_with_special_tokens(_a							)
             __SCREAMING_SNAKE_CASE       :int		    =  tokenizer.build_inputs_with_special_tokens(_a		,_a							)

             assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
             assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
                 tokenizer.sep_token_id
             ]




       @slow
       def    _UpperCamelCase					(						self							)      ->				Any:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  {'''attention_mask''': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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_41, 6, 29, 84, 25_12, 24_30, 7_82, 1_86_84, 27_61, 19, 8_08, 24_30, 25_56, 17, 8_55, 14_80, 94_77, 40_91, 1_28, 1_17_12, 15, 71_03, 21_53, 6_73, 17, 2_48_83, 99_90, 9, 3], [2, 1_15_02, 25, 10_06, 20, 7_82, 8, 1_18_09, 8_55, 17_32, 1_93_93, 1_86_67, 37, 3_67, 2_10_18, 69, 18_54, 34, 1_18_60, 1_91_24, 27, 1_56, 2_25, 17, 1_93, 41_41, 19, 65, 91_24, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 14, 22_31, 8_86, 23_85, 1_76_59, 84, 14, 1_67_92, 19_52, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], '''token_type_ids''': [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
             # fmt: on

             self.tokenizer_integration_test_util(
                 expected_encoding=_a		,model_name='''albert-base-v2'''		,revision='''6b6560eaf5ff2e250b00c50f380c5389a9c2d82e'''		,)






"""simple docstring"""
import colorsys

from PIL import Image  # type: ignore



def 					__lowerCamelCase       (							a_					:		float			,       a_					:		float			,       a_					:		int							)      ->				float:
      __SCREAMING_SNAKE_CASE       :List[Any]		    =  x
      __SCREAMING_SNAKE_CASE       :List[Any]		    =  y
      for step in range(a_							):  # noqa: B007
            __SCREAMING_SNAKE_CASE       :Dict		    =  a * a - b * b + x
            __SCREAMING_SNAKE_CASE       :Tuple		    =  2 * a * b + y
            __SCREAMING_SNAKE_CASE       :Dict		    =  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       (							a_					:		float							)      ->				tuple:
      if distance == 1:
            return (0, 0, 0)
      else:
            return (2_55, 2_55, 2_55)



def 					__lowerCamelCase       (							a_					:		float							)      ->				tuple:
      if distance == 1:
            return (0, 0, 0)
      else:
            return tuple(round(i * 2_55							) for i in colorsys.hsv_to_rgb(a_			,       1			,       1							)							)



def 					__lowerCamelCase       (							a_					:		int = 8_00			,       a_					:		int = 6_00			,       a_					:		float = -0.6			,       a_					:		float = 0			,       a_					:		float = 3.2			,       a_					:		int = 50			,       a_					:		bool = True			,       )      ->				Image.Image:
      __SCREAMING_SNAKE_CASE       :Optional[int]		    =  Image.new('''RGB'''			,       (image_width, image_height)							)
      __SCREAMING_SNAKE_CASE       :Tuple		    =  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
                  __SCREAMING_SNAKE_CASE       :Dict		    =  figure_width / image_width * image_height
                  __SCREAMING_SNAKE_CASE       :str		    =  figure_center_x + (image_x / image_width - 0.5) * figure_width
                  __SCREAMING_SNAKE_CASE       :Tuple		    =  figure_center_y + (image_y / image_height - 0.5) * figure_height

                  __SCREAMING_SNAKE_CASE       :List[Any]		    =  get_distance(a_			,       a_			,       a_							)

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

      return img


if __name__ == "__main__":
  import doctest

  doctest.testmod()

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