code: def silence(warning: Warning, silence: bool = True) -> set[Warning]:
      """Silence a particular warning on all Bokeh models.
  
      Args:
          warning (Warning) : Bokeh warning to silence
          silence (bool) : Whether or not to silence the warning
  
      Returns:
          A set containing the all silenced warnings
  
      This function adds or removes warnings from a set of silencers which
      is referred to when running ``check_integrity``. If a warning
      is added to the silencers - then it will never be raised.
  
      .. code-block:: python
  
          >>> from bokeh.core.validation.warnings import EMPTY_LAYOUT
          >>> bokeh.core.validation.silence(EMPTY_LAYOUT, True)
          {1002}
  
      To turn a warning back on use the same method but with the silence
      argument set to false
  
      .. code-block:: python
  
          >>> bokeh.core.validation.silence(EMPTY_LAYOUT, False)
          set()
  
      """
      if not isinstance(warning, Warning):
          raise ValueError(
              f"Input to silence should be a warning object - not of type {type(warning)}"
          )
      if silence:
          __silencers__.add(warning)
      elif warning in __silencers__:
          __silencers__.remove(warning)
      return __silencers__
  
file_path: bokeh/src/bokeh/core/validation/check.py
imports: from __future__ import annotations
  import logging
  import contextlib
  from typing import Iterable, Iterator, Literal, Protocol
  from ...model import Model
  from ...settings import settings
  from ...util.dataclasses import dataclass
  from .issue import Warning
label_desc: Use image node_id 1 for calling a global function with example usage: silence(warning, silence) and returns: __silencers__