code: def consolidate_layers(layers, class_name_key=True, split_args=False):
      """For each of the layer dicts in `layers`, merge the dict's keys to reflect the end value of
      the key, rather than its default value, and whether a value was explicitly given
  
      Parameters
      ----------
      layers: List
          A list of dicts, wherein each dict represents a layer in a Keras model, and contains
          information about its arguments
      class_name_key: Boolean, default=True
          If True, "class_name" is added as a key to the dict describing each layer. Else, it will be
          used as a key to create an outer dict containing the rest of the keys describing each layer
      split_args: Boolean, default=False
          If True, each layer dict will be given two keys: "arg_vals", and "kwarg_vals", which are
          both dicts containing their respective values. Else, each layer dict will directly contain
          all the keys of "arg_vals", and "kwarg_vals", removing any indication of whether the
          parameter was a positional or keyword argument, aside from order
  
      Returns
      -------
      consolidated_layers: List
          A list of the same length as `layers`, except each element has fewer keys than it did in
          `layers`. The new keys are as follows: ["class_name", "arg_vals", "kwarg_vals"]
      """
      consolidated_layers = []
  
      for layer in layers:
          arg_vals = {}
  
          #################### Gather Args ####################
          for i, expected_arg in enumerate(layer["__hh_default_args"]):
              try:
                  arg_vals[expected_arg] = layer["__hh_used_args"][i]
              except IndexError:
                  if expected_arg in layer["__hh_used_kwargs"]:
                      arg_vals[expected_arg] = layer[
                          "__hh_used_kwargs"
                      ][expected_arg]
                  else:
                      raise
  
          #################### Gather Kwargs ####################
          # Merge default and used kwargs with constraints: only include if k in default, and give priority to used values
          # This means that kwargs like `input_shape` won't make it through because they have no default values, also
          # nonsensical kwargs won't make it through because the defaults are the point of reference
          kwarg_vals = {
              k: layer["__hh_used_kwargs"].get(k, v)
              for k, v in layer["__hh_default_kwargs"].items()
          }
  
          #################### Consolidate ####################
          if split_args:
              new_layer_dict = dict(
                  arg_vals=arg_vals, kwarg_vals=kwarg_vals
              )
          else:
              new_layer_dict = {**arg_vals, **kwarg_vals}
  
          if class_name_key:
              new_layer_dict["class_name"] = layer["class_name"]
          else:
              new_layer_dict = {layer["class_name"]: new_layer_dict}
  
          consolidated_layers.append(new_layer_dict)
      return consolidated_layers
  
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 2 for calling a global function with example usage: consolidate_layers(layers, class_name_key, split_args) and returns: consolidated_layers