Customized objective function with weights for multi class

I tried to create a customized objective function for multi class problem with different weights to different classes.

gist is here: https://gist.github.com/Chandrak1907/5587eaad7b51c101975c67830fd97b37

When I defined,
COST_MATRIX = np.matrix([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
I get below confusion matrix:

[[19  0  0]
 [ 0  9  1]
 [ 0  0 16]]

When I changed cost matrix to differently weigh different classes as below:

COST_MATRIX = np.matrix([[0, 10, 20], [10, 0, 10], [20, 10, 0]])

I get below confusion matrix:

[[ 0 19 0]
[ 0 10 0]
[ 0 16 0]]

I see that gradient and hessian are not changing with new cost matrix.

I referred to below existing topics–
https://github.com/dmlc/xgboost/issues/2113