

'''simple docstring'''







from __future__ import annotations

import matplotlib.pyplot as plt  # type: ignore
import numpy

# initial triangle of Koch snowflake
__lowerCamelCase									=     numpy.array([0, 0])
__lowerCamelCase									=     numpy.array([0.5, 0.8660254])
__lowerCamelCase									=     numpy.array([1, 0])
__lowerCamelCase									=     [VECTOR_1, VECTOR_2, VECTOR_3, VECTOR_1]
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      list[numpy.ndarray]:
       A_						       =   initial_vectors
       for _ in range(UpperCAmelCase__					):
              A_						       =   iteration_step(UpperCAmelCase__					)
       return vectors
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      list[numpy.ndarray]:
       A_						       =   []
       for i, start_vector in enumerate(vectors[:-1]					):
              A_						       =   vectors[i + 1]
              new_vectors.append(UpperCAmelCase__					)
              A_						       =   end_vector - start_vector
              new_vectors.append(start_vector + difference_vector / 3					)
              new_vectors.append(
                  start_vector + difference_vector / 3 + rotate(difference_vector / 3,							60					)					)
              new_vectors.append(start_vector + difference_vector * 2 / 3					)
       new_vectors.append(vectors[-1]					)
       return new_vectors
def    UpperCAmelCase__     (   UpperCAmelCase__,							UpperCAmelCase__					)      ->      numpy.ndarray:
       A_						       =   numpy.radians(UpperCAmelCase__					)
       A_       ,      A_						       =   numpy.cos(UpperCAmelCase__					), numpy.sin(UpperCAmelCase__					)
       A_						       =   numpy.array(((c, -s), (s, c))					)
       return numpy.dot(UpperCAmelCase__,							UpperCAmelCase__					)
def    UpperCAmelCase__     (   UpperCAmelCase__					)      ->      None:
       A_						       =   plt.gca()
       axes.set_aspect("""equal"""					)

       # matplotlib.pyplot.plot takes a list of all x-coordinates and a list of all
       # y-coordinates as inputs, which are constructed from the vector-list using
       # zip()
       A_       ,      A_						       =   zip(*UpperCAmelCase__					)
       plt.plot(UpperCAmelCase__,							UpperCAmelCase__					)
       plt.show()


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      __lowerCamelCase									=     iterate(INITIAL_VECTORS, 5)
      plot(processed_vectors)



'''simple docstring'''







import os
import sys
import unittest


__lowerCamelCase									=     os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, '''utils'''))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
__lowerCamelCase									=     os.path.join(git_repo_path, '''src''', '''transformers''')

__lowerCamelCase									=     '''
{0} = None
'''

__lowerCamelCase									=     '''
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})
'''


__lowerCamelCase									=     '''
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
'''


class        A__   (   unittest.TestCase      ):



    def        snake_case_      (       self							)    ->   Dict:





           '''simple docstring'''
           A_						       =   find_backend("""    _import_structure[\"models.albert\"].append(\"AlbertTokenizerFast\")"""							)
           self.assertIsNone(UpperCamelCase__							)

           A_						       =   find_backend("""    if not is_tokenizers_available():"""							)
           self.assertEqual(UpperCamelCase__		,					"""tokenizers"""							)

           A_						       =   find_backend("""    if not is_tensorflow_text_available():"""							)
           self.assertEqual(UpperCamelCase__		,					"""tensorflow_text"""							)

           A_						       =   find_backend("""    if not (is_sentencepiece_available() and is_tokenizers_available()):"""							)
           self.assertEqual(UpperCamelCase__		,					"""sentencepiece_and_tokenizers"""							)

           A_						       =   find_backend(
               """    if not (is_sentencepiece_available() and is_tensorflow_text_available()):"""							)
           self.assertEqual(UpperCamelCase__		,					"""sentencepiece_and_tensorflow_text"""							)

           A_						       =   find_backend(
               """    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):"""							)
           self.assertEqual(UpperCamelCase__		,					"""sentencepiece_and_tokenizers_and_vision"""							)



    def        snake_case_      (       self							)    ->   int:





           '''simple docstring'''
           A_						       =   read_init()
           # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
           self.assertIn("""torch"""		,					UpperCamelCase__							)
           self.assertIn("""tensorflow_text"""		,					UpperCamelCase__							)
           self.assertIn("""sentencepiece_and_tokenizers"""		,					UpperCamelCase__							)

           # Likewise, we can't assert on the exact content of a key
           self.assertIn("""BertModel"""		,					objects["""torch"""]							)
           self.assertIn("""TFBertModel"""		,					objects["""tf"""]							)
           self.assertIn("""FlaxBertModel"""		,					objects["""flax"""]							)
           self.assertIn("""BertModel"""		,					objects["""torch"""]							)
           self.assertIn("""TFBertTokenizer"""		,					objects["""tensorflow_text"""]							)
           self.assertIn("""convert_slow_tokenizer"""		,					objects["""sentencepiece_and_tokenizers"""]							)



    def        snake_case_      (       self							)    ->   str:





           '''simple docstring'''
           A_						       =   create_dummy_object("""CONSTANT"""		,					"""'torch'"""							)
           self.assertEqual(UpperCamelCase__		,					"""\nCONSTANT = None\n"""							)

           A_						       =   create_dummy_object("""function"""		,					"""'torch'"""							)
           self.assertEqual(
               UpperCamelCase__		,					"""\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"""							)

           A_						       =   """
class FakeClass(metaclass=DummyObject):
    _backends = 'torch'

    def __init__(self, *args, **kwargs):
        requires_backends(self, 'torch')
"""
           A_						       =   create_dummy_object("""FakeClass"""		,					"""'torch'"""							)
           self.assertEqual(UpperCamelCase__		,					UpperCamelCase__							)







    def        snake_case_      (       self							)    ->   str:





           '''simple docstring'''
           A_						       =   """# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, [\"torch\"])


class FakeClass(metaclass=DummyObject):
    _backends = [\"torch\"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, [\"torch\"])
"""
           A_						       =   create_dummy_files({"""torch""": ["""CONSTANT""", """function""", """FakeClass"""]}							)
           self.assertEqual(dummy_files["""torch"""]		,					UpperCamelCase__							)
