code: def widget_to_html(
      widget: Widget,
      html_out: t.Union[str, io.TextIOWrapper],
      title: str = "",
      requirejs: bool = True,
      connected: bool = True,
      full_html: bool = True,
  ):
      """Save widget as html file.
  
      Parameters
      ----------
      widget: Widget
          The widget to save as html.
      html_out: filename or file-like object
          The file to write the HTML output to.
      title: str , default: None
          The title of the html file.
      requirejs: bool , default: True
          If to save with all javascript dependencies.
      connected : bool, default True
          whether to use CDN or not
      full_html: bool, default True
          whether to return full html page or not
      """
      state = dependency_state(widget)
      data = embed_data(views=[widget], drop_defaults=True, state=state)
  
      snippet = snippet_template.format(
          load="",  # will be added below
          json_data=escape_script(
              json.dumps(data["manager_state"], default=json_encoder)
          ),
          widget_views="\n".join(
              widget_view_template.format(
                  view_spec=escape_script(
                      json.dumps(view_spec, default=json_encoder)
                  )
              )
              for view_spec in data["view_specs"]
          ),
      )
  
      template = suite_template(full_html=full_html)
      html = template.replace("$Title", title).replace(
          "$WidgetSnippet", snippet
      )
  
      # if connected is True widgets js library will load jupyterlab-plotly by itself
      jupyterlab_plotly_lib = (
          jupyterlab_plotly_script(False) if connected is False else ""
      )
  
      requirejs_lib = requirejs_script(connected) if requirejs else ""
      widgetsjs_lib = widgets_script(connected, amd_module=requirejs)
      tags = f"{requirejs_lib}{jupyterlab_plotly_lib}{widgetsjs_lib}"
      html = html.replace("$WidgetJavascript", tags)
  
      if isinstance(html_out, str):
          with open(html_out, "w", encoding="utf-8") as f:
              f.write(html)
      elif isinstance(html_out, (io.TextIOBase, io.TextIOWrapper)):
          html_out.write(html)
      else:
          name = type(html_out).__name__
          raise TypeError(
              f'Unsupported type of "html_out" parameter - {name}'
          )
  
imports: import io
  import itertools
  import json
  import os
  import random
  import re
  import sys
  import typing
  from collections import defaultdict
  from copy import copy
  from datetime import datetime
  from decimal import Decimal
  from string import ascii_uppercase, digits
  import numpy
  import pandas
  from ipywidgets import Widget
  from ipywidgets.embed import dependency_state, embed_data, escape_script, snippet_template, widget_view_template
  from packaging.version import Version
  from pandas.core.dtypes.common import is_numeric_dtype
  import deepchecks
  from deepchecks import core
  from deepchecks.core.resources import jupyterlab_plotly_script, requirejs_script, suite_template, widgets_script
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 3 for calling a global function with example usage: widget_to_html(widget, html_out, title, requirejs, connected, full_html) without return types