code: def _grid_search_generator(
      unresolved_spec: Dict, grid_vars: List
  ) -> Generator[Dict, None, None]:
      value_indices = [0] * len(grid_vars)
  
      def increment(i):
          value_indices[i] += 1
          if value_indices[i] >= len(grid_vars[i][1]):
              value_indices[i] = 0
              if i + 1 < len(value_indices):
                  return increment(i + 1)
              else:
                  return True
          return False
  
      if not grid_vars:
          yield unresolved_spec
          return
  
      while value_indices[-1] < len(grid_vars[-1][1]):
          spec = copy.deepcopy(unresolved_spec)
          for i, (path, values) in enumerate(grid_vars):
              assign_value(spec, path, values[value_indices[i]])
          yield spec
          if grid_vars:
              done = increment(0)
              if done:
                  break
  
imports: import copy
  import logging
  import re
  from collections.abc import Mapping
  from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple
  import numpy
  import random
  from ray.tune.search.sample import Categorical, Domain, Function, RandomState
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 15 for calling a global function with example usage: _grid_search_generator(unresolved_spec, grid_vars) and returns: False, increment, True