code: def test_inverse_mellin_transform():
      from sympy.core.function import expand
      from sympy.functions.elementary.miscellaneous import Max, Min
      from sympy.functions.elementary.trigonometric import cot
      from sympy.simplify.powsimp import powsimp
      from sympy.simplify.simplify import simplify
  
      IMT = inverse_mellin_transform
  
      assert IMT(gamma(s), s, x, (0, oo)) == exp(-x)
      assert IMT(gamma(-s), s, x, (-oo, 0)) == exp(-1 / x)
      assert simplify(IMT(s / (2 * s**2 - 2), s, x, (2, oo))) == (
          x**2 + 1
      ) * Heaviside(1 - x) / (4 * x)
  
      # test passing "None"
      assert IMT(1 / (s**2 - 1), s, x, (-1, None)) == -x * Heaviside(
          -x + 1
      ) / 2 - Heaviside(x - 1) / (2 * x)
      assert IMT(1 / (s**2 - 1), s, x, (None, 1)) == -x * Heaviside(
          -x + 1
      ) / 2 - Heaviside(x - 1) / (2 * x)
  
      # test expansion of sums
      assert (
          IMT(gamma(s) + gamma(s - 1), s, x, (1, oo))
          == (x + 1) * exp(-x) / x
      )
  
      # test factorisation of polys
      r = symbols("r", real=True)
      assert IMT(1 / (s**2 + 1), s, exp(-x), (None, oo)).subs(
          x, r
      ).rewrite(sin).simplify() == sin(r) * Heaviside(1 - exp(-r))
  
      # test multiplicative substitution
      _a, _b = symbols("a b", positive=True)
      assert IMT(
          _b ** (-s / _a) * factorial(s / _a) / s, s, x, (0, oo)
      ) == exp(-_b * x**_a)
      assert IMT(
          factorial(_a / _b + s / _b) / (_a + s), s, x, (-_a, oo)
      ) == x**_a * exp(-(x**_b))
  
      def simp_pows(expr):
          return simplify(
              powsimp(expand_mul(expr, deep=False), force=True)
          ).replace(exp_polar, exp)
  
      # Now test the inverses of all direct transforms tested above
  
      # Section 8.4.2
      nu = symbols("nu", real=True)
      assert IMT(
          -1 / (nu + s), s, x, (-oo, None)
      ) == x**nu * Heaviside(x - 1)
      assert IMT(1 / (nu + s), s, x, (None, oo)) == x**nu * Heaviside(
          1 - x
      )
      assert simp_pows(
          IMT(gamma(beta) * gamma(s) / gamma(s + beta), s, x, (0, oo))
      ) == (1 - x) ** (beta - 1) * Heaviside(1 - x)
      assert simp_pows(
          IMT(
              gamma(beta) * gamma(1 - beta - s) / gamma(1 - s),
              s,
              x,
              (-oo, None),
          )
      ) == (x - 1) ** (beta - 1) * Heaviside(x - 1)
      assert (
          simp_pows(
              IMT(
                  gamma(s) * gamma(rho - s) / gamma(rho),
                  s,
                  x,
                  (0, None),
              )
          )
          == (1 / (x + 1)) ** rho
      )
      assert simp_pows(
          IMT(
              d**c
              * d ** (s - 1)
              * sin(pi * c)
              * gamma(s)
              * gamma(s + c)
              * gamma(1 - s)
              * gamma(1 - s - c)
              / pi,
              s,
              x,
              (Max(-re(c), 0), Min(1 - re(c), 1)),
          )
      ) == (x**c - d**c) / (x - d)
  
      assert (
          simplify(
              IMT(
                  1
                  / sqrt(pi)
                  * (-c / 2)
                  * gamma(s)
                  * gamma((1 - c) / 2 - s)
                  * gamma(-c / 2 - s)
                  / gamma(1 - c - s),
                  s,
                  x,
                  (0, -re(c) / 2),
              )
          )
          == (1 + sqrt(x + 1)) ** c
      )
      assert simplify(
          IMT(
              2 ** (a + 2 * s)
              * b ** (a + 2 * s - 1)
              * gamma(s)
              * gamma(1 - a - 2 * s)
              / gamma(1 - a - s),
              s,
              x,
              (0, (-re(a) + 1) / 2),
          )
      ) == b ** (a - 1) * (
          b**2 * (sqrt(1 + x / b**2) + 1) ** a
          + x * (sqrt(1 + x / b**2) + 1) ** (a - 1)
      ) / (
          b**2 + x
      )
      assert (
          simplify(
              IMT(
                  -(2 ** (c + 2 * s))
                  * c
                  * b ** (c + 2 * s)
                  * gamma(s)
                  * gamma(-c - 2 * s)
                  / gamma(-c - s + 1),
                  s,
                  x,
                  (0, -re(c) / 2),
              )
          )
          == b**c * (sqrt(1 + x / b**2) + 1) ** c
      )
  
      # Section 8.4.5
      assert IMT(24 / s**5, s, x, (0, oo)) == log(x) ** 4 * Heaviside(
          1 - x
      )
      assert expand(IMT(6 / s**4, s, x, (-oo, 0)), force=True) == log(
          x
      ) ** 3 * Heaviside(x - 1)
      assert IMT(pi / (s * sin(pi * s)), s, x, (-1, 0)) == log(x + 1)
      assert IMT(pi / (s * sin(pi * s / 2)), s, x, (-2, 0)) == log(
          x**2 + 1
      )
      assert IMT(
          pi / (s * sin(2 * pi * s)), s, x, (Rational(-1, 2), 0)
      ) == log(sqrt(x) + 1)
      assert IMT(pi / (s * sin(pi * s)), s, x, (0, 1)) == log(1 + 1 / x)
  
      # TODO
      def mysimp(expr):
          from sympy.core.function import expand
          from sympy.simplify.powsimp import powsimp
          from sympy.simplify.simplify import logcombine
  
          return expand(
              powsimp(
                  logcombine(expr, force=True), force=True, deep=True
              ),
              force=True,
          ).replace(exp_polar, exp)
  
      assert mysimp(
          mysimp(IMT(pi / (s * tan(pi * s)), s, x, (-1, 0)))
      ) in [
          log(1 - x) * Heaviside(1 - x) + log(x - 1) * Heaviside(x - 1),
          log(x) * Heaviside(x - 1)
          + log(1 - 1 / x) * Heaviside(x - 1)
          + log(-x + 1) * Heaviside(-x + 1),
      ]
      # test passing cot
      assert mysimp(IMT(pi * cot(pi * s) / s, s, x, (0, 1))) in [
          log(1 / x - 1) * Heaviside(1 - x)
          + log(1 - 1 / x) * Heaviside(x - 1),
          -log(x) * Heaviside(-x + 1)
          + log(1 - 1 / x) * Heaviside(x - 1)
          + log(-x + 1) * Heaviside(-x + 1),
      ]
  
      # 8.4.14
      assert IMT(
          -gamma(s + S.Half) / (sqrt(pi) * s),
          s,
          x,
          (Rational(-1, 2), 0),
      ) == erf(sqrt(x))
  
      # 8.4.19
      assert simplify(
          IMT(
              gamma(a / 2 + s) / gamma(a / 2 - s + 1),
              s,
              x,
              (-re(a) / 2, Rational(3, 4)),
          )
      ) == besselj(a, 2 * sqrt(x))
      assert simplify(
          IMT(
              2**a
              * gamma(S.Half - 2 * s)
              * gamma(s + (a + 1) / 2)
              / (gamma(1 - s - a / 2) * gamma(1 - 2 * s + a)),
              s,
              x,
              (-(re(a) + 1) / 2, Rational(1, 4)),
          )
      ) == sin(sqrt(x)) * besselj(a, sqrt(x))
      assert simplify(
          IMT(
              2**a
              * gamma(a / 2 + s)
              * gamma(S.Half - 2 * s)
              / (gamma(S.Half - s - a / 2) * gamma(1 - 2 * s + a)),
              s,
              x,
              (-re(a) / 2, Rational(1, 4)),
          )
      ) == cos(sqrt(x)) * besselj(a, sqrt(x))
      # TODO this comes out as an amazing mess, but simplifies nicely
      assert (
          simplify(
              IMT(
                  gamma(a + s)
                  * gamma(S.Half - s)
                  / (sqrt(pi) * gamma(1 - s) * gamma(1 + a - s)),
                  s,
                  x,
                  (-re(a), S.Half),
              )
          )
          == besselj(a, sqrt(x)) ** 2
      )
      assert simplify(
          IMT(
              gamma(s)
              * gamma(S.Half - s)
              / (sqrt(pi) * gamma(1 - s - a) * gamma(1 + a - s)),
              s,
              x,
              (0, S.Half),
          )
      ) == besselj(-a, sqrt(x)) * besselj(a, sqrt(x))
      assert simplify(
          IMT(
              4**s
              * gamma(-2 * s + 1)
              * gamma(a / 2 + b / 2 + s)
              / (
                  gamma(-a / 2 + b / 2 - s + 1)
                  * gamma(a / 2 - b / 2 - s + 1)
                  * gamma(a / 2 + b / 2 - s + 1)
              ),
              s,
              x,
              (-(re(a) + re(b)) / 2, S.Half),
          )
      ) == besselj(a, sqrt(x)) * besselj(b, sqrt(x))
  
      # Section 8.4.20
      # TODO this can be further simplified!
      assert simplify(
          IMT(
              -(2 ** (2 * s))
              * cos(pi * a / 2 - pi * b / 2 + pi * s)
              * gamma(-2 * s + 1)
              * gamma(a / 2 - b / 2 + s)
              * gamma(a / 2 + b / 2 + s)
              / (
                  pi
                  * gamma(a / 2 - b / 2 - s + 1)
                  * gamma(a / 2 + b / 2 - s + 1)
              ),
              s,
              x,
              (
                  Max(-re(a) / 2 - re(b) / 2, -re(a) / 2 + re(b) / 2),
                  S.Half,
              ),
          )
      ) == besselj(a, sqrt(x)) * -(
          besselj(-b, sqrt(x)) - besselj(b, sqrt(x)) * cos(pi * b)
      ) / sin(
          pi * b
      )
      # TODO more
  
      # for coverage
  
      assert IMT(pi / cos(pi * s), s, x, (0, S.Half)) == sqrt(x) / (
          x + 1
      )
  
imports: from sympy.integrals.transforms import mellin_transform, inverse_mellin_transform, fourier_transform, inverse_fourier_transform, sine_transform, inverse_sine_transform, cosine_transform, inverse_cosine_transform, hankel_transform, inverse_hankel_transform, FourierTransform, SineTransform, CosineTransform, InverseFourierTransform, InverseSineTransform, InverseCosineTransform, IntegralTransformError
  from sympy.integrals.laplace import laplace_transform, inverse_laplace_transform
  from sympy.core.function import Function, expand_mul
  from sympy.core import EulerGamma
  from sympy.core.numbers import I, Rational, oo, pi
  from sympy.core.singleton import S
  from sympy.core.symbol import Symbol, symbols
  from sympy.functions.combinatorial.factorials import factorial
  from sympy.functions.elementary.complexes import re, unpolarify
  from sympy.functions.elementary.exponential import exp, exp_polar, log
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.functions.elementary.trigonometric import atan, cos, sin, tan
  from sympy.functions.special.bessel import besseli, besselj, besselk, bessely
  from sympy.functions.special.delta_functions import Heaviside
  from sympy.functions.special.error_functions import erf, expint
  from sympy.functions.special.gamma_functions import gamma
  from sympy.functions.special.hyper import meijerg
  from sympy.simplify.gammasimp import gammasimp
  from sympy.simplify.hyperexpand import hyperexpand
  from sympy.simplify.trigsimp import trigsimp
  from sympy.testing.pytest import XFAIL, slow, skip, raises
  from sympy.abc import x, s, a, b, c, d
label_desc: Use image node_id 9 for calling a global function with example usage: test_inverse_mellin_transform() and returns: simplify, expand