from typing import Mapping
from typing import Sequence
from typing import Union
from typing import List
import itertools


def hyper_grid(
    grid_dict: Mapping[str, Sequence[Union[str, int, float]]]
) -> List[Mapping[str, Union[str, int, float]]]:
  """Converts a param-keyed dict of lists to a list of mapping.

  Args:
    grid_dict: A Mapping from string parameter names to lists of values.

  Returns:
    A list of parameter sweep based on the Cartesian product of
    all options in param_dict.
  """
  return [
      dict(zip(grid_dict, val))
      for val in itertools.product(*grid_dict.values())
  ]