def METHOD_NAME(model_state_dict, swa_model_state_dict, optimizer_state_dict, metrics_obj_state_dict, running_metrics, train_state, last_val_metrics, path):
    assert path is not None
    state_dict = {}
    state_dict["model"] = model_state_dict
    state_dict["optimizer"] = optimizer_state_dict
    state_dict["metrics"] = metrics_obj_state_dict
    state_dict["running_metrics"] = running_metrics
    state_dict["train_state"] = train_state
    state_dict["last_val_metrics"] = last_val_metrics
    state_dict["config"] = model_config
    if swa_model_state_dict is not None:
        state_dict["swa_model"] = swa_model_state_dict
    logging.info("Saving checkpoint: " + path)
    torch.METHOD_NAME(state_dict, path + ".tmp")
    time.sleep(1)
    os.replace(path + ".tmp", path)