code: def generate(combinations, test_combinations=()):
      """A decorator for generating combinations of a test method or a test class.
  
      Parameters of the test method must match by name to get the corresponding
      value of the combination.  Tests must accept all parameters that are passed
      other than the ones that are `OptionalParameter`.
  
      Args:
        combinations: a list of dictionaries created using combine().
        test_combinations: a tuple of `TestCombination` instances that customize
          the execution of generated tests.
  
      Returns:
        a decorator that will cause the test method or the test class to be run
        under the specified conditions.
  
      Raises:
        ValueError: if any parameters were not accepted by the test method
      """
  
      def decorator(test_method_or_class):
          """The decorator to be returned."""
  
          # Generate good test names that can be used with --test_filter.
          named_combinations = []
          for combination in combinations:
              # We use OrderedDicts in `combine()` to ensure stable order of keys in
              # each dictionary.
              assert isinstance(combination, OrderedDict)
              generated_testcase_name = "_".join(
                  [
                      str(value)
                      for (_, value) in combination.items()
                      if str(value)
                  ]
              )
              named_combinations.append(
                  OrderedDict(
                      list(combination.items())
                      + [
                          (
                              "testcase_name",
                              "_{}".format(generated_testcase_name),
                          )
                      ]
                  )
              )
  
          if isinstance(test_method_or_class, type):
              class_object = test_method_or_class
              class_object._test_method_ids = test_method_ids = {}
              for name, test_method in six.iteritems(
                  class_object.__dict__.copy()
              ):
                  if name.startswith(
                      unittest.TestLoader.testMethodPrefix
                  ) and isinstance(test_method, types.FunctionType):
                      delattr(class_object, name)
                      methods = {}
                      parameterized._update_class_dict_for_param_test_case(
                          class_object.__name__,
                          methods,
                          test_method_ids,
                          name,
                          parameterized._ParameterizedTestIter(
                              _augment_with_special_arguments(
                                  test_method,
                                  test_combinations=test_combinations,
                              ),
                              named_combinations,
                              parameterized._NAMED,
                              name,
                          ),
                      )
                      for method_name, method in six.iteritems(methods):
                          setattr(class_object, method_name, method)
  
              return class_object
          else:
              test_method = _augment_with_special_arguments(
                  test_method_or_class,
                  test_combinations=test_combinations,
              )
              return parameterized.named_parameters(
                  *named_combinations
              )(test_method)
  
      return decorator
  
imports: from collections import OrderedDict
  import contextlib
  import types
  import unittest
  from absl.testing import parameterized
  import six
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 1 for calling a global function with example usage: generate(combinations, test_combinations) and returns: decorator, class_object, parameterized