human
I wrote the below code

    new_namedict = {}
    for (l, r) in namedict.items():
        if (l != r):
            new_namedict[l] = r
    def replace_name(var, namedict):
        assert isinstance(var, ir.Var)
        while (var.name in namedict):
            var = ir.Var(var.scope, namedict[var.name], var.loc)
        return var
    visit_vars(blocks, replace_name, new_namedict)

What's a good function header?
assistant
#Here's a good function header.

def replace_var_names(blocks, namedict):