




import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)
class        __snake_case  (unittest.TestCase		):



				def       SCREAMING_SNAKE_CASE       (      self      :		List[Any]      )  ->    Optional[int]:





								'''simple docstring'''




								_lowerCAmelCase    :    Tuple										=      ["""a""", """b""", """c"""]

								# Defaults to last layer if both are None
								_lowerCAmelCase					,    _lowerCAmelCase    :    Dict										=      get_aligned_output_features_output_indices(_UpperCAmelCase		,	_UpperCAmelCase		,	_UpperCAmelCase      )
								self.assertEqual(_UpperCAmelCase		,	["""c"""]      )
								self.assertEqual(_UpperCAmelCase		,	[2]      )

								# Out indices set to match out features
								_lowerCAmelCase					,    _lowerCAmelCase    :    Optional[Any]										=      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
								_lowerCAmelCase					,    _lowerCAmelCase    :    Any										=      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
								_lowerCAmelCase					,    _lowerCAmelCase    :    Union[str, Any]										=      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      :		List[Any]      )  ->    Tuple:





								'''simple docstring'''




								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      :		Optional[Any]      )  ->    List[Any]:





								'''simple docstring'''




								_lowerCAmelCase    :    Optional[int]										=      BackboneMixin()

								_lowerCAmelCase    :    Tuple										=      ["""a""", """b""", """c"""]
								_lowerCAmelCase    :    List[str]										=      ["""a""", """c"""]
								_lowerCAmelCase    :    str										=      [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
								_lowerCAmelCase    :    Optional[Any]										=      ["""a""", """b"""]
								self.assertEqual(backbone.out_features		,	["""a""", """b"""]      )
								self.assertEqual(backbone.out_indices		,	[0, 1]      )

								_lowerCAmelCase    :    List[str]										=      [-3, -1]
								self.assertEqual(backbone.out_features		,	["""a""", """c"""]      )
								self.assertEqual(backbone.out_indices		,	[-3, -1]      )







import numpy as np




def 							_UpperCAmelCase  (UpperCamelCase_ : np.array       ):
				'''simple docstring'''
				return (2 / (1 + np.exp(-2 * vector       ))) - 1


if __name__ == "__main__":
	import doctest

	doctest.testmod()

