#NEWLINE# def make_grad_solve_triangular( ans , a , b , trans = 0 , lower = False , **kwargs ) : #NEWLINE# #INDENT# tri = ( anp . tril if ( lower ^ ( _flip ( a , trans ) == 'N' ) ) else anp . triu ) #NEWLINE# transpose = ( lambda x : ( x if ( _flip ( a , trans ) != 'N' ) else x . T ) ) #NEWLINE# def solve_triangular_grad( g ) : #NEWLINE# #INDENT# al2d = ( lambda x : ( x if ( x . ndim > 1 ) else x [ ( ... , None ) ] ) ) #NEWLINE# v = al2d ( solve_triangular ( a , g , trans = _flip ( a , trans ) , lower = lower ) ) #NEWLINE# return ( - transpose ( tri ( anp . dot ( v , al2d ( ans ) . T ) ) ) ) #NEWLINE# #UNINDENT# return solve_triangular_grad