I think you tricked yourself with the indexing.
As y[:, 2] only depends on the last column in x, only the last column of the gradient is nonzero (do print(duzdxyz)). Then you take the sec_der as the grad of an all-zero column of duzdxyz.
Best regards
Thomas