code: function(Jupyter, kernel) {
      if (kernel.comm_manager && kernel.widget_manager === undefined) {
  
          // Clear any old widget manager
          if (Jupyter.WidgetManager) {
              Jupyter.WidgetManager._managers[0].clear_state();
          }
  
          // Create a new widget manager instance. Use the global
          // Jupyter.notebook handle.
          var manager = new mngr.WidgetManager(kernel.comm_manager, Jupyter.notebook);
  
          // For backwards compatibility and interactive use.
          Jupyter.WidgetManager = mngr.WidgetManager;
  
          // Store a handle to the manager so we know not to
          // another for this kernel. This also is a convenience
          // for the user.
          kernel.widget_manager = manager;
      }
  }
docs: Create a widget manager for a kernel instance.