We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
sphinx documentation warnings
**Describe the bug**
building the documentation locally generates a couple of warnings:
```bash
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 16 source files that are out of date
updating environment: [new config] 16 added, 0 changed, 0 removed
/usr/local/anaconda3/envs/py36/lib/python3.6/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document
  warn("Container node skipped: type={0}".format(mdnode.t))
/usr/local/anaconda3/envs/py36/lib/python3.6/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document
  warn("Container node skipped: type={0}".format(mdnode.t))
reading sources... [100%] visualize                                                                                            
WARNING: autodoc: failed to import class 'handlers.CheckpointLoader' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.CheckpointSaver' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.ClassificationSaver' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.MeanDice' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.ROCAUC' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.MetricLogger' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.SegmentationSaver' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.StatsHandler' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.TensorBoardStatsHandler' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.LrScheduleHandler' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
WARNING: autodoc: failed to import class 'handlers.ValidationHandler' from module 'monai'; the following exception was raised:
cannot import name 'RemovableEventHandle'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] visualize                              
```

**To Reproduce**
Steps to reproduce the behavior:
1. Go to `MONAI/docs`
2. ` pip install -U -r requirements.txt` to install doc deps
3. Run `make clean; make html`

**Expected behavior**
no warnings in the building log

**Environment (please complete the following information):**
```
MONAI version: 0.2.0+77.g783f6a1
Python version: 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43)  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
Numpy version: 1.19.1
Pytorch version: 1.6.0

Optional dependencies:
Pytorch Ignite version: 0.3.0
Nibabel version: 3.1.1
scikit-image version: 0.17.2
Pillow version: 7.2.0
Tensorboard version: 2.3.0
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `monai/handlers/metric_logger.py`
Content:
```
1 # Copyright 2020 MONAI Consortium
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #     http://www.apache.org/licenses/LICENSE-2.0
6 # Unless required by applicable law or agreed to in writing, software
7 # distributed under the License is distributed on an "AS IS" BASIS,
8 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 # See the License for the specific language governing permissions and
10 # limitations under the License.
11 
12 from collections import defaultdict
13 from typing import TYPE_CHECKING, Callable, DefaultDict, List
14 
15 from monai.utils import exact_version, optional_import
16 
17 Events, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Events")
18 if TYPE_CHECKING:
19     from ignite.engine import Engine, RemovableEventHandle
20 else:
21     Engine, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Engine")
22     RemovableEventHandle, _ = optional_import("ignite.engine", "0.3.0", exact_version, "RemovableEventHandle")
23 
24 
25 class MetricLogger:
26     def __init__(self, loss_transform: Callable = lambda x: x, metric_transform: Callable = lambda x: x) -> None:
27         self.loss_transform = loss_transform
28         self.metric_transform = metric_transform
29         self.loss: List = []
30         self.metrics: DefaultDict = defaultdict(list)
31 
32     def attach(self, engine: Engine) -> RemovableEventHandle:
33         """
34         Args:
35             engine: Ignite Engine, it can be a trainer, validator or evaluator.
36         """
37         return engine.add_event_handler(Events.ITERATION_COMPLETED, self)
38 
39     def __call__(self, engine: Engine) -> None:
40         """
41         Args:
42             engine: Ignite Engine, it can be a trainer, validator or evaluator.
43         """
44         self.loss.append(self.loss_transform(engine.state.output))
45 
46         for m, v in engine.state.metrics.items():
47             v = self.metric_transform(v)
48             #             # metrics may not be added on the first timestep, pad the list if this is the case
49             #             # so that each metric list is the same length as self.loss
50             #             if len(self.metrics[m])==0:
51             #                 self.metrics[m].append([v[0]]*len(self.loss))
52 
53             self.metrics[m].append(v)
54 
55 
56 metriclogger = MetricLogger
57
```

Path: `monai/handlers/checkpoint_loader.py`
Content:
```
1 # Copyright 2020 MONAI Consortium
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #     http://www.apache.org/licenses/LICENSE-2.0
6 # Unless required by applicable law or agreed to in writing, software
7 # distributed under the License is distributed on an "AS IS" BASIS,
8 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9 # See the License for the specific language governing permissions and
10 # limitations under the License.
11 
12 import logging
13 from typing import TYPE_CHECKING, Dict, Optional
14 
15 import torch
16 
17 from monai.utils import exact_version, optional_import
18 
19 Events, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Events")
20 Checkpoint, _ = optional_import("ignite.handlers", "0.3.0", exact_version, "Checkpoint")
21 if TYPE_CHECKING:
22     from ignite.engine import Engine, RemovableEventHandle
23 else:
24     Engine, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Engine")
25     RemovableEventHandle, _ = optional_import("ignite.engine", "0.3.0", exact_version, "RemovableEventHandle")
26 
27 
28 class CheckpointLoader:
29     """
30     CheckpointLoader acts as an Ignite handler to load checkpoint data from file.
31     It can load variables for network, optimizer, lr_scheduler, etc.
32     If saving checkpoint after `torch.nn.DataParallel`, need to save `model.module` instead
33     as PyTorch recommended and then use this loader to load the model.
34 
35     Args:
36         load_path: the file path of checkpoint, it should be a PyTorch `pth` file.
37         load_dict: target objects that load checkpoint to. examples::
38 
39             {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}
40 
41         name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.
42 
43     """
44 
45     def __init__(self, load_path: str, load_dict: Dict, name: Optional[str] = None) -> None:
46         assert load_path is not None, "must provide clear path to load checkpoint."
47         self.load_path = load_path
48         assert load_dict is not None and len(load_dict) > 0, "must provide target objects to load."
49         self.logger = logging.getLogger(name)
50         for k, v in load_dict.items():
51             if hasattr(v, "module"):
52                 load_dict[k] = v.module
53         self.load_dict = load_dict
54 
55         self._name = name
56 
57     def attach(self, engine: Engine) -> RemovableEventHandle:
58         """
59         Args:
60             engine: Ignite Engine, it can be a trainer, validator or evaluator.
61         """
62         if self._name is None:
63             self.logger = engine.logger
64         return engine.add_event_handler(Events.STARTED, self)
65 
66     def __call__(self, engine: Engine) -> None:
67         """
68         Args:
69             engine: Ignite Engine, it can be a trainer, validator or evaluator.
70         """
71         checkpoint = torch.load(self.load_path)
72         if len(self.load_dict) == 1:
73             key = list(self.load_dict.keys())[0]
74             if not (key in checkpoint):
75                 checkpoint = {key: checkpoint}
76 
77         Checkpoint.load_objects(to_load=self.load_dict, checkpoint=checkpoint)
78         self.logger.info(f"Restored all variables from {self.load_path}")
79
```
--- 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/monai/handlers/checkpoint_loader.py b/monai/handlers/checkpoint_loader.py
--- a/monai/handlers/checkpoint_loader.py
+++ b/monai/handlers/checkpoint_loader.py
@@ -19,10 +19,9 @@
 Events, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Events")
 Checkpoint, _ = optional_import("ignite.handlers", "0.3.0", exact_version, "Checkpoint")
 if TYPE_CHECKING:
-    from ignite.engine import Engine, RemovableEventHandle
+    from ignite.engine import Engine
 else:
     Engine, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Engine")
-    RemovableEventHandle, _ = optional_import("ignite.engine", "0.3.0", exact_version, "RemovableEventHandle")
 
 
 class CheckpointLoader:
@@ -54,14 +53,14 @@
 
         self._name = name
 
-    def attach(self, engine: Engine) -> RemovableEventHandle:
+    def attach(self, engine: Engine) -> None:
         """
         Args:
             engine: Ignite Engine, it can be a trainer, validator or evaluator.
         """
         if self._name is None:
             self.logger = engine.logger
-        return engine.add_event_handler(Events.STARTED, self)
+        engine.add_event_handler(Events.STARTED, self)
 
     def __call__(self, engine: Engine) -> None:
         """
diff --git a/monai/handlers/metric_logger.py b/monai/handlers/metric_logger.py
--- a/monai/handlers/metric_logger.py
+++ b/monai/handlers/metric_logger.py
@@ -16,10 +16,9 @@
 
 Events, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Events")
 if TYPE_CHECKING:
-    from ignite.engine import Engine, RemovableEventHandle
+    from ignite.engine import Engine
 else:
     Engine, _ = optional_import("ignite.engine", "0.3.0", exact_version, "Engine")
-    RemovableEventHandle, _ = optional_import("ignite.engine", "0.3.0", exact_version, "RemovableEventHandle")
 
 
 class MetricLogger:
@@ -29,12 +28,12 @@
         self.loss: List = []
         self.metrics: DefaultDict = defaultdict(list)
 
-    def attach(self, engine: Engine) -> RemovableEventHandle:
+    def attach(self, engine: Engine) -> None:
         """
         Args:
             engine: Ignite Engine, it can be a trainer, validator or evaluator.
         """
-        return engine.add_event_handler(Events.ITERATION_COMPLETED, self)
+        engine.add_event_handler(Events.ITERATION_COMPLETED, self)
 
     def __call__(self, engine: Engine) -> None:
         """

{"golden_diff": "diff --git a/monai/handlers/checkpoint_loader.py b/monai/handlers/checkpoint_loader.py\n--- a/monai/handlers/checkpoint_loader.py\n+++ b/monai/handlers/checkpoint_loader.py\n@@ -19,10 +19,9 @@\n Events, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\n Checkpoint, _ = optional_import(\"ignite.handlers\", \"0.3.0\", exact_version, \"Checkpoint\")\n if TYPE_CHECKING:\n-    from ignite.engine import Engine, RemovableEventHandle\n+    from ignite.engine import Engine\n else:\n     Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n-    RemovableEventHandle, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"RemovableEventHandle\")\n \n \n class CheckpointLoader:\n@@ -54,14 +53,14 @@\n \n         self._name = name\n \n-    def attach(self, engine: Engine) -> RemovableEventHandle:\n+    def attach(self, engine: Engine) -> None:\n         \"\"\"\n         Args:\n             engine: Ignite Engine, it can be a trainer, validator or evaluator.\n         \"\"\"\n         if self._name is None:\n             self.logger = engine.logger\n-        return engine.add_event_handler(Events.STARTED, self)\n+        engine.add_event_handler(Events.STARTED, self)\n \n     def __call__(self, engine: Engine) -> None:\n         \"\"\"\ndiff --git a/monai/handlers/metric_logger.py b/monai/handlers/metric_logger.py\n--- a/monai/handlers/metric_logger.py\n+++ b/monai/handlers/metric_logger.py\n@@ -16,10 +16,9 @@\n \n Events, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\n if TYPE_CHECKING:\n-    from ignite.engine import Engine, RemovableEventHandle\n+    from ignite.engine import Engine\n else:\n     Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n-    RemovableEventHandle, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"RemovableEventHandle\")\n \n \n class MetricLogger:\n@@ -29,12 +28,12 @@\n         self.loss: List = []\n         self.metrics: DefaultDict = defaultdict(list)\n \n-    def attach(self, engine: Engine) -> RemovableEventHandle:\n+    def attach(self, engine: Engine) -> None:\n         \"\"\"\n         Args:\n             engine: Ignite Engine, it can be a trainer, validator or evaluator.\n         \"\"\"\n-        return engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n+        engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n \n     def __call__(self, engine: Engine) -> None:\n         \"\"\"\n", "issue": "sphinx documentation warnings\n**Describe the bug**\r\nbuilding the documentation locally generates a couple of warnings:\r\n```bash\r\nbuilding [mo]: targets for 0 po files that are out of date\r\nbuilding [html]: targets for 16 source files that are out of date\r\nupdating environment: [new config] 16 added, 0 changed, 0 removed\r\n/usr/local/anaconda3/envs/py36/lib/python3.6/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document\r\n  warn(\"Container node skipped: type={0}\".format(mdnode.t))\r\n/usr/local/anaconda3/envs/py36/lib/python3.6/site-packages/recommonmark/parser.py:75: UserWarning: Container node skipped: type=document\r\n  warn(\"Container node skipped: type={0}\".format(mdnode.t))\r\nreading sources... [100%] visualize                                                                                            \r\nWARNING: autodoc: failed to import class 'handlers.CheckpointLoader' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.CheckpointSaver' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.ClassificationSaver' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.MeanDice' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.ROCAUC' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.MetricLogger' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.SegmentationSaver' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.StatsHandler' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.TensorBoardStatsHandler' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.LrScheduleHandler' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nWARNING: autodoc: failed to import class 'handlers.ValidationHandler' from module 'monai'; the following exception was raised:\r\ncannot import name 'RemovableEventHandle'\r\nlooking for now-outdated files... none found\r\npickling environment... done\r\nchecking consistency... done\r\npreparing documents... done\r\nwriting output... [100%] visualize                              \r\n```\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Go to `MONAI/docs`\r\n2. ` pip install -U -r requirements.txt` to install doc deps\r\n3. Run `make clean; make html`\r\n\r\n**Expected behavior**\r\nno warnings in the building log\r\n\r\n**Environment (please complete the following information):**\r\n```\r\nMONAI version: 0.2.0+77.g783f6a1\r\nPython version: 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 18:53:43)  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]\r\nNumpy version: 1.19.1\r\nPytorch version: 1.6.0\r\n\r\nOptional dependencies:\r\nPytorch Ignite version: 0.3.0\r\nNibabel version: 3.1.1\r\nscikit-image version: 0.17.2\r\nPillow version: 7.2.0\r\nTensorboard version: 2.3.0\r\n```\r\n\n", "before_files": [{"content": "# Copyright 2020 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom collections import defaultdict\nfrom typing import TYPE_CHECKING, Callable, DefaultDict, List\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n    from ignite.engine import Engine, RemovableEventHandle\nelse:\n    Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n    RemovableEventHandle, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"RemovableEventHandle\")\n\n\nclass MetricLogger:\n    def __init__(self, loss_transform: Callable = lambda x: x, metric_transform: Callable = lambda x: x) -> None:\n        self.loss_transform = loss_transform\n        self.metric_transform = metric_transform\n        self.loss: List = []\n        self.metrics: DefaultDict = defaultdict(list)\n\n    def attach(self, engine: Engine) -> RemovableEventHandle:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        return engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n\n    def __call__(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        self.loss.append(self.loss_transform(engine.state.output))\n\n        for m, v in engine.state.metrics.items():\n            v = self.metric_transform(v)\n            #             # metrics may not be added on the first timestep, pad the list if this is the case\n            #             # so that each metric list is the same length as self.loss\n            #             if len(self.metrics[m])==0:\n            #                 self.metrics[m].append([v[0]]*len(self.loss))\n\n            self.metrics[m].append(v)\n\n\nmetriclogger = MetricLogger\n", "path": "monai/handlers/metric_logger.py"}, {"content": "# Copyright 2020 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport logging\nfrom typing import TYPE_CHECKING, Dict, Optional\n\nimport torch\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nCheckpoint, _ = optional_import(\"ignite.handlers\", \"0.3.0\", exact_version, \"Checkpoint\")\nif TYPE_CHECKING:\n    from ignite.engine import Engine, RemovableEventHandle\nelse:\n    Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n    RemovableEventHandle, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"RemovableEventHandle\")\n\n\nclass CheckpointLoader:\n    \"\"\"\n    CheckpointLoader acts as an Ignite handler to load checkpoint data from file.\n    It can load variables for network, optimizer, lr_scheduler, etc.\n    If saving checkpoint after `torch.nn.DataParallel`, need to save `model.module` instead\n    as PyTorch recommended and then use this loader to load the model.\n\n    Args:\n        load_path: the file path of checkpoint, it should be a PyTorch `pth` file.\n        load_dict: target objects that load checkpoint to. examples::\n\n            {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}\n\n        name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.\n\n    \"\"\"\n\n    def __init__(self, load_path: str, load_dict: Dict, name: Optional[str] = None) -> None:\n        assert load_path is not None, \"must provide clear path to load checkpoint.\"\n        self.load_path = load_path\n        assert load_dict is not None and len(load_dict) > 0, \"must provide target objects to load.\"\n        self.logger = logging.getLogger(name)\n        for k, v in load_dict.items():\n            if hasattr(v, \"module\"):\n                load_dict[k] = v.module\n        self.load_dict = load_dict\n\n        self._name = name\n\n    def attach(self, engine: Engine) -> RemovableEventHandle:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        if self._name is None:\n            self.logger = engine.logger\n        return engine.add_event_handler(Events.STARTED, self)\n\n    def __call__(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        checkpoint = torch.load(self.load_path)\n        if len(self.load_dict) == 1:\n            key = list(self.load_dict.keys())[0]\n            if not (key in checkpoint):\n                checkpoint = {key: checkpoint}\n\n        Checkpoint.load_objects(to_load=self.load_dict, checkpoint=checkpoint)\n        self.logger.info(f\"Restored all variables from {self.load_path}\")\n", "path": "monai/handlers/checkpoint_loader.py"}], "after_files": [{"content": "# Copyright 2020 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom collections import defaultdict\nfrom typing import TYPE_CHECKING, Callable, DefaultDict, List\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nif TYPE_CHECKING:\n    from ignite.engine import Engine\nelse:\n    Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\nclass MetricLogger:\n    def __init__(self, loss_transform: Callable = lambda x: x, metric_transform: Callable = lambda x: x) -> None:\n        self.loss_transform = loss_transform\n        self.metric_transform = metric_transform\n        self.loss: List = []\n        self.metrics: DefaultDict = defaultdict(list)\n\n    def attach(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        engine.add_event_handler(Events.ITERATION_COMPLETED, self)\n\n    def __call__(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        self.loss.append(self.loss_transform(engine.state.output))\n\n        for m, v in engine.state.metrics.items():\n            v = self.metric_transform(v)\n            #             # metrics may not be added on the first timestep, pad the list if this is the case\n            #             # so that each metric list is the same length as self.loss\n            #             if len(self.metrics[m])==0:\n            #                 self.metrics[m].append([v[0]]*len(self.loss))\n\n            self.metrics[m].append(v)\n\n\nmetriclogger = MetricLogger\n", "path": "monai/handlers/metric_logger.py"}, {"content": "# Copyright 2020 MONAI Consortium\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#     http://www.apache.org/licenses/LICENSE-2.0\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport logging\nfrom typing import TYPE_CHECKING, Dict, Optional\n\nimport torch\n\nfrom monai.utils import exact_version, optional_import\n\nEvents, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Events\")\nCheckpoint, _ = optional_import(\"ignite.handlers\", \"0.3.0\", exact_version, \"Checkpoint\")\nif TYPE_CHECKING:\n    from ignite.engine import Engine\nelse:\n    Engine, _ = optional_import(\"ignite.engine\", \"0.3.0\", exact_version, \"Engine\")\n\n\nclass CheckpointLoader:\n    \"\"\"\n    CheckpointLoader acts as an Ignite handler to load checkpoint data from file.\n    It can load variables for network, optimizer, lr_scheduler, etc.\n    If saving checkpoint after `torch.nn.DataParallel`, need to save `model.module` instead\n    as PyTorch recommended and then use this loader to load the model.\n\n    Args:\n        load_path: the file path of checkpoint, it should be a PyTorch `pth` file.\n        load_dict: target objects that load checkpoint to. examples::\n\n            {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}\n\n        name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.\n\n    \"\"\"\n\n    def __init__(self, load_path: str, load_dict: Dict, name: Optional[str] = None) -> None:\n        assert load_path is not None, \"must provide clear path to load checkpoint.\"\n        self.load_path = load_path\n        assert load_dict is not None and len(load_dict) > 0, \"must provide target objects to load.\"\n        self.logger = logging.getLogger(name)\n        for k, v in load_dict.items():\n            if hasattr(v, \"module\"):\n                load_dict[k] = v.module\n        self.load_dict = load_dict\n\n        self._name = name\n\n    def attach(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        if self._name is None:\n            self.logger = engine.logger\n        engine.add_event_handler(Events.STARTED, self)\n\n    def __call__(self, engine: Engine) -> None:\n        \"\"\"\n        Args:\n            engine: Ignite Engine, it can be a trainer, validator or evaluator.\n        \"\"\"\n        checkpoint = torch.load(self.load_path)\n        if len(self.load_dict) == 1:\n            key = list(self.load_dict.keys())[0]\n            if not (key in checkpoint):\n                checkpoint = {key: checkpoint}\n\n        Checkpoint.load_objects(to_load=self.load_dict, checkpoint=checkpoint)\n        self.logger.info(f\"Restored all variables from {self.load_path}\")\n", "path": "monai/handlers/checkpoint_loader.py"}]}