'''simple docstring'''




import unittest

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





class     __magic_name__						(    unittest.TestCase):







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Any    ):
										lowercase_					:			List[str]										=       ["""a""", """b""", """c"""]

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

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

										# Out features set to match out indices
										lowercase_						,						lowercase_					:			Optional[int]										=       get_aligned_output_features_output_indices(lowercase_				,			[0, 2]				,			lowercase_    )
										self.assertEqual(lowercase_				,			["""a""", """c"""]    )
										self.assertEqual(lowercase_				,			[0, 2]    )

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







			def 	SCREAMING_SNAKE_CASE_     (	self				:  Any    ):
										# Stage names must be set
										with self.assertRaises(lowercase_    ):
																	verify_out_features_out_indices(["""a""", """b"""]				,			(0, 1)				,			lowercase_    )

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

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

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

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

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

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

										# Out features and out indices should be in order
										with self.assertRaises(lowercase_    ):
																	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				:  Any    ):
										lowercase_					:			Optional[int]										=       BackboneMixin()

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

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






'''simple docstring'''




def 							lowerCamelCase	(      UpperCAmelCase__       :					int      ,      UpperCAmelCase__       :					int )			->      bool:
							return numa ^ numa < 0


if __name__ == "__main__":
						import doctest

						doctest.testmod()





