code: def test_issue_4362():
      neg = Symbol("neg", negative=True)
      nonneg = Symbol("nonneg", nonnegative=True)
      any = Symbol("any")
      num, den = sqrt(1 / neg).as_numer_denom()
      assert num == sqrt(-1)
      assert den == sqrt(-neg)
      num, den = sqrt(1 / nonneg).as_numer_denom()
      assert num == 1
      assert den == sqrt(nonneg)
      num, den = sqrt(1 / any).as_numer_denom()
      assert num == sqrt(1 / any)
      assert den == 1
  
      def eqn(num, den, pow):
          return (num / den) ** pow
  
      npos = 1
      nneg = -1
      dpos = 2 - sqrt(3)
      dneg = 1 - sqrt(3)
      assert dpos > 0 and dneg < 0 and npos > 0 and nneg < 0
      # pos or neg integer
      eq = eqn(npos, dpos, 2)
      assert eq.is_Pow and eq.as_numer_denom() == (1, dpos**2)
      eq = eqn(npos, dneg, 2)
      assert eq.is_Pow and eq.as_numer_denom() == (1, dneg**2)
      eq = eqn(nneg, dpos, 2)
      assert eq.is_Pow and eq.as_numer_denom() == (1, dpos**2)
      eq = eqn(nneg, dneg, 2)
      assert eq.is_Pow and eq.as_numer_denom() == (1, dneg**2)
      eq = eqn(npos, dpos, -2)
      assert eq.is_Pow and eq.as_numer_denom() == (dpos**2, 1)
      eq = eqn(npos, dneg, -2)
      assert eq.is_Pow and eq.as_numer_denom() == (dneg**2, 1)
      eq = eqn(nneg, dpos, -2)
      assert eq.is_Pow and eq.as_numer_denom() == (dpos**2, 1)
      eq = eqn(nneg, dneg, -2)
      assert eq.is_Pow and eq.as_numer_denom() == (dneg**2, 1)
      # pos or neg rational
      pow = S.Half
      eq = eqn(npos, dpos, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          npos**pow,
          dpos**pow,
      )
      eq = eqn(npos, dneg, pow)
      assert eq.is_Pow is False and eq.as_numer_denom() == (
          (-npos) ** pow,
          (-dneg) ** pow,
      )
      eq = eqn(nneg, dpos, pow)
      assert not eq.is_Pow or eq.as_numer_denom() == (
          nneg**pow,
          dpos**pow,
      )
      eq = eqn(nneg, dneg, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-nneg) ** pow,
          (-dneg) ** pow,
      )
      eq = eqn(npos, dpos, -pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          dpos**pow,
          npos**pow,
      )
      eq = eqn(npos, dneg, -pow)
      assert eq.is_Pow is False and eq.as_numer_denom() == (
          -((-npos) ** pow) * (-dneg) ** pow,
          npos,
      )
      eq = eqn(nneg, dpos, -pow)
      assert not eq.is_Pow or eq.as_numer_denom() == (
          dpos**pow,
          nneg**pow,
      )
      eq = eqn(nneg, dneg, -pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-dneg) ** pow,
          (-nneg) ** pow,
      )
      # unknown exponent
      pow = 2 * any
      eq = eqn(npos, dpos, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          npos**pow,
          dpos**pow,
      )
      eq = eqn(npos, dneg, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-npos) ** pow,
          (-dneg) ** pow,
      )
      eq = eqn(nneg, dpos, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          nneg**pow,
          dpos**pow,
      )
      eq = eqn(nneg, dneg, pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-nneg) ** pow,
          (-dneg) ** pow,
      )
      eq = eqn(npos, dpos, -pow)
      assert eq.as_numer_denom() == (dpos**pow, npos**pow)
      eq = eqn(npos, dneg, -pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-dneg) ** pow,
          (-npos) ** pow,
      )
      eq = eqn(nneg, dpos, -pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          dpos**pow,
          nneg**pow,
      )
      eq = eqn(nneg, dneg, -pow)
      assert eq.is_Pow and eq.as_numer_denom() == (
          (-dneg) ** pow,
          (-nneg) ** pow,
      )
  
      assert ((1 / (1 + x / 3)) ** (-S.One)).as_numer_denom() == (
          3 + x,
          3,
      )
      notp = Symbol(
          "notp", positive=False
      )  # not positive does not imply real
      b = (1 + x / notp) ** -2
      assert (b ** (-y)).as_numer_denom() == (1, b**y)
      assert (b ** (-S.One)).as_numer_denom() == (
          (notp + x) ** 2,
          notp**2,
      )
      nonp = Symbol("nonp", nonpositive=True)
      assert (((1 + x / nonp) ** -2) ** (-S.One)).as_numer_denom() == (
          (-nonp - x) ** 2,
          nonp**2,
      )
  
      n = Symbol("n", negative=True)
      assert (x**n).as_numer_denom() == (1, x**-n)
      assert sqrt(1 / n).as_numer_denom() == (S.ImaginaryUnit, sqrt(-n))
      n = Symbol("0 or neg", nonpositive=True)
      # if x and n are split up without negating each term and n is negative
      # then the answer might be wrong; if n is 0 it won't matter since
      # 1/oo and 1/zoo are both zero as is sqrt(0)/sqrt(-x) unless x is also
      # zero (in which case the negative sign doesn't matter):
      # 1/sqrt(1/-1) = -I but sqrt(-1)/sqrt(1) = I
      assert (1 / sqrt(x / n)).as_numer_denom() == (sqrt(-n), sqrt(-x))
      c = Symbol("c", complex=True)
      e = sqrt(1 / c)
      assert e.as_numer_denom() == (e, 1)
      i = Symbol("i", integer=True)
      assert ((1 + x / y) ** i).as_numer_denom() == (
          (x + y) ** i,
          y**i,
      )
  
imports: from sympy.core import Basic, Rational, Symbol, S, Float, Integer, Mul, Number, Pow, Expr, I, nan, pi, symbols, oo, zoo, N
  from sympy.core.parameters import global_parameters
  from sympy.core.tests.test_evalf import NS
  from sympy.core.function import expand_multinomial
  from sympy.functions.elementary.miscellaneous import sqrt, cbrt
  from sympy.functions.elementary.exponential import exp, log
  from sympy.functions.special.error_functions import erf
  from sympy.functions.elementary.trigonometric import sin, cos, tan, sec, csc, atan
  from sympy.functions.elementary.hyperbolic import cosh, sinh, tanh
  from sympy.polys import Poly
  from sympy.series.order import O
  from sympy.sets import FiniteSet
  from sympy.core.power import power
  from sympy.core.intfunc import integer_nthroot
  from sympy.testing.pytest import warns, _both_exp_pow
  from sympy.utilities.exceptions import SymPyDeprecationWarning
  from sympy.abc import a, b, c, x, y
label_desc: Use image node_id 8 for calling a global function with example usage: test_issue_4362() and returns: unknown