Add a gradient check utility