Created by: Superjomn
Fixes: https://github.com/PaddlePaddle/Paddle/issues/10611
This is a part of the large PR https://github.com/PaddlePaddle/Paddle/pull/10459 It is based on the PR https://github.com/PaddlePaddle/Paddle/pull/10522 and should not merge before that PR.