code: def cleanup(self):
          
          plots = self.traverse(lambda x: x, [BokehPlot])
          for plot in plots:
              if not isinstance(plot, (GenericCompositePlot, GenericElementPlot, GenericOverlayPlot)):
                  continue
              streams = list(plot.streams)
              plot.streams = []
              plot._document = None
  
              if plot.subplots:
                  plot.subplots.clear()
  
              if isinstance(plot, GenericElementPlot):
                  for callback in plot.callbacks:
                      streams += callback.streams
                      callback.cleanup()
  
              for stream in set(streams):
                  stream._subscribers = [
                      (p, subscriber) for p, subscriber in stream._subscribers
                      if get_method_owner(subscriber) not in plots
                  ]
  
          if self.comm and self.root is self.handles.get('plot'):
              self.comm.close()
docs: Cleans up references to the plot after the plot has been
          deleted. Traverses through all plots cleaning up Callbacks and
          Stream subscribers.