code: def build_hp_grid(
      framework,
      types,
      num_trials,
      problem_type,
      hp_path=resource_filename(__name__, "hyperparameters.yml"),
  ):
      """Builds the hyperparameter grid for model grid search.
  
      # Arguments:
          framework: string indicating the framework (e.g. `tensorflow`)
          types: list of hyperparameter types to consider; exclude rest
          num_trials: number of distinct trials to keep
          problem_type: type of problem to solve
          hp_path: filepath of hyperparameters
  
      # Returns
          A list of dicts of hyperparameter specifications
      """
  
      with open(hp_path) as f:
          hps = yaml.safe_load(f)
  
      # Refine hyperparameters by only using ones relevant to
      # the data and framework of choice
      hps = dict(hps["base"], **hps[framework])
      keys = [
          key
          for key in hps.keys()
          if (
              hps[key]["type"] in types
              or hps[key]["type"] == "base"
              or hps[key]["type"] == problem_type
          )
      ]
      values = [hps[key]["hyperparams"] for key in keys]
  
      grid = set()
      while len(grid) < num_trials:
          grid.add(tuple([random.choice(x) for x in values]))
  
      grid_params = [dict(zip(keys, grid_hps)) for grid_hps in grid]
      return grid_params
  
imports: import re
  import pandas
  import random
  import yaml
  import os
  import shutil
  from time import time
  from pkg_resources import resource_filename
  from tqdm import tqdm, tqdm_notebook
  from tqdm._utils import _term_move_up
  from subprocess import Popen, PIPE, DEVNULL, CalledProcessError
  from autopep8 import fix_code
  from collections import OrderedDict
label_desc: Use image node_id 3 for calling a global function with example usage: build_hp_grid(framework, types, num_trials, problem_type, hp_path) and returns: grid_params