





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      ):





       '''simple docstring'''







       def 							UpperCAmelCase__			(  self			:   Dict		):
         __snake_case:						List[str]			  =						["""a""", """b""", """c"""]

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

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

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

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




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

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

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

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

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

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

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

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

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

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













from __future__ import annotations

import numpy as np







def       A__							(   SCREAMING_SNAKE_CASE__)       ->   List[str]:
  return np.maximum(0 , SCREAMING_SNAKE_CASE__)


if __name__ == "__main__":
      print(np.array(relu([-1, 0, 5])))  # --> [0, 0, 5]






