code: def test_on_ambiguity():
      f = Dispatcher("f")
  
      def identity(x):
          return x
  
      ambiguities = [False]
  
      def on_ambiguity(dispatcher, amb):
          ambiguities[0] = True
  
      f.add((object, object), identity, on_ambiguity=on_ambiguity)
      assert not ambiguities[0]
      f.add((object, float), identity, on_ambiguity=on_ambiguity)
      assert not ambiguities[0]
      f.add((float, object), identity, on_ambiguity=on_ambiguity)
      assert ambiguities[0]
  
imports: from sympy.multipledispatch.dispatcher import Dispatcher, MDNotImplementedError, MethodDispatcher, halt_ordering, restart_ordering, ambiguity_register_error_ignore_dup
  from sympy.testing.pytest import raises, warns
label_desc: Use image node_id 8 for calling a global function with example usage: test_on_ambiguity() and returns: x