code: def get_trial_results(trial):
      """Format results from a `orion.core.worker.trial.Trial` using standard structures."""
      results = {}
  
      lie = trial.lie
      objective = trial.objective
  
      if lie:
          results["objective"] = lie.value
      elif objective:
          results["objective"] = objective.value
      else:
          results["objective"] = None
  
      results["constraint"] = [
          result.value
          for result in trial.results
          if result.type == "constraint"
      ]
      grad = trial.gradient
      results["gradient"] = tuple(grad.value) if grad else None
  
      return results
  
imports: from orion.core.utils.flatten import flatten
  from orion.core.worker.trial import Trial
label_desc: Use image node_id 4 for calling a global function with example usage: get_trial_results(trial) and returns: results