code: def _create_test_entry_function(cls, module, devices):
      # Creates a test entry function from the template class, and places it in
      # the same module as the class.
  
      # We enforce 'Test' prefix in OpTest implementations so that they look like
      # unittest.TestCase implementations. OTOH generated entry function must
      # have a prefix 'test_' in order for it to be found in pytest test
      # collection.
      if not cls.__name__.startswith("Test"):
          raise TypeError(
              "OpTest class name must start with 'Test'. Actual: {!r}".format(
                  cls.__name__
              )
          )
  
      func_name = "test_{}".format(cls.__name__[len("Test") :])
  
      @pytest.mark.parametrize_device(devices)
      def entry_func(device, *args, **kwargs):
          backend_config = _make_backend_config(device.name)
  
          # Forward test
          obj = cls()
          try:
              obj.setup(*args, **kwargs)
              obj.run_test_forward(backend_config)
          finally:
              obj.teardown()
  
          # If this is a NumpyOpTest instance, skip backward/double-backward
          # tests if the forward test succeeds with acceptable errors.
          if isinstance(obj, NumpyOpTest):
              if obj.is_forward_successful_with_accept_errors:
                  return  # success with expected errors
  
          # Backward test
          obj = cls()
          try:
              obj.setup(*args, **kwargs)
              obj.run_test_backward(backend_config)
          finally:
              obj.teardown()
  
          # Double-backward test
          obj = cls()
          try:
              obj.setup(*args, **kwargs)
              obj.run_test_double_backward(backend_config)
          finally:
              obj.teardown()
  
      entry_func.__name__ = func_name
  
      # Set the signature of the entry function
      sig = inspect.signature(cls.setup)
      params = list(sig.parameters.values())
      params = params[1:]  # Remove `self` argument
      device_param = inspect.Parameter(
          "device", inspect.Parameter.POSITIONAL_OR_KEYWORD
      )
      params = [device_param] + params  # Prepend `device` argument
      entry_func.__signature__ = inspect.Signature(params)
  
      # Set the pytest mark
      try:
          pytestmark = cls.pytestmark
          entry_func.pytestmark += pytestmark
      except AttributeError:
          pass
  
      # Place the entry function in the module of the class
      setattr(module, func_name, entry_func)
  
imports: import inspect
  import sys
  import unittest
  import numpy
  import pytest
  import chainer
  import chainer.testing
  import chainerx
label_desc: Use image node_id 2 for calling a global function with example usage: _create_test_entry_function(cls, module, devices) without return types