code: def rewrite_model_builder(build_fn_source):
      """Convert the build function used to construct a Keras model to a reusable format by replacing
      usages of `hyperparameter_hunter.space` classes (`Real`, `Integer`, `Categorical`) with key
      lookups to a new build_fn input dict containing keys for each of the hyperparameter search
      space choices found in the original source code
  
      Parameters
      ----------
      build_fn_source: String
          The stringified source code of a callable (assumed to be Keras `build_fn`)
  
      Returns
      -------
      reusable_build_fn: String
          The given `build_fn_source`, in which any usages of `hyperparameter_hunter.space` classes
          (`Real`, `Integer`, `Categorical`) are replaced with key lookups to a new build_fn input
          dict containing keys for each of the hyperparameter search space choices found in the
          original `build_fn_source`,
      expected_params: `collections.OrderedDict` instance
          A mapping of the names of the located hyperparameter choices to their given ranges
          (as described by `hyperparameter_hunter.space` classes)"""
      clipped_choices, names, start_indexes = find_space_fragments(
          build_fn_source
      )
      expected_params = OrderedDict(zip(names, clipped_choices))
  
      for i, name in enumerate(names):
          lookup_val = "params[{!r}]".format(name)
          build_fn_source = build_fn_source.replace(
              clipped_choices[i], lookup_val, 1
          )
  
      new_first_line = "def build_fn(input_shape=(10, ), params=None):"
      reusable_build_fn = build_fn_source.replace(
          build_fn_source.split("\n")[0], new_first_line
      )
  
      return reusable_build_fn, expected_params
  
imports: from hyperparameter_hunter.settings import G, TEMP_MODULES_DOT_PATH, TEMP_MODULES_DIR_PATH
  from hyperparameter_hunter.compat.keras_helper import parameterize_compiled_keras_model
  from hyperparameter_hunter.space.dimensions import Real, Integer, Categorical
  from hyperparameter_hunter.utils.boltons_utils import remap, default_enter
  from hyperparameter_hunter.utils.general_utils import deep_restricted_update, subdict
  from hyperparameter_hunter.utils.parsing_utils import stringify_model_builder, write_python, build_temp_model_file
  from collections import OrderedDict
  from copy import deepcopy
  from datetime import datetime
  from importlib.util import spec_from_file_location, module_from_spec
  import os
  import re
  import sys
  from types import FunctionType, MethodType
label_desc: Use image node_id 7 for calling a global function with example usage: rewrite_model_builder(build_fn_source) and returns: reusable_build_fn,  expected_params