code: def modify_document(self, doc):
      # checks that session created hook has run, and session destroyed has not.
      assert self.session_creation_async_value == 3
      doc.title = "Modified"
      doc.roots[0].hooks.append("modify")
      self.hooks.append("modify")
  
      doc.add_next_tick_callback(self.on_next_tick)
      doc.add_timeout_callback(self.on_timeout, 2)
      periodic_cb = doc.add_periodic_callback(self.on_periodic, 3)
      self.periodic_remover = lambda: doc.remove_periodic_callback(
          periodic_cb
      )
  
imports: from __future__ import annotations
  import pytest
  import asyncio
  import logging
  import re
  import ssl
  import sys
  import time
  from datetime import timedelta
  from unittest import mock
  import tornado
  from _util_server import http_get, url, websocket_open, ws_url
  from tornado.httpclient import HTTPError
  from tornado.httpserver import HTTPServer
  from tornado.ioloop import IOLoop
  from bokeh.application import Application
  from bokeh.application.handlers import Handler
  from bokeh.client import pull_session
  from bokeh.core.properties import List, String
  from bokeh.core.types import ID
  from bokeh.model import Model
  from bokeh.server.server import BaseServer, Server
  from bokeh.server.tornado import BokehTornado
  from bokeh.util.token import check_token_signature, generate_jwt_token, get_session_id, get_token_payload
  from tests.support.plugins.managed_server_loop import MSL
  import bokeh.server.server
label_desc: Use image node_id 2 for calling the HookTestHandler obj's underlying member method code with example usage: obj.modify_document(doc) without return types