code: def max_or_min(solve_fun, kwargs, constraints, default, call_log):
      """Emulates :func:`optunity.maximize` and :func:`optunity.minimize`."""
      replacements = comm._find_replacements(_illegal_keys, kwargs)
      solver_config = comm._replace_keys(kwargs, replacements)
      constraints = comm._replace_keys(constraints, replacements)
  
      # prepare objective function
      mgr = comm.EvalManager(replacements=replacements)
      func = prepare_fun(mgr, constraints, default, call_log)
  
      # solve problem
      try:
          solution, rslt, solver = solve_fun(
              func, pmap=mgr.pmap, **solver_config
          )
      except EOFError:
          msg = {"error_msg": "Broken pipe."}
          comm.send(comm.json_encode(msg))
          exit(1)
  
      # send solution and exit
      result = rslt._asdict()
      result["solution"] = solution
      result["solver"] = solver
      result_json = comm.json_encode(result)
      comm.send(result_json)
      exit(0)
  
file_path: optunity/optunity/standalone.py
imports: from __future__ import print_function
  import sys
  import keyword
  from .None import communication
  from .None import functions
  import optunity
label_desc: Use image node_id 6 for calling a global function with example usage: max_or_min(solve_fun, kwargs, constraints, default, call_log) without return types