code: def test_dispatcher_autograph_warnings(
      capsys: CaptureFixture[str],
      Dispatcher: Type[Any],
      expect_autograph_warning: bool,
  ) -> None:
      if Dispatcher is multipledispatch.Dispatcher and (
          Version(tf.__version__) >= Version("2.3.0")
      ):
          pytest.skip(
              "In TensorFlow >= 2.3, multipledispatch.Dispatcher no longer works at all"
          )
  
      tf.autograph.set_verbosity(
          0, alsologtostdout=True
      )  # to be able to capture it using capsys
  
      test_fn = Dispatcher("test_fn")
  
      # generator would only be invoked when defining for base class...
      @test_fn.register(gpflow.inducing_variables.InducingVariables)
      def test_iv(
          x: gpflow.inducing_variables.InducingVariables,
      ) -> tf.Tensor:
          return tf.reduce_sum(x.Z)
  
      test_fn_compiled = tf.function(
          test_fn
      )  # with autograph=True by default
  
      # ...but calling using subclass
      result = test_fn_compiled(
          gpflow.inducing_variables.InducingPoints([[1.0, 2.0]])
      )
      assert (
          result.numpy() == 3.0
      )  # expect computation to work either way
  
      captured = capsys.readouterr()
  
      tf_warning = "WARNING:.*Entity .* appears to be a generator function. It will not be converted by AutoGraph."
      assert (
          bool(re.match(tf_warning, captured.out))
          == expect_autograph_warning
      )
  
file_path: GPflow/tests/gpflow/utilities/test_multipledispatch.py
imports: import re
  import warnings
  from typing import Any, Type
  import multipledispatch
  import pytest
  import tensorflow
  from _pytest.capture import CaptureFixture
  from packaging.version import Version
  import gpflow
  from gpflow.utilities import Dispatcher
label_desc: Use image node_id 4 for calling a global function with example usage: test_dispatcher_autograph_warnings(capsys, Dispatcher, expect_autograph_warning) and returns: tf