[Dy2stat] Add Test and Example Code for Different Access to ProgramTranslator and Fix Related Bug !23958
Created by: zhhsplendid
To prepare for publishing APIs, I added tests for that we can access dy2stat through:
@fluid.dygraph.declarative @fluid.dygraph.jit.declarative fluid.dygraph.ProgramTranslator() fluid.dygraph.dygraph_to_static.ProgramTranslator() fluid.dygraph.dygraph_to_static.program_translator.ProgramTranslator()
It surprised me that we had bugs on those different usages. I have fixed them.
I also added example codes for these new APIs
This PR also pulls my current PR https://github.com/PaddlePaddle/Paddle/pull/23880, so the PR history is long. For reviewer information, you could review this PR after https://github.com/PaddlePaddle/Paddle/pull/23880 is merged