#NEWLINE# def update_gradients_expectations( self , dL_dpsi0 , dL_dpsi1 , dL_dpsi2 , Z , variational_posterior ) : #NEWLINE# #INDENT# if ( dL_dpsi2 . ndim == 2 ) : #NEWLINE# #INDENT# self . variance . gradient = ( ( dL_dpsi0 . sum ( ) + dL_dpsi1 . sum ( ) ) + ( ( ( 2.0 * self . variance ) * dL_dpsi2 . sum ( ) ) * variational_posterior . shape [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . variance . gradient = ( ( dL_dpsi0 . sum ( ) + dL_dpsi1 . sum ( ) ) + ( ( 2.0 * self . variance ) * dL_dpsi2 . sum ( ) ) )