def _sub_func(expr, sub_dict):
 if (expr in sub_dict):
  return sub_dict[expr]
 elif ((not expr.args) or expr.is_Derivative):
  return expr

def _sub_func ( expr , sub_dict ) : if ( expr in sub_dict ) : return sub_dict [ expr ] elif ( ( not expr . args ) or expr . is_Derivative ) : return expr
perform direct matching substitution .