code: def piecewise_exclusive(expr, *, skip_nan=False, deep=True):
      """
      Rewrite :class:`Piecewise` with mutually exclusive conditions.
  
      Explanation
      ===========
  
      SymPy represents the conditions of a :class:`Piecewise` in an
      "if-elif"-fashion, allowing more than one condition to be simultaneously
      True. The interpretation is that the first condition that is True is the
      case that holds. While this is a useful representation computationally it
      is not how a piecewise formula is typically shown in a mathematical text.
      The :func:`piecewise_exclusive` function can be used to rewrite any
      :class:`Piecewise` with more typical mutually exclusive conditions.
  
      Note that further manipulation of the resulting :class:`Piecewise`, e.g.
      simplifying it, will most likely make it non-exclusive. Hence, this is
      primarily a function to be used in conjunction with printing the Piecewise
      or if one would like to reorder the expression-condition pairs.
  
      If it is not possible to determine that all possibilities are covered by
      the different cases of the :class:`Piecewise` then a final
      :class:`~sympy.core.numbers.NaN` case will be included explicitly. This
      can be prevented by passing ``skip_nan=True``.
  
      Examples
      ========
  
      >>> from sympy import piecewise_exclusive, Symbol, Piecewise, S
      >>> x = Symbol('x', real=True)
      >>> p = Piecewise((0, x < 0), (S.Half, x <= 0), (1, True))
      >>> piecewise_exclusive(p)
      Piecewise((0, x < 0), (1/2, Eq(x, 0)), (1, x > 0))
      >>> piecewise_exclusive(Piecewise((2, x > 1)))
      Piecewise((2, x > 1), (nan, x <= 1))
      >>> piecewise_exclusive(Piecewise((2, x > 1)), skip_nan=True)
      Piecewise((2, x > 1))
  
      Parameters
      ==========
  
      expr: a SymPy expression.
          Any :class:`Piecewise` in the expression will be rewritten.
      skip_nan: ``bool`` (default ``False``)
          If ``skip_nan`` is set to ``True`` then a final
          :class:`~sympy.core.numbers.NaN` case will not be included.
      deep:  ``bool`` (default ``True``)
          If ``deep`` is ``True`` then :func:`piecewise_exclusive` will rewrite
          any :class:`Piecewise` subexpressions in ``expr`` rather than just
          rewriting ``expr`` itself.
  
      Returns
      =======
  
      An expression equivalent to ``expr`` but where all :class:`Piecewise` have
      been rewritten with mutually exclusive conditions.
  
      See Also
      ========
  
      Piecewise
      piecewise_fold
      """
  
      def make_exclusive(*pwargs):
          cumcond = false
          newargs = []
  
          # Handle the first n-1 cases
          for expr_i, cond_i in pwargs[:-1]:
              cancond = And(cond_i, Not(cumcond)).simplify()
              cumcond = Or(cond_i, cumcond).simplify()
              newargs.append((expr_i, cancond))
  
          # For the nth case defer simplification of cumcond
          expr_n, cond_n = pwargs[-1]
          cancond_n = And(cond_n, Not(cumcond)).simplify()
          newargs.append((expr_n, cancond_n))
  
          if not skip_nan:
              cumcond = Or(cond_n, cumcond).simplify()
              if cumcond is not true:
                  newargs.append((Undefined, Not(cumcond).simplify()))
  
          return Piecewise(*newargs, evaluate=False)
  
      if deep:
          return expr.replace(Piecewise, make_exclusive)
      elif isinstance(expr, Piecewise):
          return make_exclusive(*expr.args)
      else:
          return expr
  
imports: from sympy.core import S, Function, diff, Tuple, Dummy, Mul
  from sympy.core.basic import Basic, as_Basic
  from sympy.core.numbers import Rational, NumberSymbol, _illegal
  from sympy.core.parameters import global_parameters
  from sympy.core.relational import Lt, Gt, Eq, Ne, Relational, _canonical, _canonical_coeff
  from sympy.core.sorting import ordered
  from sympy.functions.elementary.miscellaneous import Max, Min
  from sympy.logic.boolalg import And, Boolean, distribute_and_over_or, Not, true, false, Or, ITE, simplify_logic, to_cnf, distribute_or_over_and
  from sympy.utilities.iterables import uniq, sift, common_prefix
  from sympy.utilities.misc import filldedent, func_name
  from itertools import product
label_desc: Use image node_id 8 for calling a global function with example usage: piecewise_exclusive(expr) and returns: Piecewise, expr, make_exclusive, expr