keras/src/saving/saving_api.py/save_weights
def save_weights(model, filepath, overwrite=True, **kwargs):
    if not str(filepath).endswith(".weights.h5"):
        raise ValueError(
            "The filename must end in `.weights.h5`. "
            f"Received: filepath={filepath}"
        )
    try:
        exists = os.path.exists(filepath)
    except TypeError:
        exists = False
    if exists and not overwrite:
        proceed = io_utils.ask_to_proceed_with_overwrite(filepath)
        if not proceed:
            return
    saving_lib.save_weights_only(model, filepath, **kwargs)