code: def generate_random_search_trials(params, nb_trials):
      """
      Generates random combination of hyperparameters to try.
      See (Bergstra and Bengio, 2012) for more details.
  
      :param params: The hyperparameters options to search.
      :param nb_trials: The number of trials to run.
      :return: A dict containing the hyperparameters.
      """
      if nb_trials is None:
          raise TypeError(
              "`random_search` strategy requires nb_trails to be an int."
          )
      results = []
  
      # ensures we have unique results
      seen_trials = set()
  
      # shuffle each param list
      potential_trials = 1
      for param in params:
          random.shuffle(param)
          potential_trials *= len(param)
  
      # we can't sample more trials than are possible
      max_iters = min(potential_trials, nb_trials)
  
      # then for the nb of trials requested, create a new param tuple
      # by picking a random integer at each param level
      while len(results) < max_iters:
          trial = []
          for param in params:
              sampled_param = random.sample(param, 1)[0]
              trial.append(sampled_param)
  
          # verify this is a unique trial so we
          # don't duplicate work
          trial_str = json.dumps(trial)
          if trial_str not in seen_trials:
              seen_trials.add(trial_str)
              results.append(trial)
  
      return results
  
imports: import itertools
  import json
  import random
label_desc: Use image node_id 3 for calling a global function with example usage: generate_random_search_trials(params, nb_trials) and returns: results