class_docstr: Poor man helper to switch between different backends at run-time.
class_docstr_tok: ["Poor","man","helper","to","switch","between","different","backends","at","run-time","."]
code: def set_backend(self, backend):
      if backend and (backend == self._backend):
          lgr.debug("not changing backend since the same %s", backend)
          return
      if backend is None:
          # Might be IPython
          ipython_shell = get_ipython_shell()
          if ipython_shell:
              # Good old ipython would have TerminalInteractiveShell
              if ipython_shell.__class__.__name__ in (
                  "ZMQInteractiveShell",
              ):
                  backend = "ipython"
                  # well -- this will not even be printed yet since unlikely
                  # the lgr handlers were set already
                  lgr.info(
                      "Detected IPython session. Setting UI backend to %r. "
                      "If this is not a web IPython notebook session, you "
                      "might like to datalad.ui.ui.set_backend('dialog'). "
                      "Other known UI backends: %s",
                      backend,
                      ", ".join(KNOWN_BACKENDS),
                  )
              else:
                  backend = "dialog"
          else:
              backend = "dialog" if is_interactive() else "no-progress"
      self._ui = KNOWN_BACKENDS[backend]()
      lgr.debug("UI set to %s", self._ui)
      self._backend = backend
  
file_path: datalad/datalad/ui/__init__.py
imports: from logging import getLogger
  from .dialog import ConsoleLog, DialogUI, IPythonUI, UnderAnnexUI, UnderTestsUI, SilentConsoleLog, QuietConsoleLog
  from ..utils import is_interactive, get_ipython_shell
label_desc: Use image node_id 2 for calling the _UI_Switcher obj's underlying member method code with example usage: obj.set_backend(backend) without return types