code: def _test_case_generator(base, method_names, params):
      # Defines the logic to generate test case classes parameterized with
      # backends.
  
      if method_names is not None:
  
          def method_generator(base_method):
              if base_method.__name__ in method_names:
                  return None
              return base_method
  
          yield (base.__name__, {}, method_generator)
  
      for i_param, param in enumerate(params):
          backend_config = BackendConfig(param)
          marks = backend_config.get_pytest_marks()
          cls_name = "{}_{}".format(
              base.__name__, backend_config.get_func_str()
          )
  
          def method_generator(base_method):
              # Generates a wrapped test method
  
              if (
                  method_names is not None
                  and base_method.__name__ not in method_names
              ):
                  return None
  
              # Bind to a new variable.
              backend_config2 = backend_config
  
              @functools.wraps(base_method)
              def new_method(self, *args, **kwargs):
                  return base_method(
                      self, backend_config2, *args, **kwargs
                  )
  
              # Apply test marks
              for mark in marks:
                  new_method = mark(new_method)
  
              return new_method
  
          yield (cls_name, {}, method_generator)
  
imports: import functools
  import chainer
  from chainer import backend
  from chainer.testing import _bundle
  from chainer.testing import attr
  import chainerx
label_desc: Use image node_id 1 for calling a global function with example usage: _test_case_generator(base, method_names, params) and returns: base_method, new_method, None, None, base_method