#NEWLINE# def __call__( self , y , pred , sample_weight = None ) : #NEWLINE# #INDENT# Y = np . zeros ( ( y . shape [ 0 ] , self . K ) , dtype = np . float64 ) #NEWLINE# for k in range ( self . K ) : #NEWLINE# #INDENT# Y [ : , k ] = ( y == k ) #NEWLINE# #UNINDENT# if ( self is None ) : #NEWLINE# #INDENT# return np . sum ( ( ( ( - 1 ) * ( Y * pred ) . sum ( axis = 1 ) ) + logsumexp ( pred , axis = 1 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return np . sum ( ( ( ( ( - 1 ) * sample_weight ) * ( Y * pred ) . sum ( axis = 1 ) ) + logsumexp ( pred , axis = 1 ) ) )