code: def get_winner(trials):
      
      winner = {}
      # TODO: sort_key should be customized here
      sort_key = "accuracy"
      if trials and len(trials) > 0:
          first_metrics = get_trial_info(trials[0])["metrics"]
          if first_metrics and not first_metrics.get("accuracy", None):
              sort_key = "episode_reward"
          max_metric = float("-Inf")
          for t in trials:
              metrics = get_trial_info(t).get("metrics", None)
              if metrics and metrics.get(sort_key, None):
                  current_metric = float(metrics[sort_key])
                  if current_metric > max_metric:
                      winner["trial_id"] = t.trial_id
                      winner["metric"] = sort_key + ": " + str(current_metric)
                      max_metric = current_metric
      return winner
docs: Get winner trial of a job.