code: def _display(
      port=None, height=None, print_message=False, display_handle=None
  ):
      """Internal version of `display`.
  
      Args:
        port: As with `display`.
        height: As with `display`.
        print_message: True to print which TensorBoard instance was selected
          for display (if applicable), or False otherwise.
        display_handle: If not None, an IPython display handle into which to
          render TensorBoard.
      """
      if height is None:
          height = 800
  
      if port is None:
          infos = manager.get_all()
          if not infos:
              raise ValueError(
                  "Can't display TensorBoard: no known instances running."
              )
          else:
              info = max(manager.get_all(), key=lambda x: x.start_time)
              port = info.port
      else:
          infos = [i for i in manager.get_all() if i.port == port]
          info = (
              max(infos, key=lambda x: x.start_time) if infos else None
          )
  
      if print_message:
          if info is not None:
              message = (
                  "Selecting TensorBoard with {data_source} "
                  "(started {delta} ago; port {port}, pid {pid})."
              ).format(
                  data_source=manager.data_source_from_info(info),
                  delta=_time_delta_from_info(info),
                  port=info.port,
                  pid=info.pid,
              )
              print(message)
          else:
              # The user explicitly provided a port, and we don't have any
              # additional information. There's nothing useful to say.
              pass
  
      fn = {
          _CONTEXT_COLAB: _display_colab,
          _CONTEXT_IPYTHON: _display_ipython,
          _CONTEXT_NONE: _display_cli,
      }[_get_context()]
      return fn(port=port, height=height, display_handle=display_handle)
  
imports: import datetime
  import errno
  import html
  import json
  import os
  import random
  import shlex
  import textwrap
  import time
  from tensorboard import manager
label_desc: Use image node_id 9 for calling a global function with example usage: _display(port, height, print_message, display_handle) and returns: fn