We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ignore `label` in the workflow if it's not tensor
**Is your feature request related to a problem? Please describe.**
During evaluation, now we use `prepare_batch` to extract `image` and `label` fields if existing the key. But maybe we don't want to load `label` for inference and didn't apply transforms, so need to ignore it for this case.


--- 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/engines/utils.py`
Content:
```
1 # Copyright 2020 - 2021 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 typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union
13 
14 import torch
15 
16 from monai.utils import exact_version, optional_import
17 from monai.utils.enums import CommonKeys
18 
19 if TYPE_CHECKING:
20     from ignite.engine import EventEnum
21 else:
22     EventEnum, _ = optional_import("ignite.engine", "0.4.4", exact_version, "EventEnum")
23 
24 __all__ = [
25     "IterationEvents",
26     "GanKeys",
27     "get_devices_spec",
28     "default_prepare_batch",
29     "default_make_latent",
30 ]
31 
32 
33 class IterationEvents(EventEnum):
34     """
35     Additional Events engine can register and trigger in the iteration process.
36     Refer to the example in ignite: https://github.com/pytorch/ignite/blob/master/ignite/engine/events.py#L146
37     These Events can be triggered during training iteration:
38     `FORWARD_COMPLETED` is the Event when `network(image, label)` completed.
39     `LOSS_COMPLETED` is the Event when `loss(pred, label)` completed.
40     `BACKWARD_COMPLETED` is the Event when `loss.backward()` completed.
41     `MODEL_COMPLETED` is the Event when all the model related operations completed.
42 
43     """
44 
45     FORWARD_COMPLETED = "forward_completed"
46     LOSS_COMPLETED = "loss_completed"
47     BACKWARD_COMPLETED = "backward_completed"
48     MODEL_COMPLETED = "model_completed"
49 
50 
51 class GanKeys:
52     """
53     A set of common keys for generative adversarial networks.
54 
55     """
56 
57     REALS = "reals"
58     FAKES = "fakes"
59     LATENTS = "latents"
60     GLOSS = "g_loss"
61     DLOSS = "d_loss"
62 
63 
64 def get_devices_spec(devices: Optional[Sequence[torch.device]] = None) -> List[torch.device]:
65     """
66     Get a valid specification for one or more devices. If `devices` is None get devices for all CUDA devices available.
67     If `devices` is and zero-length structure a single CPU compute device is returned. In any other cases `devices` is
68     returned unchanged.
69 
70     Args:
71         devices: list of devices to request, None for all GPU devices, [] for CPU.
72 
73     Raises:
74         RuntimeError: When all GPUs are selected (``devices=None``) but no GPUs are available.
75 
76     Returns:
77         list of torch.device: list of devices.
78 
79     """
80     if devices is None:
81         devices = [torch.device(f"cuda:{d:d}") for d in range(torch.cuda.device_count())]
82 
83         if len(devices) == 0:
84             raise RuntimeError("No GPU devices available.")
85 
86     elif len(devices) == 0:
87         devices = [torch.device("cpu")]
88 
89     else:
90         devices = list(devices)
91 
92     return devices
93 
94 
95 def default_prepare_batch(
96     batchdata: Dict[str, torch.Tensor],
97     device: Optional[Union[str, torch.device]] = None,
98     non_blocking: bool = False,
99 ) -> Union[Tuple[torch.Tensor, Optional[torch.Tensor]], torch.Tensor]:
100     """
101     Default function to prepare the data for current iteration.
102     Refer to ignite: https://github.com/pytorch/ignite/blob/v0.4.2/ignite/engine/__init__.py#L28.
103 
104     Returns:
105         image, label(optional).
106 
107     """
108     if not isinstance(batchdata, dict):
109         raise AssertionError("default prepare_batch expects dictionary input data.")
110     if CommonKeys.LABEL in batchdata:
111         return (
112             batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking),
113             batchdata[CommonKeys.LABEL].to(device=device, non_blocking=non_blocking),
114         )
115     if GanKeys.REALS in batchdata:
116         return batchdata[GanKeys.REALS].to(device=device, non_blocking=non_blocking)
117     return batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking), None
118 
119 
120 def default_make_latent(
121     num_latents: int,
122     latent_size: int,
123     device: Optional[Union[str, torch.device]] = None,
124     non_blocking: bool = False,
125 ) -> torch.Tensor:
126     return torch.randn(num_latents, latent_size).to(device=device, non_blocking=non_blocking)
127
```
--- 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/engines/utils.py b/monai/engines/utils.py
--- a/monai/engines/utils.py
+++ b/monai/engines/utils.py
@@ -107,7 +107,7 @@
     """
     if not isinstance(batchdata, dict):
         raise AssertionError("default prepare_batch expects dictionary input data.")
-    if CommonKeys.LABEL in batchdata:
+    if isinstance(batchdata.get(CommonKeys.LABEL, None), torch.Tensor):
         return (
             batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking),
             batchdata[CommonKeys.LABEL].to(device=device, non_blocking=non_blocking),

{"golden_diff": "diff --git a/monai/engines/utils.py b/monai/engines/utils.py\n--- a/monai/engines/utils.py\n+++ b/monai/engines/utils.py\n@@ -107,7 +107,7 @@\n     \"\"\"\n     if not isinstance(batchdata, dict):\n         raise AssertionError(\"default prepare_batch expects dictionary input data.\")\n-    if CommonKeys.LABEL in batchdata:\n+    if isinstance(batchdata.get(CommonKeys.LABEL, None), torch.Tensor):\n         return (\n             batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking),\n             batchdata[CommonKeys.LABEL].to(device=device, non_blocking=non_blocking),\n", "issue": "ignore `label` in the workflow if it's not tensor\n**Is your feature request related to a problem? Please describe.**\r\nDuring evaluation, now we use `prepare_batch` to extract `image` and `label` fields if existing the key. But maybe we don't want to load `label` for inference and didn't apply transforms, so need to ignore it for this case.\r\n\n", "before_files": [{"content": "# Copyright 2020 - 2021 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 typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union\n\nimport torch\n\nfrom monai.utils import exact_version, optional_import\nfrom monai.utils.enums import CommonKeys\n\nif TYPE_CHECKING:\n    from ignite.engine import EventEnum\nelse:\n    EventEnum, _ = optional_import(\"ignite.engine\", \"0.4.4\", exact_version, \"EventEnum\")\n\n__all__ = [\n    \"IterationEvents\",\n    \"GanKeys\",\n    \"get_devices_spec\",\n    \"default_prepare_batch\",\n    \"default_make_latent\",\n]\n\n\nclass IterationEvents(EventEnum):\n    \"\"\"\n    Additional Events engine can register and trigger in the iteration process.\n    Refer to the example in ignite: https://github.com/pytorch/ignite/blob/master/ignite/engine/events.py#L146\n    These Events can be triggered during training iteration:\n    `FORWARD_COMPLETED` is the Event when `network(image, label)` completed.\n    `LOSS_COMPLETED` is the Event when `loss(pred, label)` completed.\n    `BACKWARD_COMPLETED` is the Event when `loss.backward()` completed.\n    `MODEL_COMPLETED` is the Event when all the model related operations completed.\n\n    \"\"\"\n\n    FORWARD_COMPLETED = \"forward_completed\"\n    LOSS_COMPLETED = \"loss_completed\"\n    BACKWARD_COMPLETED = \"backward_completed\"\n    MODEL_COMPLETED = \"model_completed\"\n\n\nclass GanKeys:\n    \"\"\"\n    A set of common keys for generative adversarial networks.\n\n    \"\"\"\n\n    REALS = \"reals\"\n    FAKES = \"fakes\"\n    LATENTS = \"latents\"\n    GLOSS = \"g_loss\"\n    DLOSS = \"d_loss\"\n\n\ndef get_devices_spec(devices: Optional[Sequence[torch.device]] = None) -> List[torch.device]:\n    \"\"\"\n    Get a valid specification for one or more devices. If `devices` is None get devices for all CUDA devices available.\n    If `devices` is and zero-length structure a single CPU compute device is returned. In any other cases `devices` is\n    returned unchanged.\n\n    Args:\n        devices: list of devices to request, None for all GPU devices, [] for CPU.\n\n    Raises:\n        RuntimeError: When all GPUs are selected (``devices=None``) but no GPUs are available.\n\n    Returns:\n        list of torch.device: list of devices.\n\n    \"\"\"\n    if devices is None:\n        devices = [torch.device(f\"cuda:{d:d}\") for d in range(torch.cuda.device_count())]\n\n        if len(devices) == 0:\n            raise RuntimeError(\"No GPU devices available.\")\n\n    elif len(devices) == 0:\n        devices = [torch.device(\"cpu\")]\n\n    else:\n        devices = list(devices)\n\n    return devices\n\n\ndef default_prepare_batch(\n    batchdata: Dict[str, torch.Tensor],\n    device: Optional[Union[str, torch.device]] = None,\n    non_blocking: bool = False,\n) -> Union[Tuple[torch.Tensor, Optional[torch.Tensor]], torch.Tensor]:\n    \"\"\"\n    Default function to prepare the data for current iteration.\n    Refer to ignite: https://github.com/pytorch/ignite/blob/v0.4.2/ignite/engine/__init__.py#L28.\n\n    Returns:\n        image, label(optional).\n\n    \"\"\"\n    if not isinstance(batchdata, dict):\n        raise AssertionError(\"default prepare_batch expects dictionary input data.\")\n    if CommonKeys.LABEL in batchdata:\n        return (\n            batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking),\n            batchdata[CommonKeys.LABEL].to(device=device, non_blocking=non_blocking),\n        )\n    if GanKeys.REALS in batchdata:\n        return batchdata[GanKeys.REALS].to(device=device, non_blocking=non_blocking)\n    return batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking), None\n\n\ndef default_make_latent(\n    num_latents: int,\n    latent_size: int,\n    device: Optional[Union[str, torch.device]] = None,\n    non_blocking: bool = False,\n) -> torch.Tensor:\n    return torch.randn(num_latents, latent_size).to(device=device, non_blocking=non_blocking)\n", "path": "monai/engines/utils.py"}], "after_files": [{"content": "# Copyright 2020 - 2021 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 typing import TYPE_CHECKING, Dict, List, Optional, Sequence, Tuple, Union\n\nimport torch\n\nfrom monai.utils import exact_version, optional_import\nfrom monai.utils.enums import CommonKeys\n\nif TYPE_CHECKING:\n    from ignite.engine import EventEnum\nelse:\n    EventEnum, _ = optional_import(\"ignite.engine\", \"0.4.4\", exact_version, \"EventEnum\")\n\n__all__ = [\n    \"IterationEvents\",\n    \"GanKeys\",\n    \"get_devices_spec\",\n    \"default_prepare_batch\",\n    \"default_make_latent\",\n]\n\n\nclass IterationEvents(EventEnum):\n    \"\"\"\n    Additional Events engine can register and trigger in the iteration process.\n    Refer to the example in ignite: https://github.com/pytorch/ignite/blob/master/ignite/engine/events.py#L146\n    These Events can be triggered during training iteration:\n    `FORWARD_COMPLETED` is the Event when `network(image, label)` completed.\n    `LOSS_COMPLETED` is the Event when `loss(pred, label)` completed.\n    `BACKWARD_COMPLETED` is the Event when `loss.backward()` completed.\n    `MODEL_COMPLETED` is the Event when all the model related operations completed.\n\n    \"\"\"\n\n    FORWARD_COMPLETED = \"forward_completed\"\n    LOSS_COMPLETED = \"loss_completed\"\n    BACKWARD_COMPLETED = \"backward_completed\"\n    MODEL_COMPLETED = \"model_completed\"\n\n\nclass GanKeys:\n    \"\"\"\n    A set of common keys for generative adversarial networks.\n\n    \"\"\"\n\n    REALS = \"reals\"\n    FAKES = \"fakes\"\n    LATENTS = \"latents\"\n    GLOSS = \"g_loss\"\n    DLOSS = \"d_loss\"\n\n\ndef get_devices_spec(devices: Optional[Sequence[torch.device]] = None) -> List[torch.device]:\n    \"\"\"\n    Get a valid specification for one or more devices. If `devices` is None get devices for all CUDA devices available.\n    If `devices` is and zero-length structure a single CPU compute device is returned. In any other cases `devices` is\n    returned unchanged.\n\n    Args:\n        devices: list of devices to request, None for all GPU devices, [] for CPU.\n\n    Raises:\n        RuntimeError: When all GPUs are selected (``devices=None``) but no GPUs are available.\n\n    Returns:\n        list of torch.device: list of devices.\n\n    \"\"\"\n    if devices is None:\n        devices = [torch.device(f\"cuda:{d:d}\") for d in range(torch.cuda.device_count())]\n\n        if len(devices) == 0:\n            raise RuntimeError(\"No GPU devices available.\")\n\n    elif len(devices) == 0:\n        devices = [torch.device(\"cpu\")]\n\n    else:\n        devices = list(devices)\n\n    return devices\n\n\ndef default_prepare_batch(\n    batchdata: Dict[str, torch.Tensor],\n    device: Optional[Union[str, torch.device]] = None,\n    non_blocking: bool = False,\n) -> Union[Tuple[torch.Tensor, Optional[torch.Tensor]], torch.Tensor]:\n    \"\"\"\n    Default function to prepare the data for current iteration.\n    Refer to ignite: https://github.com/pytorch/ignite/blob/v0.4.2/ignite/engine/__init__.py#L28.\n\n    Returns:\n        image, label(optional).\n\n    \"\"\"\n    if not isinstance(batchdata, dict):\n        raise AssertionError(\"default prepare_batch expects dictionary input data.\")\n    if isinstance(batchdata.get(CommonKeys.LABEL, None), torch.Tensor):\n        return (\n            batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking),\n            batchdata[CommonKeys.LABEL].to(device=device, non_blocking=non_blocking),\n        )\n    if GanKeys.REALS in batchdata:\n        return batchdata[GanKeys.REALS].to(device=device, non_blocking=non_blocking)\n    return batchdata[CommonKeys.IMAGE].to(device=device, non_blocking=non_blocking), None\n\n\ndef default_make_latent(\n    num_latents: int,\n    latent_size: int,\n    device: Optional[Union[str, torch.device]] = None,\n    non_blocking: bool = False,\n) -> torch.Tensor:\n    return torch.randn(num_latents, latent_size).to(device=device, non_blocking=non_blocking)\n", "path": "monai/engines/utils.py"}]}