code: def check_token_signature(
      token: str,
      secret_key: bytes | None = settings.secret_key_bytes(),
      signed: bool = settings.sign_sessions(),
  ) -> bool:
      """Check the signature of a token and the contained signature.
  
      The server uses this function to check whether a token and the
      contained session id was generated with the correct secret key.
      If signed sessions are disabled, this function always returns True.
  
      Args:
          token (str) :
              The token to check
  
          secret_key (str, optional) :
              Secret key (default: value of BOKEH_SECRET_KEY environment variable)
  
          signed (bool, optional) :
              Whether to check anything (default: value of BOKEH_SIGN_SESSIONS
              environment variable)
  
      Returns:
          bool
  
      """
      secret_key = _ensure_bytes(secret_key)
      if signed:
          token_pieces = token.split(".", 1)
          if len(token_pieces) != 2:
              return False
          base_token = token_pieces[0]
          provided_token_signature = token_pieces[1]
          expected_token_signature = _signature(base_token, secret_key)
          # hmac.compare_digest() uses a string compare algorithm that doesn't
          # short-circuit so we don't allow timing analysis
          token_valid = hmac.compare_digest(
              expected_token_signature,
              provided_token_signature,
          )
          session_id = get_session_id(token)
          session_id_valid = check_session_id_signature(
              session_id, secret_key, signed
          )
          return token_valid and session_id_valid
      return True
  
imports: from __future__ import annotations
  import logging
  import base64
  import calendar
  import codecs
  import datetime
  import hashlib
  import hmac
  import json
  import time
  import zlib
  from typing import TYPE_CHECKING, Any
  from ..core.types import ID
  from ..settings import settings
  from .warnings import warn
label_desc: Use image node_id 6 for calling a global function with example usage: check_token_signature(token, secret_key, signed) and returns: True, unknown, False