def log_sum_exp(input_tensor, reduction_indices=None, keep_dims=False):
 input_tensor = tf.convert_to_tensor(input_tensor)
 dependencies = [tf.verify_tensor_all_finite(input_tensor, msg='')]
 input_tensor = control_flow_ops.with_dependencies(dependencies, input_tensor)
 x_max = tf.reduce_max(input_tensor, reduction_indices, keep_dims=True)
 return (tf.squeeze(x_max) + tf.log(tf.reduce_sum(tf.exp((input_tensor - x_max)), reduction_indices, keep_dims)))

def log_sum_exp ( input_tensor , reduction_indices = None , keep_dims = False ) : input_tensor = tf . convert_to_tensor ( input_tensor ) dependencies = [ tf . verify_tensor_all_finite ( input_tensor , msg = '' ) ] input_tensor = control_flow_ops . with_dependencies ( dependencies , input_tensor ) x_max = tf . reduce_max ( input_tensor , reduction_indices , keep_dims = True ) return ( tf . squeeze ( x_max ) + tf . log ( tf . reduce_sum ( tf . exp ( ( input_tensor - x_max ) ) , reduction_indices , keep_dims ) ) )
compute the log_sum_exp of elements in a tensor .