
import unittest

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

class     _UpperCamelCase			(   unittest.TestCase					):






			'''simple docstring'''

			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							UpperCamelCase_:							int		=  ["""a""", """b""", """c"""]

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

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

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

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

			def  lowerCAmelCase__		(    self	:    int ):
							# Stage names must be set
							with self.assertRaises(snake_case_ ):
											verify_out_features_out_indices(["""a""", """b"""]  ,		(0, 1)  ,		snake_case_ )

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

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

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

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

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

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

							# Out features and out indices should be in order
							with self.assertRaises(snake_case_ ):
											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  lowerCAmelCase__		(    self	:    str ):
							UpperCamelCase_:							Any		=  BackboneMixin()

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

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








def     A__   (  lowerCamelCase       ,      lowerCamelCase  )					->		float:
				if mass < 0:
								raise ValueError("""The mass of a body cannot be negative"""  )
				return 0.5 * mass * abs(lowerCamelCase  ) * abs(lowerCamelCase  )


if __name__ == "__main__":
							import doctest

							doctest.testmod(verbose=True)






