code: def signsimp(expr, evaluate=None):
      """Make all Add sub-expressions canonical wrt sign.
  
      Explanation
      ===========
  
      If an Add subexpression, ``a``, can have a sign extracted,
      as determined by could_extract_minus_sign, it is replaced
      with Mul(-1, a, evaluate=False). This allows signs to be
      extracted from powers and products.
  
      Examples
      ========
  
      >>> from sympy import signsimp, exp, symbols
      >>> from sympy.abc import x, y
      >>> i = symbols('i', odd=True)
      >>> n = -1 + 1/x
      >>> n/x/(-n)**2 - 1/n/x
      (-1 + 1/x)/(x*(1 - 1/x)**2) - 1/(x*(-1 + 1/x))
      >>> signsimp(_)
      0
      >>> x*n + x*-n
      x*(-1 + 1/x) + x*(1 - 1/x)
      >>> signsimp(_)
      0
  
      Since powers automatically handle leading signs
  
      >>> (-2)**i
      -2**i
  
      signsimp can be used to put the base of a power with an integer
      exponent into canonical form:
  
      >>> n**i
      (-1 + 1/x)**i
  
      By default, signsimp does not leave behind any hollow simplification:
      if making an Add canonical wrt sign didn't change the expression, the
      original Add is restored. If this is not desired then the keyword
      ``evaluate`` can be set to False:
  
      >>> e = exp(y - x)
      >>> signsimp(e) == e
      True
      >>> signsimp(e, evaluate=False)
      exp(-(x - y))
  
      """
      if evaluate is None:
          evaluate = global_parameters.evaluate
      expr = sympify(expr)
      if not isinstance(expr, (Expr, Relational)) or expr.is_Atom:
          return expr
      # get rid of an pre-existing unevaluation regarding sign
      e = expr.replace(
          lambda x: x.is_Mul and -(-x) != x, lambda x: -(-x)
      )
      e = sub_post(sub_pre(e))
      if not isinstance(e, (Expr, Relational)) or e.is_Atom:
          return e
      if e.is_Add:
          rv = e.func(*[signsimp(a) for a in e.args])
          if (
              not evaluate
              and isinstance(rv, Add)
              and rv.could_extract_minus_sign()
          ):
              return Mul(S.NegativeOne, -rv, evaluate=False)
          return rv
      if evaluate:
          e = e.replace(
              lambda x: x.is_Mul and -(-x) != x, lambda x: -(-x)
          )
      return e
  
imports: from collections import defaultdict
  from sympy.concrete.products import Product
  from sympy.concrete.summations import Sum
  from sympy.core import Basic, S, Add, Mul, Pow, Symbol, sympify, expand_func, Function, Dummy, Expr, factor_terms, expand_power_exp, Eq
  from sympy.core.exprtools import factor_nc
  from sympy.core.parameters import global_parameters
  from sympy.core.function import expand_log, count_ops, _mexpand, nfloat, expand_mul, expand
  from sympy.core.numbers import Float, I, pi, Rational
  from sympy.core.relational import Relational
  from sympy.core.rules import Transform
  from sympy.core.sorting import ordered
  from sympy.core.sympify import _sympify
  from sympy.core.traversal import bottom_up, walk
  from sympy.functions import gamma, exp, sqrt, log, exp_polar, re
  from sympy.functions.combinatorial.factorials import CombinatorialFunction
  from sympy.functions.elementary.complexes import unpolarify, Abs, sign
  from sympy.functions.elementary.exponential import ExpBase
  from sympy.functions.elementary.hyperbolic import HyperbolicFunction
  from sympy.functions.elementary.integers import ceiling
  from sympy.functions.elementary.piecewise import Piecewise, piecewise_fold, piecewise_simplify
  from sympy.functions.elementary.trigonometric import TrigonometricFunction
  from sympy.functions.special.bessel import BesselBase, besselj, besseli, besselk, bessely, jn
  from sympy.functions.special.tensor_functions import KroneckerDelta
  from sympy.integrals.integrals import Integral
  from sympy.matrices.expressions import MatrixExpr, MatAdd, MatMul, MatPow, MatrixSymbol
  from sympy.polys import together, cancel, factor
  from sympy.polys.numberfields.minpoly import _is_sum_surds, _minimal_polynomial_sq
  from sympy.simplify.combsimp import combsimp
  from sympy.simplify.cse_opts import sub_pre, sub_post
  from sympy.simplify.hyperexpand import hyperexpand
  from sympy.simplify.powsimp import powsimp
  from sympy.simplify.radsimp import radsimp, fraction, collect_abs
  from sympy.simplify.sqrtdenest import sqrtdenest
  from sympy.simplify.trigsimp import trigsimp, exptrigsimp
  from sympy.utilities.decorator import deprecated
  from sympy.utilities.iterables import has_variety, sift, subsets, iterable
  from sympy.utilities.misc import as_int
  import mpmath
label_desc: Use image node_id 7 for calling a global function with example usage: signsimp(expr, evaluate) and returns: e, expr, e, rv, Mul