def create_params(options, base_params, keys=None):
  """
  Given a dictionary of parameters and possible values,
  creates a list of the cross products of all parameter values.

  Note that b has [3] as an element.  The cross product is shallow
  so [3] will be a value in the output.

  Example:
    options = { a: [1,2], b: [[3],4] }
    returns: [ {a:1, b:[3]}, {a:1, b:4}, {a:2, b:[3]}, {a:2, b:4} ]
  """
  if keys is None:
    keys = options.keys()
  if len(keys) == 0:
    return [dict(base_params)]

  ret = []
  key = keys[0]
  vals = options[key]
  if not isinstance(vals, list):
    vals = [vals]

  for val in vals:
    param = dict(base_params)
    param[key] = val
    ret.extend(create_params(options, param, keys[1:]))
  return ret