docstr: Teardown hooks and display saving, called with wandb.finish.
docstr_tok: ["Teardown","hooks","and","display","saving",",","called","with","wandb.finish","."]
code: def _jupyter_teardown(self) -> None:
      """Teardown hooks and display saving, called with wandb.finish."""
      assert self.notebook
      ipython = self.notebook.shell
      self.notebook.save_history()
      if self.notebook.save_ipynb():
          assert self.run is not None
          res = self.run.log_code(root=None)
          logger.info("saved code and history: %s", res)  # type: ignore
      logger.info("cleaning up jupyter logic")  # type: ignore
      # because of how we bind our methods we manually find them to unregister
      for hook in ipython.events.callbacks["pre_run_cell"]:
          if "_resume_backend" in hook.__name__:
              ipython.events.unregister("pre_run_cell", hook)
      for hook in ipython.events.callbacks["post_run_cell"]:
          if "_pause_backend" in hook.__name__:
              ipython.events.unregister("post_run_cell", hook)
      ipython.display_pub.publish = ipython.display_pub._orig_publish
      del ipython.display_pub._orig_publish
  
imports: import copy
  import json
  import logging
  import os
  import platform
  import sys
  import tempfile
  import traceback
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, Union
  import wandb
  import wandb.env
  from wandb import trigger
  from wandb.errors import CommError, Error, UsageError
  from wandb.errors.util import ProtobufErrorHandler
  from wandb.integration import sagemaker
  from wandb.integration.magic import magic_install
  from wandb.sdk.lib import runid
  from wandb.sdk.lib.paths import StrPath
  from wandb.util import _is_artifact_representation
  from .None import wandb_login, wandb_setup
  from .backend.backend import Backend
  from .lib import RunDisabled, SummaryDisabled, filesystem, ipython, module, reporting, telemetry
  from .lib.deprecate import Deprecated, deprecate
  from .lib.mailbox import Mailbox, MailboxProgress
  from .lib.printer import Printer, get_printer
  from .lib.wburls import wburls
  from .wandb_helper import parse_config
  from .wandb_run import Run, TeardownHook, TeardownStage
  from .wandb_settings import Settings, Source
label_desc: Use image node_id 10 for calling the _WandbInit obj's underlying member method code with example usage: obj._jupyter_teardown() without return types