code: def test_xreplace():
      assert b21.xreplace({b2: b1}) == Basic(b1, b1)
      assert b21.xreplace({b2: b21}) == Basic(b21, b1)
      assert b3.xreplace({b2: b1}) == b2
      assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1)
      assert Atom(b1).xreplace({b1: b2}) == Atom(b1)
      assert Atom(b1).xreplace({Atom(b1): b2}) == b2
      raises(TypeError, lambda: b1.xreplace())
      raises(TypeError, lambda: b1.xreplace([b1, b2]))
      for f in (exp, Function("f")):
          assert f.xreplace({}) == f
          assert f.xreplace({}, hack2=True) == f
          assert f.xreplace({f: b1}) == b1
          assert f.xreplace({f: b1}, hack2=True) == b1
  
imports: import collections
  from typing import TypeVar, Generic
  from sympy.assumptions.ask import Q
  from sympy.core.basic import Basic, Atom, as_Basic, _atomic, _aresame
  from sympy.core.containers import Tuple
  from sympy.core.function import Function, Lambda
  from sympy.core.numbers import I, pi, Float
  from sympy.core.singleton import S
  from sympy.core.symbol import symbols, Symbol, Dummy
  from sympy.concrete.summations import Sum
  from sympy.functions.elementary.trigonometric import cos, sin
  from sympy.functions.special.gamma_functions import gamma
  from sympy.integrals.integrals import Integral
  from sympy.functions.elementary.exponential import exp
  from sympy.testing.pytest import raises, warns_deprecated_sympy
label_desc: Use image node_id 13 for calling a global function with example usage: test_xreplace() without return types