Add Gradient Penalty to the loss function

Is there any way to add a function of the network gradients into the loss function in Symbolic API.