fix gradient (or partial derivative) computation with a RB context