code: def __init__(self, *args, **kwargs):
      # Make sure transformer and renderer and registered
      import vegafusion as vf
      import vegafusion.transformer
      import vegafusion_jupyter.renderer
  
      # Support altair object or spec as the single positional argument
      if len(args) == 1:
          # Use single positional argument as spec
          kwargs.setdefault("spec", args[0])
  
      # Handle spec as Altair chart
      if isinstance(kwargs.get("spec", None), alt.TopLevelMixin):
          spec = kwargs["spec"]
  
          # If vegafusion-feather renderer is already enabled, use the same options
          if alt.data_transformers.active == "vegafusion-feather":
              data_transformer_opts = alt.data_transformers.options
          else:
              data_transformer_opts = dict()
  
          with vf.enable_widget(**data_transformer_opts):
              # Temporarily enable the vegafusion renderer and transformer so
              # that we use them even if they are not enabled globally
              spec = spec.to_dict()
  
          # Set spec as a dict, which will be converted to string below
          kwargs["spec"] = spec
  
      # Handle spec as dict
      if isinstance(kwargs.get("spec", None), dict):
          kwargs["spec"] = json.dumps(kwargs["spec"], indent=2)
  
      # If vegafusion renderer is already enabled, use the configured debounce options as the default
      if alt.renderers.active == "vegafusion-widget":
          # Use configured debounce options, if any
          renderer_opts = alt.renderers.options
          for opt in ["debounce_wait", "debounce_max_wait"]:
              if opt in renderer_opts:
                  kwargs.setdefault(opt, renderer_opts[opt])
  
      super().__init__(**kwargs)
  
      # Wire up widget message callback
      self.on_msg(self._handle_message)
  
file_path: vegafusion/python/vegafusion-jupyter/vegafusion_jupyter/widget.py
imports: from ipywidgets import DOMWidget
  from traitlets import Unicode, Bool, Float, CBytes, observe
  import time
  import logging
  from ._frontend import module_name, module_version
  import altair
  import json
label_desc: Use image node_id 1 to create a new VegaFusionWidget object from inherited base classes: DOMWidget with example: obj = VegaFusionWidget()