We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Problems when displaying multiple views of ContainerWidget. 
`ContainerView.render` registers anonymous functions to `this.model.on('displayed')` . This is a problem because when rendering multiple views of the same widget container, multiple instances of this anonymous function get registered to this event. 

PS: This is also related to #5958


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/html/widgets/widget_container.py`
Content:
```
1 """ContainerWidget class.  
2 
3 Represents a container that can be used to group other widgets.
4 """
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
7 #
8 # Distributed under the terms of the Modified BSD License.
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
12 
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16 from .widget import DOMWidget
17 from IPython.utils.traitlets import Unicode, Tuple, TraitError
18 
19 #-----------------------------------------------------------------------------
20 # Classes
21 #-----------------------------------------------------------------------------
22 
23 class ContainerWidget(DOMWidget):
24     _view_name = Unicode('ContainerView', sync=True)
25 
26     # Child widgets in the container.
27     # Using a tuple here to force reassignment to update the list.
28     # When a proper notifying-list trait exists, that is what should be used here.
29     children = Tuple()
30     _children = Tuple(sync=True)
31 
32 
33     def __init__(self, **kwargs):
34         super(ContainerWidget, self).__init__(**kwargs)
35         self.on_displayed(ContainerWidget._fire_children_displayed)
36 
37     def _fire_children_displayed(self):
38         for child in self._children:
39             child._handle_displayed()
40 
41     def _children_changed(self, name, old, new):
42         """Validate children list.
43 
44         Makes sure only one instance of any given model can exist in the 
45         children list.
46         An excellent post on uniqifiers is available at 
47             http://www.peterbe.com/plog/uniqifiers-benchmark
48         which provides the inspiration for using this implementation.  Below
49         I've implemented the `f5` algorithm using Python comprehensions."""
50         if new is not None:
51             seen = {}
52             def add_item(i):
53                 seen[i.model_id] = True
54                 return i
55             self._children = [add_item(i) for i in new if not i.model_id in seen]
56 
57 
58 class PopupWidget(ContainerWidget):
59     _view_name = Unicode('PopupView', sync=True)
60     
61     description = Unicode(sync=True)
62     button_text = Unicode(sync=True)
63
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py
--- a/IPython/html/widgets/widget_container.py
+++ b/IPython/html/widgets/widget_container.py
@@ -2,58 +2,29 @@
 
 Represents a container that can be used to group other widgets.
 """
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, the IPython Development Team.
-#
+
+# Copyright (c) IPython Development Team.
 # Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
 
-#-----------------------------------------------------------------------------
-# Imports
-#-----------------------------------------------------------------------------
 from .widget import DOMWidget
 from IPython.utils.traitlets import Unicode, Tuple, TraitError
 
-#-----------------------------------------------------------------------------
-# Classes
-#-----------------------------------------------------------------------------
-
 class ContainerWidget(DOMWidget):
     _view_name = Unicode('ContainerView', sync=True)
 
     # Child widgets in the container.
     # Using a tuple here to force reassignment to update the list.
     # When a proper notifying-list trait exists, that is what should be used here.
-    children = Tuple()
-    _children = Tuple(sync=True)
-
+    children = Tuple(sync=True)
 
     def __init__(self, **kwargs):
         super(ContainerWidget, self).__init__(**kwargs)
         self.on_displayed(ContainerWidget._fire_children_displayed)
 
     def _fire_children_displayed(self):
-        for child in self._children:
+        for child in self.children:
             child._handle_displayed()
 
-    def _children_changed(self, name, old, new):
-        """Validate children list.
-
-        Makes sure only one instance of any given model can exist in the 
-        children list.
-        An excellent post on uniqifiers is available at 
-            http://www.peterbe.com/plog/uniqifiers-benchmark
-        which provides the inspiration for using this implementation.  Below
-        I've implemented the `f5` algorithm using Python comprehensions."""
-        if new is not None:
-            seen = {}
-            def add_item(i):
-                seen[i.model_id] = True
-                return i
-            self._children = [add_item(i) for i in new if not i.model_id in seen]
-
 
 class PopupWidget(ContainerWidget):
     _view_name = Unicode('PopupView', sync=True)

{"golden_diff": "diff --git a/IPython/html/widgets/widget_container.py b/IPython/html/widgets/widget_container.py\n--- a/IPython/html/widgets/widget_container.py\n+++ b/IPython/html/widgets/widget_container.py\n@@ -2,58 +2,29 @@\n \n Represents a container that can be used to group other widgets.\n \"\"\"\n-#-----------------------------------------------------------------------------\n-# Copyright (c) 2013, the IPython Development Team.\n-#\n+\n+# Copyright (c) IPython Development Team.\n # Distributed under the terms of the Modified BSD License.\n-#\n-# The full license is in the file COPYING.txt, distributed with this software.\n-#-----------------------------------------------------------------------------\n \n-#-----------------------------------------------------------------------------\n-# Imports\n-#-----------------------------------------------------------------------------\n from .widget import DOMWidget\n from IPython.utils.traitlets import Unicode, Tuple, TraitError\n \n-#-----------------------------------------------------------------------------\n-# Classes\n-#-----------------------------------------------------------------------------\n-\n class ContainerWidget(DOMWidget):\n     _view_name = Unicode('ContainerView', sync=True)\n \n     # Child widgets in the container.\n     # Using a tuple here to force reassignment to update the list.\n     # When a proper notifying-list trait exists, that is what should be used here.\n-    children = Tuple()\n-    _children = Tuple(sync=True)\n-\n+    children = Tuple(sync=True)\n \n     def __init__(self, **kwargs):\n         super(ContainerWidget, self).__init__(**kwargs)\n         self.on_displayed(ContainerWidget._fire_children_displayed)\n \n     def _fire_children_displayed(self):\n-        for child in self._children:\n+        for child in self.children:\n             child._handle_displayed()\n \n-    def _children_changed(self, name, old, new):\n-        \"\"\"Validate children list.\n-\n-        Makes sure only one instance of any given model can exist in the \n-        children list.\n-        An excellent post on uniqifiers is available at \n-            http://www.peterbe.com/plog/uniqifiers-benchmark\n-        which provides the inspiration for using this implementation.  Below\n-        I've implemented the `f5` algorithm using Python comprehensions.\"\"\"\n-        if new is not None:\n-            seen = {}\n-            def add_item(i):\n-                seen[i.model_id] = True\n-                return i\n-            self._children = [add_item(i) for i in new if not i.model_id in seen]\n-\n \n class PopupWidget(ContainerWidget):\n     _view_name = Unicode('PopupView', sync=True)\n", "issue": "Problems when displaying multiple views of ContainerWidget. \n`ContainerView.render` registers anonymous functions to `this.model.on('displayed')` . This is a problem because when rendering multiple views of the same widget container, multiple instances of this anonymous function get registered to this event. \n\nPS: This is also related to #5958\n\n", "before_files": [{"content": "\"\"\"ContainerWidget class.  \n\nRepresents a container that can be used to group other widgets.\n\"\"\"\n#-----------------------------------------------------------------------------\n# Copyright (c) 2013, the IPython Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\nfrom .widget import DOMWidget\nfrom IPython.utils.traitlets import Unicode, Tuple, TraitError\n\n#-----------------------------------------------------------------------------\n# Classes\n#-----------------------------------------------------------------------------\n\nclass ContainerWidget(DOMWidget):\n    _view_name = Unicode('ContainerView', sync=True)\n\n    # Child widgets in the container.\n    # Using a tuple here to force reassignment to update the list.\n    # When a proper notifying-list trait exists, that is what should be used here.\n    children = Tuple()\n    _children = Tuple(sync=True)\n\n\n    def __init__(self, **kwargs):\n        super(ContainerWidget, self).__init__(**kwargs)\n        self.on_displayed(ContainerWidget._fire_children_displayed)\n\n    def _fire_children_displayed(self):\n        for child in self._children:\n            child._handle_displayed()\n\n    def _children_changed(self, name, old, new):\n        \"\"\"Validate children list.\n\n        Makes sure only one instance of any given model can exist in the \n        children list.\n        An excellent post on uniqifiers is available at \n            http://www.peterbe.com/plog/uniqifiers-benchmark\n        which provides the inspiration for using this implementation.  Below\n        I've implemented the `f5` algorithm using Python comprehensions.\"\"\"\n        if new is not None:\n            seen = {}\n            def add_item(i):\n                seen[i.model_id] = True\n                return i\n            self._children = [add_item(i) for i in new if not i.model_id in seen]\n\n\nclass PopupWidget(ContainerWidget):\n    _view_name = Unicode('PopupView', sync=True)\n    \n    description = Unicode(sync=True)\n    button_text = Unicode(sync=True)\n", "path": "IPython/html/widgets/widget_container.py"}], "after_files": [{"content": "\"\"\"ContainerWidget class.  \n\nRepresents a container that can be used to group other widgets.\n\"\"\"\n\n# Copyright (c) IPython Development Team.\n# Distributed under the terms of the Modified BSD License.\n\nfrom .widget import DOMWidget\nfrom IPython.utils.traitlets import Unicode, Tuple, TraitError\n\nclass ContainerWidget(DOMWidget):\n    _view_name = Unicode('ContainerView', sync=True)\n\n    # Child widgets in the container.\n    # Using a tuple here to force reassignment to update the list.\n    # When a proper notifying-list trait exists, that is what should be used here.\n    children = Tuple(sync=True)\n\n    def __init__(self, **kwargs):\n        super(ContainerWidget, self).__init__(**kwargs)\n        self.on_displayed(ContainerWidget._fire_children_displayed)\n\n    def _fire_children_displayed(self):\n        for child in self.children:\n            child._handle_displayed()\n\n\nclass PopupWidget(ContainerWidget):\n    _view_name = Unicode('PopupView', sync=True)\n    \n    description = Unicode(sync=True)\n    button_text = Unicode(sync=True)\n", "path": "IPython/html/widgets/widget_container.py"}]}