code: def _scalar_optimization_prepare_result(
      work, res, res_work_pairs, active, shape, customize_result
  ):
      # Prepare the result object `res` by creating a copy, copying the latest
      # data from work, running the provided result customization function,
      # and reshaping the data to the original shapes.
      res = res.copy()
      _scalar_optimization_update_active(
          work, res, res_work_pairs, active
      )
  
      shape = customize_result(res, shape)
  
      for key, val in res.items():
          res[key] = np.reshape(val, shape)[()]
      res["_order_keys"] = ["success"] + [i for i, j in res_work_pairs]
      return OptimizeResult(**res)
  
imports: import warnings
  from collections import namedtuple
  import operator
  from .None import _zeros
  from ._optimize import OptimizeResult, _call_callback_maybe_halt
  import numpy
label_desc: Use image node_id 26 for calling a global function with example usage: _scalar_optimization_prepare_result(work, res, res_work_pairs, active, shape, customize_result) and returns: OptimizeResult