code: def test_expr_to_config():
      z = hp.randint("z", 10)
      a = hp.choice(
          "a",
          [
              hp.uniform("b", -1, 1) + z,
              {
                  "c": 1,
                  "d": hp.choice(
                      "d",
                      [
                          3 + hp.loguniform("c", 0, 1),
                          1 + hp.loguniform("e", 0, 1),
                      ],
                  ),
              },
          ],
      )
  
      expr = as_apply((a, z))
  
      hps = {}
      expr_to_config(expr, (True,), hps)
  
      for label, dct in list(hps.items()):
          print(label)
          print(
              "  dist: %s(%s)"
              % (
                  dct["node"].name,
                  ", ".join(
                      map(
                          str,
                          [ii.eval() for ii in dct["node"].inputs()],
                      )
                  ),
              )
          )
          if len(dct["conditions"]) > 1:
              print("  conditions (OR):")
              for condseq in dct["conditions"]:
                  print("    ", " AND ".join(map(str, condseq)))
          elif dct["conditions"]:
              for condseq in dct["conditions"]:
                  print(
                      "  conditions :", " AND ".join(map(str, condseq))
                  )
  
      assert hps["a"]["node"].name == "randint"
      assert hps["b"]["node"].name == "uniform"
      assert hps["c"]["node"].name == "loguniform"
      assert hps["d"]["node"].name == "randint"
      assert hps["e"]["node"].name == "loguniform"
      assert hps["z"]["node"].name == "randint"
  
      assert {(True, EQ("a", 0))} == {(True, EQ("a", 0))}
      assert hps["a"]["conditions"] == {(True,)}
      assert hps["b"]["conditions"] == {(True, EQ("a", 0))}, hps["b"][
          "conditions"
      ]
      assert hps["c"]["conditions"] == {(True, EQ("a", 1), EQ("d", 0))}
      assert hps["d"]["conditions"] == {(True, EQ("a", 1))}
      assert hps["e"]["conditions"] == {(True, EQ("a", 1), EQ("d", 1))}
      assert hps["z"]["conditions"] == {(True,), (True, EQ("a", 0))}
  
imports: from hyperopt import pyll_utils
  from hyperopt.pyll_utils import EQ
  from hyperopt.pyll_utils import expr_to_config
  from hyperopt import hp
  from hyperopt.pyll import as_apply
  from hyperopt.pyll.stochastic import sample
  import unittest
  import numpy
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: test_expr_to_config() without return types