


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 				lowerCamelCase__(   self     :Dict   )      ->					Any:
												a__    =  ['a', 'b', 'c']

												# Defaults to last layer if both are None
												a__   ,      a__    =  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
												a__   ,      a__    =  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
												a__   ,      a__    =  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
												a__   ,      a__    =  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     :Tuple   )      ->					Union[str, Any]:
												# 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     :List[Any]   )      ->					Optional[int]:
												a__    =  BackboneMixin()

												a__    =  ['a', 'b', 'c']
												a__    =  ['a', 'c']
												a__    =  [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
												a__    =  ['a', 'b']
												self.assertEqual(backbone.out_features    ,['a', 'b']   )
												self.assertEqual(backbone.out_indices    ,[0, 1]   )

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








import unittest

from knapsack import greedy_knapsack as kp







class  snake_case_     (unittest.TestCase   ):
					def 				lowerCamelCase__(   self     :Optional[Any]   )      ->					Union[str, Any]:
												a__    =  [10, 20, 30, 40, 50, 60]
												a__    =  [2, 4, 6, 8, 10, 12]
												a__    =  1_00
												self.assertEqual(kp.calc_profit(__snake_case    ,__snake_case    ,__snake_case   )    ,2_10   )
					def 				lowerCamelCase__(   self     :str   )      ->					Optional[int]:
												self.assertRaisesRegex(__snake_case    ,'max_weight must greater than zero.'   )
					def 				lowerCamelCase__(   self     :Optional[Any]   )      ->					int:
												self.assertRaisesRegex(__snake_case    ,'Weight can not be negative.'   )
					def 				lowerCamelCase__(   self     :str   )      ->					List[str]:
												self.assertRaisesRegex(__snake_case    ,'Profit can not be negative.'   )
					def 				lowerCamelCase__(   self     :str   )      ->					Optional[Any]:
												self.assertRaisesRegex(__snake_case    ,'max_weight must greater than zero.'   )



					def 				lowerCamelCase__(   self     :int   )      ->					List[Any]:
												self.assertRaisesRegex(
												    __snake_case    ,'The length of profit and weight must be same.'   )


if __name__ == "__main__":
						unittest.main()




