code: def load_parameter(parameter, key=None):
      """Parses each parameter and return a dict"""
      # pylint: disable=too-many-branches
      # pylint: disable=too-many-statements
      # Common parameters
      _name = parameter.get("name", key)
      if _name is None:
          raise ValueError("Parameter name is required")
      _type = parameter.get("type", "float")
      _kernel = parameter.get("kernel", "")
      # Common for Euclidean, Integral, Discrete, Discrete Numeric domains
      _dim = parameter.get("dim", "")
      # For Euclidean/Integral
      _min = parameter.get("min", -np.inf)
      _max = parameter.get("max", np.inf)
      # For Discrete
      _items = parameter.get("items", "")
      # For neural networks -- see below
  
      # Now process them
      param = {}
      param["name"] = unicode_to_str(_name)
      param["kernel"] = unicode_to_str(_kernel)
      param["type"] = unicode_to_str(_type).lower()
      # First for regular domains
      if param["type"] in [
          "float",
          "int",
          "discrete",
          "discrete_numeric",
          "boolean",
      ]:
          if not isinstance(_dim, Number):
              _dim = unicode_to_str(_dim)
          if _dim != "":
              _dim = int(_dim)
          param["dim"] = _dim
          if param["type"] in ["float", "int"]:
              param["min"] = _min
              param["max"] = _max
          elif param["type"] == "discrete":
              if _items == "":
                  raise ValueError("List of items required")
              if isinstance(_items, list):
                  param["items"] = [unicode_to_str(i) for i in _items]
              else:
                  param["items"] = unicode_to_str(_items).split("-")
          elif param["type"] == "discrete_numeric":
              if _items == "":
                  raise ValueError("List or range of items required")
              elif ":" not in _items:
                  param["items"] = [
                      float(x)
                      for x in unicode_to_str(_items).split("-")
                  ]
              else:
                  _range = [
                      float(x)
                      for x in unicode_to_str(_items).split(":")
                  ]
                  param["items"] = list(
                      np.arange(_range[0], _range[2], _range[1])
                  )
      elif param["type"].startswith(("cnn", "mlp")):
          nn_params = {}
          nn_params["max_num_layers"] = parameter.get(
              "max_num_layers", "inf"
          )
          nn_params["min_num_layers"] = parameter.get(
              "min_num_layers", 0
          )
          nn_params["max_mass"] = parameter.get("max_mass", "inf")
          nn_params["min_mass"] = parameter.get("min_mass", 0)
          nn_params["max_in_degree"] = parameter.get(
              "max_in_degree", "inf"
          )
          nn_params["max_out_degree"] = parameter.get(
              "max_out_degree", "inf"
          )
          nn_params["max_num_edges"] = parameter.get(
              "max_num_edges", "inf"
          )
          nn_params["max_num_units_per_layer"] = parameter.get(
              "max_num_units_per_layer", "inf"
          )
          nn_params["min_num_units_per_layer"] = parameter.get(
              "min_num_units_per_layer", 0
          )
          # For CNNs add strides
          if param["type"].startswith("cnn"):
              nn_params["max_num_2strides"] = parameter.get(
                  "max_num_2strides", "inf"
              )
          for nnp_key, nnp_val in nn_params.items():
              if isinstance(nnp_val, str):
                  nnp_val = unicode_to_str(nnp_val)
              nnp_val = np.inf if nnp_val == "inf" else nnp_val
              param[nnp_key] = nnp_val
          # Finally add the following
          param["dim"] = ""
      else:
          raise ValueError("Unknown type %s." % (param["type"]))
      return param
  
file_path: dragonfly/dragonfly/parse/config_parser.py
imports: from __future__ import absolute_import
  import sys
  import json
  from collections import OrderedDict
  from numbers import Number
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: load_parameter(parameter, key) and returns: param