





"""simple docstring"""
import unittest

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






class  _SCREAMING_SNAKE_CASE(       unittest.TestCase  ):




       def    _UpperCamelCase					(						self							)      ->				List[str]:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :Optional[Any]		    =  ['''a''', '''b''', '''c''']

             # Defaults to last layer if both are None
             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :int		    =  get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,['''c''']							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,[2]							)

             # Out indices set to match out features
             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :str		    =  get_aligned_output_features_output_indices(['''a''', '''c''']		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,['''a''', '''c''']							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,[0, 2]							)

             # Out features set to match out indices
             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :List[str]		    =  get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__		,[0, 2]		,SCREAMING_SNAKE_CASE__							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,['''a''', '''c''']							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,[0, 2]							)

             # Out features selected from negative indices
             __SCREAMING_SNAKE_CASE    ,__SCREAMING_SNAKE_CASE       :Optional[int]		    =  get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__		,[-3, -1]		,SCREAMING_SNAKE_CASE__							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,['''a''', '''c''']							)
             self.assertEqual(SCREAMING_SNAKE_CASE__		,[-3, -1]							)




       def    _UpperCamelCase					(						self							)      ->				int:





             """simple docstring"""






             with self.assertRaises(SCREAMING_SNAKE_CASE__							):
                   verify_out_features_out_indices(['''a''', '''b''']		,(0, 1)		,SCREAMING_SNAKE_CASE__							)

             # Out features must be a list
             with self.assertRaises(SCREAMING_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(SCREAMING_SNAKE_CASE__							):
                   verify_out_features_out_indices(['''a''', '''b''']		,(0, 1)		,['''a''']							)

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

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

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

             # Out features should match out indices
             with self.assertRaises(SCREAMING_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(SCREAMING_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    _UpperCamelCase					(						self							)      ->				Tuple:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE       :List[str]		    =  BackboneMixin()

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

             __SCREAMING_SNAKE_CASE       :Optional[int]		    =  [-3, -1]
             self.assertEqual(backbone.out_features		,['''a''', '''c''']							)
             self.assertEqual(backbone.out_indices		,[-3, -1]							)






"""simple docstring"""
import math
import random



def 					__lowerCamelCase       (							a_					:		float			,       a_					:		bool = False							)      ->				float:
      if deriv:
            return value * (1 - value)
      return 1 / (1 + math.exp(-value							))


# Initial Value
lowerCamelCase_       =		0.02



def 					__lowerCamelCase       (							a_					:		int			,       a_					:		int							)      ->				float:
      __SCREAMING_SNAKE_CASE       :Any		    =  float(2 * (random.randint(1			,       1_00							)) - 1							)

      for _ in range(a_							):
            # Forward propagation
            __SCREAMING_SNAKE_CASE       :Any		    =  sigmoid_function(INITIAL_VALUE * weight							)
            # How much did we miss?
            __SCREAMING_SNAKE_CASE       :Tuple		    =  (expected / 1_00) - layer_a
            # Error delta
            __SCREAMING_SNAKE_CASE       :Union[str, Any]		    =  layer_1_error * sigmoid_function(a_			,       a_							)
            # Update weight
            weight += INITIAL_VALUE * layer_1_delta

      return layer_a * 1_00


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  lowerCamelCase_       =		int(input("Expected value: "))
  lowerCamelCase_       =		int(input("Number of propagations: "))
  print(forward_propagation(expected, number_propagations))