Repository: Project-MONAI/MONAI

Issue:
test_auto3dseg_ensemble test error
```
[2022-12-12T21:38:32.963Z]     raise value
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/multiprocessing/pool.py", line 125, in worker
[2022-12-12T21:38:32.963Z]     result = (True, func(*args, **kwds))
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/dataset.py", line 884, in _load_cache_item
[2022-12-12T21:38:32.963Z]     item = apply_transform(_xform, item)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/transform.py", line 129, in apply_transform
[2022-12-12T21:38:32.963Z]     raise RuntimeError(f"applying transform {transform}") from e
[2022-12-12T21:38:32.963Z] RuntimeError: applying transform <monai.transforms.croppad.dictionary.SpatialPadd object at 0x7f2c3619d790>
[2022-12-12T21:38:33.888Z] 
[2022-12-12T21:38:33.889Z] EFinished test: test_ensemble (tests.test_auto3dseg_ensemble.TestEnsembleBuilder) (61.9s)
```

<details>

```
[2022-12-12T21:37:32.052Z] Starting test: test_ensemble (tests.test_auto3dseg_ensemble.TestEnsembleBuilder)...
[2022-12-12T21:37:33.124Z] 
  0%|          | 0/12 [00:00<?, ?it/s]
  8%|▊         | 1/12 [00:00<00:06,  1.80it/s]
 58%|█████▊    | 7/12 [00:00<00:01,  2.53it/s]
100%|██████████| 12/12 [00:01<00:00, 11.78it/s]
[2022-12-12T21:37:34.052Z] 
algo_templates.tar.gz: 0.00B [00:00, ?B/s]
algo_templates.tar.gz:  18%|█▊        | 8.00k/44.0k [00:00<00:03, 9.49kB/s]
algo_templates.tar.gz: 48.0kB [00:00, 52.6kB/s]                            2022-12-12 21:37:34,014 - INFO - Downloaded: /tmp/tmpxvqyhybp/algo_templates.tar.gz
[2022-12-12T21:37:34.052Z] 2022-12-12 21:37:34,014 - INFO - Expected md5 is None, skip md5 check for file /tmp/tmpxvqyhybp/algo_templates.tar.gz.
[2022-12-12T21:37:34.052Z] 2022-12-12 21:37:34,015 - INFO - Writing into directory: /tmp/tmp3r2jiw7p/workdir.
[2022-12-12T21:37:34.613Z] 2022-12-12 21:37:34,468 - INFO - /tmp/tmp3r2jiw7p/workdir/segresnet2d_0
[2022-12-12T21:37:34.868Z] 2022-12-12 21:37:34,803 - INFO - /tmp/tmp3r2jiw7p/workdir/dints_0
[2022-12-12T21:37:35.123Z] 2022-12-12 21:37:35,097 - INFO - /tmp/tmp3r2jiw7p/workdir/swinunetr_0
[2022-12-12T21:37:35.683Z] 2022-12-12 21:37:35,408 - INFO - /tmp/tmp3r2jiw7p/workdir/segresnet_0
[2022-12-12T21:37:35.684Z] 2022-12-12 21:37:35,408 - INFO - Launching: python /tmp/tmp3r2jiw7p/workdir/segresnet2d_0/scripts/train.py run --config_file='/tmp/tmp3r2jiw7p/workdir/segresnet2d_0/configs/transforms_train.yaml','/tmp/tmp3r2jiw7p/workdir/segresnet2d_0/configs/transforms_infer.yaml','/tmp/tmp3r2jiw7p/workdir/segresnet2d_0/configs/hyper_parameters.yaml','/tmp/tmp3r2jiw7p/workdir/segresnet2d_0/configs/network.yaml','/tmp/tmp3r2jiw7p/workdir/segresnet2d_0/configs/transforms_validate.yaml' --num_iterations=4 --num_iterations_per_validation=4 --num_images_per_batch=2 --num_epochs=1 --num_warmup_iterations=4 --use_pretrain=False --pretrained_path=
[2022-12-12T21:37:43.765Z] [info] number of GPUs: 1
[2022-12-12T21:37:43.766Z] [info] world_size: 1
[2022-12-12T21:37:43.766Z] train_files: 8
[2022-12-12T21:37:43.766Z] val_files: 4
[2022-12-12T21:37:43.766Z] num_epochs 1
[2022-12-12T21:37:43.766Z] num_epochs_per_validation 1
[2022-12-12T21:37:43.766Z] [info] training from scratch
[2022-12-12T21:37:43.766Z] [info] amp enabled
[2022-12-12T21:37:43.766Z] ----------
[2022-12-12T21:37:43.766Z] epoch 1/1
[2022-12-12T21:37:43.766Z] learning rate is set to 0.2
[2022-12-12T21:37:44.326Z] <function compute_meandice at 0x7fe8778210d0>: Function `compute_meandice` has been deprecated since version 1.0.0. use `compute_dice` instead.
[2022-12-12T21:37:44.326Z] [2022-12-12 21:37:43] 1/4, train_loss: 0.6647
[2022-12-12T21:37:44.326Z] [2022-12-12 21:37:43] 2/4, train_loss: 0.4190
[2022-12-12T21:37:44.326Z] [2022-12-12 21:37:43] 3/4, train_loss: 0.3129
[2022-12-12T21:37:44.326Z] [2022-12-12 21:37:43] 4/4, train_loss: 0.3899
[2022-12-12T21:37:44.326Z] epoch 1 average loss: 0.4466, best mean dice: -1.0000 at epoch -1
[2022-12-12T21:37:44.326Z] 1 / 4 tensor([[0.7866]], device='cuda:0')
[2022-12-12T21:37:44.326Z] 2 / 4 tensor([[0.7051]], device='cuda:0')
[2022-12-12T21:37:44.326Z] 3 / 4 tensor([[0.6903]], device='cuda:0')
[2022-12-12T21:37:44.326Z] 4 / 4 tensor([[0.6117]], device='cuda:0')
[2022-12-12T21:37:44.326Z] evaluation metric - class 1: 0.6984416246414185
[2022-12-12T21:37:44.326Z] avg_metric 0.6984416246414185
[2022-12-12T21:37:44.326Z] saved new best metric model
[2022-12-12T21:37:44.326Z] current epoch: 1 current mean dice: 0.6984 best mean dice: 0.6984 at epoch 1
[2022-12-12T21:37:44.326Z] train completed, best_metric: 0.6984 at epoch: 1
[2022-12-12T21:37:44.326Z] 0.6984416246414185
[2022-12-12T21:37:45.257Z] 2022-12-12 21:37:45,057 - INFO - Launching: python /tmp/tmp3r2jiw7p/workdir/dints_0/scripts/search.py run --config_file='/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_train.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_infer.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/network_search.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/hyper_parameters.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/network.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_validate.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/hyper_parameters_search.yaml' --searching#num_iterations=4 --searching#num_iterations_per_validation=4 --searching#num_images_per_batch=2 --searching#num_epochs=1 --searching#num_warmup_iterations=4 --searching#use_pretrain=False --searching#pretrained_path=
[2022-12-12T21:37:55.196Z] [info] number of GPUs: 1
[2022-12-12T21:37:55.196Z] [info] world_size: 1
[2022-12-12T21:37:55.196Z] train_files_w: 4
[2022-12-12T21:37:55.196Z] train_files_a: 4
[2022-12-12T21:37:55.196Z] val_files: 4
[2022-12-12T21:37:55.196Z] num_epochs 2
[2022-12-12T21:37:55.196Z] num_epochs_warmup 2
[2022-12-12T21:37:55.196Z] num_epochs_per_validation 2
[2022-12-12T21:37:55.196Z] [info] amp enabled
[2022-12-12T21:37:55.196Z] ----------
[2022-12-12T21:37:55.196Z] epoch 1/2
[2022-12-12T21:37:55.196Z] learning rate is set to 0.025
[2022-12-12T21:37:57.086Z] [2022-12-12 21:37:55] 1/2, train_loss: 0.6681
[2022-12-12T21:37:57.088Z] [2022-12-12 21:37:56] 2/2, train_loss: 0.7003
[2022-12-12T21:37:57.088Z] epoch 1 average loss: 0.6842, best mean dice: -1.0000 at epoch -1
[2022-12-12T21:37:57.088Z] ----------
[2022-12-12T21:37:57.088Z] epoch 2/2
[2022-12-12T21:37:57.088Z] learning rate is set to 0.025
[2022-12-12T21:37:57.088Z] The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. 
[2022-12-12T21:37:57.088Z] Non-finite norm encountered in torch.nn.utils.clip_grad_norm_; continuing anyway. Note that the default behavior will change in a future release to error out if a non-finite total norm is encountered. At that point, setting error_if_nonfinite=false will be required to retain the old behavior.
[2022-12-12T21:37:57.343Z] Default upsampling behavior when mode=trilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
[2022-12-12T21:37:57.343Z] Default upsampling behavior when mode=trilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
[2022-12-12T21:38:15.384Z] <function compute_meandice at 0x7faa4b0da550>: Function `compute_meandice` has been deprecated since version 1.0.0. use `compute_dice` instead.
[2022-12-12T21:38:15.385Z] [2022-12-12 21:37:58] 1/2, train_loss: 0.6705
[2022-12-12T21:38:15.385Z] [2022-12-12 21:37:59] 2/2, train_loss: 0.7194
[2022-12-12T21:38:15.385Z] epoch 2 average loss: 0.6949, best mean dice: -1.0000 at epoch -1
[2022-12-12T21:38:15.385Z] 1 / 4 tensor([[0.4815]], device='cuda:0')
[2022-12-12T21:38:15.385Z] 2 / 4 tensor([[0.3614]], device='cuda:0')
[2022-12-12T21:38:15.385Z] 3 / 4 tensor([[0.3651]], device='cuda:0')
[2022-12-12T21:38:15.385Z] 4 / 4 tensor([[0.3793]], device='cuda:0')
[2022-12-12T21:38:15.385Z] evaluation metric - class 1: 0.39682692289352417
[2022-12-12T21:38:15.385Z] avg_metric 0.39682692289352417
[2022-12-12T21:38:15.385Z] saved new best metric model
[2022-12-12T21:38:15.385Z] current epoch: 2 current mean dice: 0.3968 best mean dice: 0.3968 at epoch 2
[2022-12-12T21:38:15.385Z] train completed, best_metric: 0.3968 at epoch: 2
[2022-12-12T21:38:15.385Z] 2022-12-12 21:38:14,526 - INFO - Launching: python /tmp/tmp3r2jiw7p/workdir/dints_0/scripts/train.py run --config_file='/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_train.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_infer.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/network_search.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/hyper_parameters.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/network.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/transforms_validate.yaml','/tmp/tmp3r2jiw7p/workdir/dints_0/configs/hyper_parameters_search.yaml' --training#num_iterations=4 --training#num_iterations_per_validation=4 --training#num_images_per_batch=2 --training#num_epochs=1 --training#num_warmup_iterations=4 --training#use_pretrain=False --training#pretrained_path=
[2022-12-12T21:38:23.468Z] [info] number of GPUs: 1
[2022-12-12T21:38:23.469Z] [info] world_size: 1
[2022-12-12T21:38:23.469Z] train_files: 8
[2022-12-12T21:38:23.469Z] val_files: 4
[2022-12-12T21:38:23.469Z] num_epochs 1
[2022-12-12T21:38:23.469Z] num_epochs_per_validation 1
[2022-12-12T21:38:23.469Z] [info] training from scratch
[2022-12-12T21:38:23.469Z] [info] amp enabled
[2022-12-12T21:38:23.469Z] ----------
[2022-12-12T21:38:23.469Z] epoch 1/1
[2022-12-12T21:38:23.469Z] learning rate is set to 0.2
[2022-12-12T21:38:25.982Z] Default upsampling behavior when mode=trilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
[2022-12-12T21:38:27.872Z] The default behavior for interpolate/upsample with float scale_factor changed in 1.6.0 to align with other frameworks/libraries, and now uses scale_factor directly, instead of relying on the computed output size. If you wish to restore the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details. 
[2022-12-12T21:38:27.872Z] <function compute_meandice at 0x7f476687fee0>: Function `compute_meandice` has been deprecated since version 1.0.0. use `compute_dice` instead.
[2022-12-12T21:38:27.872Z] [2022-12-12 21:38:24] 1/4, train_loss: 0.6794
[2022-12-12T21:38:27.872Z] [2022-12-12 21:38:24] 2/4, train_loss: 0.6015
[2022-12-12T21:38:27.872Z] [2022-12-12 21:38:25] 3/4, train_loss: 0.6137
[2022-12-12T21:38:27.872Z] [2022-12-12 21:38:25] 4/4, train_loss: 0.5467
[2022-12-12T21:38:27.872Z] epoch 1 average loss: 0.6103, best mean dice: -1.0000 at epoch -1
[2022-12-12T21:38:27.872Z] 1 / 4 tensor([[0.5169]], device='cuda:0')
[2022-12-12T21:38:27.872Z] 2 / 4 tensor([[0.5320]], device='cuda:0')
[2022-12-12T21:38:27.872Z] 3 / 4 tensor([[0.5546]], device='cuda:0')
[2022-12-12T21:38:27.872Z] 4 / 4 tensor([[0.5383]], device='cuda:0')
[2022-12-12T21:38:27.872Z] evaluation metric - class 1: 0.5354511737823486
[2022-12-12T21:38:27.872Z] avg_metric 0.5354511737823486
[2022-12-12T21:38:27.872Z] saved new best metric model
[2022-12-12T21:38:27.872Z] current epoch: 1 current mean dice: 0.5355 best mean dice: 0.5355 at epoch 1
[2022-12-12T21:38:27.872Z] train completed, best_metric: 0.5355 at epoch: 1
[2022-12-12T21:38:27.872Z] 0.5354511737823486
[2022-12-12T21:38:28.797Z] 2022-12-12 21:38:28,567 - INFO - Launching: python /tmp/tmp3r2jiw7p/workdir/swinunetr_0/scripts/train.py run --config_file='/tmp/tmp3r2jiw7p/workdir/swinunetr_0/configs/transforms_train.yaml','/tmp/tmp3r2jiw7p/workdir/swinunetr_0/configs/transforms_infer.yaml','/tmp/tmp3r2jiw7p/workdir/swinunetr_0/configs/hyper_parameters.yaml','/tmp/tmp3r2jiw7p/workdir/swinunetr_0/configs/network.yaml','/tmp/tmp3r2jiw7p/workdir/swinunetr_0/configs/transforms_validate.yaml' --num_iterations=4 --num_iterations_per_validation=4 --num_images_per_batch=2 --num_epochs=1 --num_warmup_iterations=4 --use_pretrain=False --pretrained_path=
[2022-12-12T21:38:32.963Z] [info] number of GPUs: 1
[2022-12-12T21:38:32.963Z] [info] world_size: 1
[2022-12-12T21:38:32.963Z] train_files: 8
[2022-12-12T21:38:32.963Z] val_files: 4
[2022-12-12T21:38:32.963Z] Traceback (most recent call last):
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/croppad/array.py", line 184, in __call__
[2022-12-12T21:38:32.963Z]     out = _pad(img_t, pad_width=to_pad_, mode=mode_, **kwargs_)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/croppad/array.py", line 138, in _pt_pad
[2022-12-12T21:38:32.963Z]     return pad_pt(img.unsqueeze(0), pt_pad_width, mode=mode, **kwargs).squeeze(0)
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py", line 4149, in _pad
[2022-12-12T21:38:32.963Z]     return handle_torch_function(_pad, (input,), input, pad, mode=mode, value=value)
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/torch/overrides.py", line 1252, in handle_torch_function
[2022-12-12T21:38:32.963Z]     result = overloaded_arg.__torch_function__(public_api, types, args, kwargs)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/meta_tensor.py", line 268, in __torch_function__
[2022-12-12T21:38:32.963Z]     ret = super().__torch_function__(func, types, args, kwargs)
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/torch/_tensor.py", line 1023, in __torch_function__
[2022-12-12T21:38:32.963Z]     ret = func(*args, **kwargs)
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py", line 4181, in _pad
[2022-12-12T21:38:32.963Z]     raise NotImplementedError
[2022-12-12T21:38:32.963Z] NotImplementedError
[2022-12-12T21:38:32.963Z] 
[2022-12-12T21:38:32.963Z] The above exception was the direct cause of the following exception:
[2022-12-12T21:38:32.963Z] 
[2022-12-12T21:38:32.963Z] Traceback (most recent call last):
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/transform.py", line 102, in apply_transform
[2022-12-12T21:38:32.963Z]     return _apply_transform(transform, data, unpack_items)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/transform.py", line 66, in _apply_transform
[2022-12-12T21:38:32.963Z]     return transform(parameters)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/croppad/dictionary.py", line 147, in __call__
[2022-12-12T21:38:32.963Z]     d[key] = self.padder(d[key], mode=m)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/croppad/array.py", line 189, in __call__
[2022-12-12T21:38:32.963Z]     raise ValueError(f"{mode_}, {kwargs_}, {img_t.dtype}, {img_t.device}") from err
[2022-12-12T21:38:32.963Z] ValueError: reflect, {}, torch.float32, cpu
[2022-12-12T21:38:32.963Z] 
[2022-12-12T21:38:32.963Z] The above exception was the direct cause of the following exception:
[2022-12-12T21:38:32.963Z] 
[2022-12-12T21:38:32.963Z] Traceback (most recent call last):
[2022-12-12T21:38:32.963Z]   File "/tmp/tmp3r2jiw7p/workdir/swinunetr_0/scripts/train.py", line 430, in <module>
[2022-12-12T21:38:32.963Z]     fire.Fire()
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
[2022-12-12T21:38:32.963Z]     component_trace = _Fire(component, args, parsed_flag_args, context, name)
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 475, in _Fire
[2022-12-12T21:38:32.963Z]     component, remaining_args = _CallAndUpdateTrace(
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 691, in _CallAndUpdateTrace
[2022-12-12T21:38:32.963Z]     component = fn(*varargs, **kwargs)
[2022-12-12T21:38:32.963Z]   File "/tmp/tmp3r2jiw7p/workdir/swinunetr_0/scripts/train.py", line 144, in run
[2022-12-12T21:38:32.963Z]     train_ds = monai.data.CacheDataset(
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/dataset.py", line 814, in __init__
[2022-12-12T21:38:32.963Z]     self.set_data(data)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/dataset.py", line 841, in set_data
[2022-12-12T21:38:32.963Z]     self._cache = self._fill_cache(indices)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/dataset.py", line 871, in _fill_cache
[2022-12-12T21:38:32.963Z]     return list(p.imap(self._load_cache_item, indices))
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/multiprocessing/pool.py", line 868, in next
[2022-12-12T21:38:32.963Z]     raise value
[2022-12-12T21:38:32.963Z]   File "/opt/conda/lib/python3.8/multiprocessing/pool.py", line 125, in worker
[2022-12-12T21:38:32.963Z]     result = (True, func(*args, **kwds))
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/data/dataset.py", line 884, in _load_cache_item
[2022-12-12T21:38:32.963Z]     item = apply_transform(_xform, item)
[2022-12-12T21:38:32.963Z]   File "/home/jenkins/agent/workspace/Monai-pytorch-versions/monai/transforms/transform.py", line 129, in apply_transform
[2022-12-12T21:38:32.963Z]     raise RuntimeError(f"applying transform {transform}") from e
[2022-12-12T21:38:32.963Z] RuntimeError: applying transform <monai.transforms.croppad.dictionary.SpatialPadd object at 0x7f2c3619d790>
[2022-12-12T21:38:33.888Z] 
[2022-12-12T21:38:33.889Z] EFinished test: test_ensemble (tests.test_auto3dseg_ensemble.TestEnsembleBuilder) (61.9s)
```

</details>

cc @mingxin-zheng @Nic-Ma  I'm not sure if the issue is from this codebase or the algo templates, the last successful run was at 25130db17751bb709e841b9727f34936a84f9093


Discussion:

Resolving patch:
diff --git a/monai/transforms/croppad/array.py b/monai/transforms/croppad/array.py
--- a/monai/transforms/croppad/array.py
+++ b/monai/transforms/croppad/array.py
@@ -183,10 +183,14 @@ def __call__(  # type: ignore
                     )
                     out = _pad(img_t, pad_width=to_pad_, mode=mode_, **kwargs_)
                 except (ValueError, TypeError, RuntimeError) as err:
-                    if "supported" in str(err) or "unexpected keyword" in str(err) or "implemented" in str(err):
+                    if isinstance(err, NotImplementedError) or any(
+                        k in str(err) for k in ("supported", "unexpected keyword", "implemented")
+                    ):
                         out = self._np_pad(img_t, pad_width=to_pad_, mode=mode_, **kwargs_)
                     else:
-                        raise ValueError(f"{mode_}, {kwargs_}, {img_t.dtype}, {img_t.device}") from err
+                        raise ValueError(
+                            f"{img_t.shape} {to_pad_} {mode_} {kwargs_} {img_t.dtype} {img_t.device}"
+                        ) from err
         else:
             out = img_t
         if get_track_meta():


Test patch: