#NEWLINE# def test_backward( self ) : #NEWLINE# #INDENT# x = chainer . Variable ( numpy . array ( [ 1 ] ) , name = 'x' ) #NEWLINE# y1 = F . identity ( x ) #NEWLINE# y1 . name = 'y1' #NEWLINE# y2 = F . identity ( x ) #NEWLINE# y2 . name = 'y2' #NEWLINE# z = ( y1 + y2 ) #NEWLINE# z . name = 'z' #NEWLINE# z . grad = numpy . array ( [ 1 ] ) #NEWLINE# z . backward ( retain_grad = True ) #NEWLINE# self . assertEqual ( y1 . grad [ 0 ] , 1 ) #NEWLINE# self . assertEqual ( y2 . grad [ 0 ] , 1 ) #NEWLINE# self . assertEqual ( x . grad [ 0 ] , 2 )