diff --git a/monai/engines/utils.py b/monai/engines/utils.py index 9095f8d943..baeafd5081 100644 --- a/monai/engines/utils.py +++ b/monai/engines/utils.py @@ -219,8 +219,8 @@ def __call__( `kwargs` supports other args for `Tensor.to()` API. """ image, label = default_prepare_batch(batchdata, device, non_blocking, **kwargs) - args_ = list() - kwargs_ = dict() + args_ = [] + kwargs_ = {} def _get_data(key: str) -> torch.Tensor: data = batchdata[key] @@ -235,7 +235,7 @@ def _get_data(key: str) -> torch.Tensor: args_.append(_get_data(k)) elif isinstance(self.extra_keys, dict): for k, v in self.extra_keys.items(): - kwargs_.update({k: _get_data(v)}) + kwargs_[k] = _get_data(v) return cast(torch.Tensor, image), cast(torch.Tensor, label), tuple(args_), kwargs_