def METHOD_NAME(line, cell):
    # search for federatedml path
    base_path = None
    for p in sys.path:
        if p.endswith('/fate/python'):
            base_path = p
            break
    if base_path is None:
        raise ValueError(
            'cannot find fate/python in system path, please check your configuration')
    base_path = base_path + '/federatedml/'
    model_pth = 'nn/model_zoo/'
    dataset_pth = 'nn/dataset/'
    trainer_pth = 'nn/homo/trainer/'
    aggregator_pth = 'framework/homo/aggregator/'
    loss_path = 'nn/loss/'
    mode_map = {
        'model': model_pth,
        'trainer': trainer_pth,
        'aggregator': aggregator_pth,
        'dataset': dataset_pth,
        'loss': loss_path
    }
    args = line.split()
    assert len(
        args) == 2, "input args len is not 2, got {} \n expect format: %%save_to_fate SAVE_MODE FILENAME \n SAVE_MODE in ['model', 'dataset', 'trainer', 'loss', 'aggregator']   FILE_NAME xxx.py".format(args)
    modes_avail = ['model', 'dataset', 'trainer', 'aggregator', 'loss']
    save_mode = args[0]
    file_name = args[1]
    assert save_mode in modes_avail, 'avail modes are {}, got {}'.format(
        modes_avail, save_mode)
    assert file_name.endswith('.py'), 'save file should be a .py'
    with open(base_path + mode_map[save_mode] + file_name, 'w') as f:
        f.write(cell)
    ipy.get_ipython().run_cell(cell)