How to save model during tuning

i want to save the model during tune process when i get a new best reward, not only save the model after finish the whole tune.
but i do not know how to write the code.
i tried to use the callback function but i do not the the save function which can be used
here is my code

import ray
from ray import train, tune
from ray.rllib.algorithms import Algorithm
from ray.tune import Callback
from ray.tune.registry import get_trainable_cls

class SaveModelOnNewMaxRewardCallback(Callback):
    def __init__(self, max_reward_key="episode_reward_max", model_save_path="model_checkpoint"):
        self.max_reward_key = max_reward_key
        self.model_save_path = model_save_path
        self.best_reward = float("-inf")

    def on_trial_result(self, iteration, trials, trial, result, **info):
        new_max_reward = result.get(self.max_reward_key, None)
        if new_max_reward is not None and new_max_reward > self.best_reward:
            self.best_reward = new_max_reward
            # save the model


config = (
# 创建回调函数实例
save_model_callback = SaveModelOnNewMaxRewardCallback()
# ```` allows setting a custom log directory (other than ``~/ray-results``)
tuner = ray.tune.Tuner(
        stop={"episode_reward_mean": 50},

results =

# Get the best result based on a particular metric.
best_result = results.get_best_result(metric="episode_reward_mean", mode="max")

# Get the best checkpoint corresponding to the best result.
best_checkpoint = best_result.checkpoint

algo = Algorithm.from_checkpoint("model_checkpoint")

there is no trial.save_checkpoint(self.model_save_path) function
thanks a lot