code: def _generate_case(base, module, cls_name, mb, method_generator):
      # Returns a _TestCaseTuple.
  
      members = mb.copy()
      # ismethod for Python 2 and isfunction for Python 3
      base_methods = inspect.getmembers(
          base,
          predicate=lambda m: inspect.ismethod(m)
          or inspect.isfunction(m),
      )
      for name, value in base_methods:
          if not name.startswith("test_"):
              continue
          value = method_generator(value)
          # If the return value of method_generator is None, None is assigned
          # as the value of the test method and it is ignored by pytest.
          members[name] = value
  
      cls = type(cls_name, (base,), members)
  
      # Add new test class to module
      setattr(module, cls_name, cls)
  
      return _TestCaseTuple(cls, module.__name__, cls_name)
  
file_path: chainer/chainer/testing/_bundle.py
imports: import collections
  import inspect
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_case(base, module, cls_name, mb, method_generator) and returns: _TestCaseTuple