code: def extract_scalar_reward(value, scalar_key="default"):
      """
      Extract scalar reward from trial result.
  
      Parameters
      ----------
      value : int, float, dict
          the reported final metric data
      scalar_key : str
          the key name that indicates the numeric number
  
      Raises
      ------
      RuntimeError
          Incorrect final result: the final result should be float/int,
          or a dict which has a key named "default" whose value is float/int.
      """
      if isinstance(value, (float, int)):
          reward = value
      elif (
          isinstance(value, dict)
          and scalar_key in value
          and isinstance(value[scalar_key], (float, int))
      ):
          reward = value[scalar_key]
      else:
          raise RuntimeError(
              "Incorrect final result: the final result should be float/int, "
              'or a dict which has a key named "default" whose value is float/int.'
          )
      return reward
  
imports: import copy
  from enum import Enum, unique
  from pathlib import Path
  from schema import And
  from .None import parameter_expressions
label_desc: Use image node_id 2 for calling a global function with example usage: extract_scalar_reward(value, scalar_key) and returns: reward