

"""simple docstring"""




import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)





class  lowerCamelCase    (unittest.TestCase      ):

			def        SCREAMING_SNAKE_CASE					(       self					:    Tuple							) ->     List[Any]:
						SCREAMING_SNAKE_CASE__										=   ["""a""", """b""", """c"""]

						# Defaults to last layer if both are None
						SCREAMING_SNAKE_CASE__				,		SCREAMING_SNAKE_CASE__										=   get_aligned_output_features_output_indices(__UpperCAmelCase     ,					__UpperCAmelCase     ,					__UpperCAmelCase							)
						self.assertEqual(__UpperCAmelCase     ,					["""c"""]							)
						self.assertEqual(__UpperCAmelCase     ,					[2]							)

						# Out indices set to match out features
						SCREAMING_SNAKE_CASE__				,		SCREAMING_SNAKE_CASE__										=   get_aligned_output_features_output_indices(["""a""", """c"""]     ,					__UpperCAmelCase     ,					__UpperCAmelCase							)
						self.assertEqual(__UpperCAmelCase     ,					["""a""", """c"""]							)
						self.assertEqual(__UpperCAmelCase     ,					[0, 2]							)

						# Out features set to match out indices
						SCREAMING_SNAKE_CASE__				,		SCREAMING_SNAKE_CASE__										=   get_aligned_output_features_output_indices(__UpperCAmelCase     ,					[0, 2]     ,					__UpperCAmelCase							)
						self.assertEqual(__UpperCAmelCase     ,					["""a""", """c"""]							)
						self.assertEqual(__UpperCAmelCase     ,					[0, 2]							)

						# Out features selected from negative indices
						SCREAMING_SNAKE_CASE__				,		SCREAMING_SNAKE_CASE__										=   get_aligned_output_features_output_indices(__UpperCAmelCase     ,					[-3, -1]     ,					__UpperCAmelCase							)
						self.assertEqual(__UpperCAmelCase     ,					["""a""", """c"""]							)
						self.assertEqual(__UpperCAmelCase     ,					[-3, -1]							)

			def        SCREAMING_SNAKE_CASE					(       self					:    Dict							) ->     Optional[Any]:
						# Stage names must be set
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(["""a""", """b"""]     ,					(0, 1)     ,					__UpperCAmelCase							)

						# Out features must be a list
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(("""a""", """b""")     ,					(0, 1)     ,					["""a""", """b"""]							)

						# Out features must be a subset of stage names
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(["""a""", """b"""]     ,					(0, 1)     ,					["""a"""]							)

						# Out indices must be a list or tuple
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(__UpperCAmelCase     ,					0     ,					["""a""", """b"""]							)

						# Out indices must be a subset of stage names
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(__UpperCAmelCase     ,					(0, 1)     ,					["""a"""]							)

						# Out features and out indices must be the same length
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(["""a""", """b"""]     ,					(0,)     ,					["""a""", """b""", """c"""]							)

						# Out features should match out indices
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(["""a""", """b"""]     ,					(0, 2)     ,					["""a""", """b""", """c"""]							)

						# Out features and out indices should be in order
						with self.assertRaises(__UpperCAmelCase							):
									verify_out_features_out_indices(["""b""", """a"""]     ,					(0, 1)     ,					["""a""", """b"""]							)

						# Check passes with valid inputs
						verify_out_features_out_indices(["""a""", """b""", """d"""]     ,					(0, 1, -1)     ,					["""a""", """b""", """c""", """d"""]							)





			def        SCREAMING_SNAKE_CASE					(       self					:    Dict							) ->     Union[str, Any]:
						SCREAMING_SNAKE_CASE__										=   BackboneMixin()

						SCREAMING_SNAKE_CASE__										=   ["""a""", """b""", """c"""]
						SCREAMING_SNAKE_CASE__										=   ["""a""", """c"""]
						SCREAMING_SNAKE_CASE__										=   [0, 2]

						# Check that the output features and indices are set correctly
						self.assertEqual(backbone.out_features     ,					["""a""", """c"""]							)
						self.assertEqual(backbone.out_indices     ,					[0, 2]							)

						# Check out features and indices are updated correctly
						SCREAMING_SNAKE_CASE__										=   ["""a""", """b"""]
						self.assertEqual(backbone.out_features     ,					["""a""", """b"""]							)
						self.assertEqual(backbone.out_indices     ,					[0, 1]							)

						SCREAMING_SNAKE_CASE__										=   [-3, -1]
						self.assertEqual(backbone.out_features     ,					["""a""", """c"""]							)
						self.assertEqual(backbone.out_indices     ,					[-3, -1]							)





"""simple docstring"""




import numpy as np

def 						A							(  snake_case__     ):




			'''simple docstring'''


			return (2 / (1 + np.exp(-2 * vector     ))) - 1


if __name__ == "__main__":
						import doctest

						doctest.testmod()


