importpickleimportsiximportwarningsfromfunctoolsimportpartialimportpaddle.fluidasfluiddefload(program,model_path,executor=None,var_list=None):""" To load python2 saved models in python3. """try:fluid.load(program,model_path,executor,var_list)exceptUnicodeDecodeError:warnings.warn("An UnicodeDecodeError is catched, which might be caused by loading ""a python2 saved model. Encoding of pickle.load would be set and ""load again automatically.")ifsix.PY3:load_bak=pickle.loadpickle.load=partial(load_bak,encoding="latin1")fluid.load(program,model_path,executor,var_list)pickle.load=load_bak