from pathlib import Path

def delete_optimizer_pt(folder_path: str = ".") -> None:
    """
    Delete every file named 'optimizer.pt' inside the given folder
    (including all its sub-folders).

    Parameters
    ----------
    folder_path : str
        Path to the root folder you want to clean.  
        Defaults to the current working directory (".").
    """
    deleted = 0
    for file_path in Path(folder_path).rglob("optimizer.pt"):
        try:
            file_path.unlink()          # Permanently removes the file
            deleted += 1
        except Exception as e:
            print(f"Couldn’t delete {file_path}: {e}")

    print(f"Finished – deleted {deleted} file(s).")

# --- run it ---------------------------------------------------------------
if __name__ == "__main__":
    delete_optimizer_pt("/workspace/P76127027/Research/models")