<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):
 """Substitute sub-expressions Args: var_map (dict):
 Dictionary with entries of the form ``{expr: substitution}`` """

        if self in var_map:
            return var_map[self]
        return self._substitute(var_map)