def replace_grid(old_grid, new_grid, topology_grid):
    """Replaces old hyperparameter search grid with one supplied by YAML."""
    for k in new_grid.keys():
        if k != 'topology_grid':
            old_grid['--{}'.format(k)] = new_grid[k]
    if 'topology_grid' in new_grid:
        topology_grid = new_grid.pop('topology_grid')
    return old_grid, topology_grid
