code: def generate_trials(strategy, flat_params, nb_trials=None):
      r"""Generates the parameter combinations to search.
  
      Two search strategies are implemented:
      1. `grid_search`: creates a search space that consists of the
          product of all flat_params. If `nb_trials` is specified
          the first `nb_trials` combinations are searched.
      2. `random_search`: Creates random combinations of the
          hyperparameters. Can be used for a more efficient search.
          See (Bergstra and Bengio, 2012) for more details.
  
      :param strategy: The hyperparameter search to strategy. Can be
          one of: {`grid_search`, `random`}.
      :param flat_params: The hyperparameter arguments to iterate over.
      :param nb_trials: The number of hyperparameter combinations to try.
      Generates the parameter combinations for each requested trial
      :param strategy:
      :param flat_params:
      :param nb_trials: The number of trials to un.
      :return:
      """
      if strategy == "grid_search":
          trials = generate_grid_search_trials(flat_params, nb_trials)
          return trials
      elif strategy == "random_search":
          trials = generate_random_search_trials(flat_params, nb_trials)
          return trials
      else:
          raise ValueError(
              (
                  'Unknown strategy "{}". Must be one of '
                  "{{grid_search, random_search}}"
              ).format(strategy)
          )
  
imports: import itertools
  import json
  import random
label_desc: Use image node_id 1 for calling a global function with example usage: generate_trials(strategy, flat_params, nb_trials) and returns: trials, trials