partial gradient checking code