class_docstr: Represents a websocket connection to a server-side session.
  
  Each server session stores a Document, which is kept in sync with the
  corresponding Document for this ``ClientSession`` instance. Updates on
  either side of the connection will automatically propagate to the other
  side, as long as the connection is open.
  
  ClientSession objects can (and usually should) be used as a context manager
  so that the session is properly closed:
  
  .. code-block:: python
  
      with pull_session(url=app_url) as mysession:
          # customize session here
          script = server_session(session_id=mysession.id, url=app_url)
          return render_template("embed.html", script=script, template="Flask")
  
  If you do not use ``ClientSession`` in this way, it is up to you to ensure
  that ``mysession.close()`` is called.
docstr: A connection which attaches to a particular named session on the
  server.
  
  Always call either pull() or push() immediately after creating the
  session (until these are called ``session.document`` will be ``None``).
  
  The :func:`~bokeh.client.session.push_session` and
  :func:`~bokeh.client.session.pull_session()` functions will construct a
  ``ClientSession`` and push or pull in one step, so they are a good way to
  obtain a ``ClientSession``.
  
  Args:
      session_id (str) :
          The name of the session or None to generate one
  
      websocket_url (str) :
          Websocket URL to connect to
  
      io_loop (IOLoop, optional) :
          The IOLoop to use for the websocket
  
      arguments (dict[str, str], optional) :
          A dictionary of key/values to be passed as HTTP request
          arguments to Bokeh application code (default: None)
  
          Note that should only be provided when pulling new sessions.
          If ``session_id`` is not None, or a session with ``session_id``
          already exists, these arguments will have no effect.
  
      max_message_size (int, optional) :
          Configure the Tornado max websocket message size.
          (default: 20 MB)
docstr_tok: ["A","connection","which","attaches","to","a","particular","named","session","on","the","server",".","Always","call","either","pull","(",")","or","push","(",")","immediately","after","creating","the","session","(","until","these","are","called","``","session.document","``","will","be","``","None","``",")",".","The",":","func",":","`","~bokeh.client.session.push_session","`","and",":","func",":","`","~bokeh.client.session.pull_session","(",")","`","functions","will","construct","a","``","ClientSession","``","and","push","or","pull","in","one","step",",","so","they","are","a","good","way","to","obtain","a","``","ClientSession","``",".","Args",":","session_id","(","str",")",":","The","name","of","the","session","or","None","to","generate","one","websocket_url","(","str",")",":","Websocket","URL","to","connect","to","io_loop","(","IOLoop",",","optional",")",":","The","IOLoop","to","use","for","the","websocket","arguments","(","dict","[","str",",","str","]",",","optional",")",":","A","dictionary","of","key\/values","to","be","passed","as","HTTP","request","arguments","to","Bokeh","application","code","(","default",":","None",")","Note","that","should","only","be","provided","when","pulling","new","sessions",".","If","``","session_id","``","is","not","None",",","or","a","session","with","``","session_id","``","already","exists",",","these","arguments","will","have","no","effect",".","max_message_size","(","int",",","optional",")",":","Configure","the","Tornado","max","websocket","message","size",".","(","default",":","20","MB",")"]
code: def __init__(
      self,
      session_id: ID | None = None,
      websocket_url: str = DEFAULT_SERVER_WEBSOCKET_URL,
      io_loop: IOLoop | None = None,
      arguments: dict[str, str] | None = None,
      max_message_size: int = 20 * 1024 * 1024,
  ):
      """A connection which attaches to a particular named session on the
      server.
  
      Always call either pull() or push() immediately after creating the
      session (until these are called ``session.document`` will be ``None``).
  
      The :func:`~bokeh.client.session.push_session` and
      :func:`~bokeh.client.session.pull_session()` functions will construct a
      ``ClientSession`` and push or pull in one step, so they are a good way to
      obtain a ``ClientSession``.
  
      Args:
          session_id (str) :
              The name of the session or None to generate one
  
          websocket_url (str) :
              Websocket URL to connect to
  
          io_loop (IOLoop, optional) :
              The IOLoop to use for the websocket
  
          arguments (dict[str, str], optional) :
              A dictionary of key/values to be passed as HTTP request
              arguments to Bokeh application code (default: None)
  
              Note that should only be provided when pulling new sessions.
              If ``session_id`` is not None, or a session with ``session_id``
              already exists, these arguments will have no effect.
  
          max_message_size (int, optional) :
              Configure the Tornado max websocket message size.
              (default: 20 MB)
  
      """
      self._document = None
      self._id = self._ensure_session_id(session_id)
  
      from .connection import ClientConnection
  
      self._connection = ClientConnection(
          session=self,
          io_loop=io_loop,
          websocket_url=websocket_url,
          arguments=arguments,
          max_message_size=max_message_size,
      )
  
      from ..server.callbacks import DocumentCallbackGroup
  
      self._callbacks = DocumentCallbackGroup(self._connection.io_loop)
  
imports: from __future__ import annotations
  import logging
  from typing import TYPE_CHECKING, Any, Literal
  from urllib.parse import quote_plus
  from ..core.types import ID
  from ..document import Document
  from ..resources import DEFAULT_SERVER_HTTP_URL, SessionCoordinates
  from ..util.browser import NEW_PARAM, BrowserLike, BrowserTarget
  from ..util.token import generate_jwt_token, generate_session_id
  from .states import ErrorReason
  from .util import server_url_for_websocket_url, websocket_url_for_server_url
label_desc: Use image node_id 1 to create a new ClientSession object  with example: obj = ClientSession(session_id, websocket_url, io_loop, arguments, max_message_size)