code: def domain_constructor(**b_kwargs):
      """
      Decorate a function that returns a pyll expressions so that
      it becomes a Domain instance instead of a function
  
      Example:
  
      @domain_constructor(loss_target=0)
      def f(low, high):
          return {'loss': hp.uniform('x', low, high) ** 2 }
  
      """
  
      def deco(f):
          def wrapper(*args, **kwargs):
              if "name" in b_kwargs:
                  _b_kwargs = b_kwargs
              else:
                  _b_kwargs = dict(b_kwargs, name=f.__name__)
              f_rval = f(*args, **kwargs)
              domain = Domain(lambda x: x, f_rval, **_b_kwargs)
              return domain
  
          wrapper.__name__ = f.__name__
          return wrapper
  
      return deco
  
imports: import unittest
  import numpy
  from hyperopt import Trials, Domain, fmin, hp, base
  from hyperopt.rand import suggest
  from hyperopt.pyll import as_apply
  from hyperopt.pyll import scope
label_desc: Use image node_id 1 for calling a global function with example usage: domain_constructor() and returns: deco, wrapper, domain