code: def generate_grid_search_trials(flat_params, nb_trials):
      """
      Standard grid search. Takes the product of `flat_params`
      to generate the search space.
  
      :param params: The hyperparameters options to search.
      :param nb_trials: Returns the first `nb_trials` from the
          combinations space. If this is None, all combinations
          are returned.
      :return: A dict containing the hyperparameters.
      """
      trials = list(itertools.product(*flat_params))
      if nb_trials:
          trials = trials[0:nb_trials]
      return trials
  
imports: import itertools
  import json
  import random
label_desc: Use image node_id 2 for calling a global function with example usage: generate_grid_search_trials(flat_params, nb_trials) and returns: trials