Created by: qingqing01
cherry-pick code for double backward.
PR: https://github.com/PaddlePaddle/Paddle/pull/18485