<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def substitute(self, var_map, cont=False, tag=None):
 """Substitute sub-expressions both on the lhs and rhs Args: var_map (dict):
 Dictionary with entries of the form ``{expr: substitution}`` """

        return self.apply(substitute, var_map=var_map, cont=cont, tag=tag)