"""simple docstring"""




from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__				):






       """simple docstring"""





       return math.sqrt(sum(pow(a - b       ,    2				) for a, b in zip(UpperCamelCase__       ,    UpperCamelCase__				)				)				)






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__				):






       """simple docstring"""





       if dataset.ndim != value_array.ndim:
              A__	     =							(
                  'Wrong input data\'s dimensions... '
                  F'''dataset : {dataset.ndim}, value_array : {value_array.ndim}'''
              )
              raise ValueError(UpperCamelCase__				)

       try:
              if dataset.shape[1] != value_array.shape[1]:
                     A__	     =							(
                         'Wrong input data\'s shape... '
                         F'''dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}'''
                     )
                     raise ValueError(UpperCamelCase__				)
       except IndexError:
              if dataset.ndim != value_array.ndim:
                     raise TypeError('Wrong shape'				)

       if dataset.dtype != value_array.dtype:
              A__	     =							(
                  'Input data have different datatype... '
                  F'''dataset : {dataset.dtype}, value_array : {value_array.dtype}'''
              )
              raise TypeError(UpperCamelCase__				)

       A__	     =							[]

       for value in value_array:
              A__	     =							euclidean(UpperCamelCase__       ,    dataset[0]				)
              A__	     =							dataset[0].tolist()

              for dataset_value in dataset[1:]:
                     A__	     =							euclidean(UpperCamelCase__       ,    UpperCamelCase__				)

                     if dist > temp_dist:
                            A__	     =							temp_dist
                            A__	     =							dataset_value.tolist()

              answer.append([vector, dist]				)

       return answer






def   UpperCAmelCase					(	UpperCamelCase__       ,    UpperCamelCase__				):






       """simple docstring"""





       return np.dot(UpperCamelCase__       ,    UpperCamelCase__				) / (norm(UpperCamelCase__				) * norm(UpperCamelCase__				))


if __name__ == "__main__":
    import doctest

    doctest.testmod()






"""simple docstring"""




import unittest

import torch
from torch import nn

from diffusers.models.activations import get_activation
class     UpperCamelCase__(			unittest.TestCase ):





						def 				snake_case__	(       self     )					->				str:
													A__	     =							get_activation('swish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				Optional[Any]:
													A__	     =							get_activation('silu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.SiLU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('mish'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.Mish     )

													self.assertEqual(act(torch.tensor(-2_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





						def 				snake_case__	(       self     )					->				List[str]:
													A__	     =							get_activation('gelu'     )

													self.assertIsInstance(__UpperCAmelCase		,nn.GELU     )

													self.assertEqual(act(torch.tensor(-1_00		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertNotEqual(act(torch.tensor(-1		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(0		,dtype=torch.floataa     )     ).item()		,0     )
													self.assertEqual(act(torch.tensor(20		,dtype=torch.floataa     )     ).item()		,20     )





