Why the following code about replace in SymPy have errors?

See an answer here: https://github.com/JuliaPy/SymPy.jl/issues/277 . There needs to be a lambda defined on the python side, not the julia side of things.