def _prepare_trainer(self, program=None, dataset=None, scope=None, thread=0, debug=False, fetch_list=None, fetch_info=None, print_period=100):
    if (scope is None):
        scope = global_scope()
    if (fetch_list is None):
        fetch_list = []
    if (fetch_info is None):
        fetch_info = []
    assert (len(fetch_list) == len(fetch_info))
    compiled = isinstance(program, compiler.CompiledProgram)
    if (not compiled):
        if program._pipeline_opt:
            trainer = TrainerFactory()._create_trainer(program._pipeline_opt)
        else:
            trainer = TrainerFactory()._create_trainer(program._fleet_opt)
        trainer._set_program(program)
    else:
        if program._pipeline_opt:
            trainer = TrainerFactory()._create_trainer(program.program._pipeline_opt)
        else:
            trainer = TrainerFactory()._create_trainer(program.program._fleet_opt)
        trainer._set_program(program.program)
    if (thread <= 0):
        if (dataset.thread_num <= 0):
            raise RuntimeError('You should set thread num first, either in Datasetor in Executor.train_from_dataset')
        else:
            trainer._set_thread(dataset.thread_num)
    else:
        trainer._set_thread(thread)
    trainer._set_debug(debug)
    trainer._set_fetch_var_and_info(fetch_list, fetch_info, print_period)
    return (scope, trainer)
def _prepare_trainer(self, program=None, dataset=None, scope=None, thread=0, debug=False, fetch_list=None, fetch_info=None, print_period=100):
    if (scope is None):
        scope = global_scope()
    if (fetch_list is None):
        fetch_list = []
    if (fetch_info is None):
        fetch_info = []
    assert (len(fetch_list) == len(fetch_info))
    compiled = isinstance(program, compiler.CompiledProgram)
    if (not compiled):
        if program._pipeline_opt:
            trainer = TrainerFactory()._create_trainer(program._pipeline_opt)
        else:
            trainer = TrainerFactory()._create_trainer(program._fleet_opt)
        trainer._set_program(program)
    else:
        if program._pipeline_opt:
            trainer = TrainerFactory()._create_trainer(program.program._pipeline_opt)
        else:
            trainer = TrainerFactory()._create_trainer(program.program._fleet_opt)
        trainer._set_program(program.program)
    if (thread <= 0):
        if (dataset.thread_num <= 0):
            raise RuntimeError('You should set thread num first, either in Datasetor in Executor.train_from_dataset')
        else:
            trainer._set_thread(dataset.thread_num)
    else:
        trainer._set_thread(thread)
    trainer._set_debug(debug)
    trainer._set_fetch_var_and_info(fetch_list, fetch_info, print_period)
    return (scope, trainer)