




"""simple docstring"""


import numpy as np

A_									=       [
    ['''a''', '''b''', '''c''', '''d''', '''e'''],
    ['''f''', '''g''', '''h''', '''i''', '''k'''],
    ['''l''', '''m''', '''n''', '''o''', '''p'''],
    ['''q''', '''r''', '''s''', '''t''', '''u'''],
    ['''v''', '''w''', '''x''', '''y''', '''z'''],
]






class       lowercase:







 '''simple docstring'''





 def __init__(       self:	Dict	):




   '''simple docstring'''



   _snake_case							:	List[Any]			=						np.array(a_	)


 def 				UpperCamelCase_     (       self:	Union[str, Any],   a_:	str	):




   '''simple docstring'''



   _snake_case							:	Union[str, Any]			=						np.where(letter == self.SQUARE	)
   _snake_case							:	Dict			=						np.concatenate([indexa + 1, indexa + 1]	)
   return indexes


 def 				UpperCamelCase_     (       self:	Union[str, Any],   a_:	int,   a_:	int	):




   '''simple docstring'''



   _snake_case							:	List[str]			=						self.SQUARE[indexa - 1, indexa - 1]
   return letter


 def 				UpperCamelCase_     (       self:	Any,   a_:	str	):




   '''simple docstring'''



   _snake_case							:	int			=						message.lower()
   _snake_case							:	str			=						message.replace(""" """,   """"""	)
   _snake_case							:	Optional[int]			=						message.replace("""j""",   """i"""	)

   _snake_case							:	List[str]			=						np.empty((2, len(a_	))	)
   for letter_index in range(len(a_	)	):
     _snake_case							:	List[Any]			=						self.letter_to_numbers(message[letter_index]	)

     _snake_case							:	Union[str, Any]			=						numbers[0]
     _snake_case							:	Optional[int]			=						numbers[1]

   _snake_case							:	Tuple			=						first_step.reshape(2 * len(a_	)	)
   _snake_case							:	Optional[Any]			=						""""""
   for numbers_index in range(len(a_	)	):
     _snake_case							:	int			=						int(second_step[numbers_index * 2]	)
     _snake_case							:	Tuple			=						int(second_step[(numbers_index * 2) + 1]	)
     _snake_case							:	Optional[int]			=						self.numbers_to_letter(a_,   a_	)
     _snake_case							:	int			=						encoded_message + letter

   return encoded_message


 def 				UpperCamelCase_     (       self:	Any,   a_:	str	):




   '''simple docstring'''



   _snake_case							:	List[Any]			=						message.lower()
   message.replace(""" """,   """"""	)
   _snake_case							:	Any			=						np.empty(2 * len(a_	)	)
   for letter_index in range(len(a_	)	):
     _snake_case							:	List[str]			=						self.letter_to_numbers(message[letter_index]	)
     _snake_case							:	str			=						numbers[0]
     _snake_case							:	Dict			=						numbers[1]

   _snake_case							:	int			=						first_step.reshape((2, len(a_	))	)
   _snake_case							:	Optional[Any]			=						""""""
   for numbers_index in range(len(a_	)	):
     _snake_case							:	Union[str, Any]			=						int(second_step[0, numbers_index]	)
     _snake_case							:	Tuple			=						int(second_step[1, numbers_index]	)
     _snake_case							:	List[str]			=						self.numbers_to_letter(a_,   a_	)
     _snake_case							:	List[str]			=						decoded_message + letter

   return decoded_message








"""simple docstring"""


import os
import sys
import unittest


A_      			=       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
A_      			=       os.path.join(git_repo_path, '''src''', '''diffusers''')






class       lowercase(  unittest.TestCase				):







 '''simple docstring'''





 def 				UpperCamelCase_     (       self:	Tuple	):




   '''simple docstring'''



   _snake_case							:	Optional[int]			=						find_backend("""    if not is_torch_available():"""	)
   self.assertEqual(a_,   """torch"""	)

   # backend_with_underscore = find_backend("    if not is_tensorflow_text_available():")
   # self.assertEqual(backend_with_underscore, "tensorflow_text")

   _snake_case							:	Any			=						find_backend("""    if not (is_torch_available() and is_transformers_available()):"""	)
   self.assertEqual(a_,   """torch_and_transformers"""	)

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

   _snake_case							:	Union[str, Any]			=						find_backend(
       """    if not (is_torch_available() and is_transformers_available() and is_onnx_available()):"""	)
   self.assertEqual(a_,   """torch_and_transformers_and_onnx"""	)


 def 				UpperCamelCase_     (       self:	List[Any]	):




   '''simple docstring'''



   _snake_case							:	Dict			=						read_init()
   # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
   self.assertIn("""torch""",   a_	)
   self.assertIn("""torch_and_transformers""",   a_	)
   self.assertIn("""flax_and_transformers""",   a_	)
   self.assertIn("""torch_and_transformers_and_onnx""",   a_	)

   # Likewise, we can't assert on the exact content of a key
   self.assertIn("""UNet2DModel""",   objects["""torch"""]	)
   self.assertIn("""FlaxUNet2DConditionModel""",   objects["""flax"""]	)
   self.assertIn("""StableDiffusionPipeline""",   objects["""torch_and_transformers"""]	)
   self.assertIn("""FlaxStableDiffusionPipeline""",   objects["""flax_and_transformers"""]	)
   self.assertIn("""LMSDiscreteScheduler""",   objects["""torch_and_scipy"""]	)
   self.assertIn("""OnnxStableDiffusionPipeline""",   objects["""torch_and_transformers_and_onnx"""]	)


 def 				UpperCamelCase_     (       self:	List[str]	):




   '''simple docstring'''



   _snake_case							:	Optional[Any]			=						create_dummy_object("""CONSTANT""",   """'torch'"""	)
   self.assertEqual(a_,   """\nCONSTANT = None\n"""	)

   _snake_case							:	Optional[int]			=						create_dummy_object("""function""",   """'torch'"""	)
   self.assertEqual(
       a_,   """\ndef function(*args, **kwargs):\n    requires_backends(function, 'torch')\n"""	)

   _snake_case							:	List[Any]			=						"""
class FakeClass(metaclass=DummyObject):
    _backends = 'torch'

    def __init__(self, *args, **kwargs):
        requires_backends(self, 'torch')

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, 'torch')

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, 'torch')
"""
   _snake_case							:	Union[str, Any]			=						create_dummy_object("""FakeClass""",   """'torch'"""	)
   self.assertEqual(a_,   a_	)


 def 				UpperCamelCase_     (       self:	Union[str, Any]	):




   '''simple docstring'''



   _snake_case							:	Union[str, Any]			=						"""# 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\"])

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, [\"torch\"])

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, [\"torch\"])
"""
   _snake_case							:	List[Any]			=						create_dummy_files({"""torch""": ["""CONSTANT""", """function""", """FakeClass"""]}	)
   self.assertEqual(dummy_files["""torch"""],   a_	)


