

'''simple docstring'''

import unittest

import numpy as np

from transformers import is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
				import tensorflow as tf

				from transformers.activations_tf import get_tf_activation







@require_tf
class   UpperCamelCase__   (       unittest.TestCase       ):


		"""simple docstring"""

		def 				A_	(			self      ):


							'''simple docstring'''

							UpperCAmelCase		:							int        =       tf.constant([-1_0_0, -1.0, -0.1, 0, 0.1, 1.0, 100.0]      )
							UpperCAmelCase		:							int        =       get_tf_activation("gelu"      )
							UpperCAmelCase		:							Dict        =       get_tf_activation("gelu_10"      )

							UpperCAmelCase		:							str        =       gelu(snake_case      )
							UpperCAmelCase		:							int        =       geluaa(snake_case      )

							UpperCAmelCase		:							Optional[int]        =       tf.where(y_gelu_aa < 10.0   ,      1.0   ,      0.0      )

							self.assertEqual(tf.math.reduce_max(snake_case      ).numpy().item()   ,      10.0      )
							self.assertTrue(np.allclose(y_gelu * clipped_mask   ,      y_gelu_aa * clipped_mask      )      )







		def 				A_	(			self      ):


							'''simple docstring'''

							get_tf_activation("gelu"      )
							get_tf_activation("gelu_10"      )
							get_tf_activation("gelu_fast"      )
							get_tf_activation("gelu_new"      )
							get_tf_activation("glu"      )
							get_tf_activation("mish"      )
							get_tf_activation("quick_gelu"      )
							get_tf_activation("relu"      )
							get_tf_activation("sigmoid"      )
							get_tf_activation("silu"      )
							get_tf_activation("swish"      )
							get_tf_activation("tanh"      )
							with self.assertRaises(snake_case      ):
												get_tf_activation("bogus"      )
							with self.assertRaises(snake_case      ):
												get_tf_activation(snake_case      )



'''simple docstring'''

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load iris file
a       :      List[Any]  	=			load_iris()
iris.keys()


print(F'Target names: \n {iris.target_names} ')
print(F'\n Features: \n {iris.feature_names}')

# Train set e Test set
a	,						a	,						a	,						a       :      List[Any]  	=			train_test_split(
    iris["data"], iris["target"], random_state=4
)

# KNN

a       :      Tuple  	=			KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

# new array to test
a       :      Optional[int]  	=			[[1, 2, 1, 4], [2, 3, 4, 5]]

a       :      Tuple  	=			knn.predict(X_new)

print(
    F'\nNew array: \n {X_new}\n\nTarget Names Prediction: \n'
    F' {iris["target_names"][prediction]}'
)
