Repository: Project-MONAI/MONAI

Issue:
Potential 3D bug in EfficientNet Squeeze and Excitation layer
efficientnet.py

```
        if self.has_se:
            self._se_adaptpool = adaptivepool_type(1)
            num_squeezed_channels = max(1, int(in_channels * self.se_ratio))
            self._se_reduce = conv_type(in_channels=oup, out_channels=num_squeezed_channels, kernel_size=1)
            self._se_reduce_padding = _make_same_padder(self._se_reduce, [1, 1])
            self._se_expand = conv_type(in_channels=num_squeezed_channels, out_channels=oup, kernel_size=1)
            self._se_expand_padding = _make_same_padder(self._se_expand, [1, 1])
```

I believe the image_size = [1, 1] in _make_same_padder() should actually be [1, 1, 1] for the EfficientNet to support 3D. This is just by inspection, but I suspect this oversight came from extending 2D code.

3D bug in EfficientNet Squeeze and Excitation layer
Fixes #5574.

### Description

I believe the image_size = [1, 1] in _make_same_padder() should actually be [1, 1, 1] for the EfficientNet to support 3D. This is just by inspection, but I suspect this oversight came from extending 2D code.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not applicable items -->
- [x] Non-breaking change (fix or new feature that would not break existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests  --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/` folder.



Discussion:
agreed, would you like to contribute a fix?
Great, yes. I'm new to Monai, are there any special instructions?
Sure, the contributing guide has some details https://github.com/Project-MONAI/MONAI/blob/dev/CONTRIBUTING.md and please let me know if you have any specific questions
Hi @yiheng-wang-nv could you please help fix this one, it seems https://github.com/Project-MONAI/MONAI/pull/5695 had stalled.


Resolving patch:
diff --git a/monai/networks/nets/efficientnet.py b/monai/networks/nets/efficientnet.py
--- a/monai/networks/nets/efficientnet.py
+++ b/monai/networks/nets/efficientnet.py
@@ -163,9 +163,9 @@ def __init__(
             self._se_adaptpool = adaptivepool_type(1)
             num_squeezed_channels = max(1, int(in_channels * self.se_ratio))
             self._se_reduce = conv_type(in_channels=oup, out_channels=num_squeezed_channels, kernel_size=1)
-            self._se_reduce_padding = _make_same_padder(self._se_reduce, [1, 1])
+            self._se_reduce_padding = _make_same_padder(self._se_reduce, [1] * spatial_dims)
             self._se_expand = conv_type(in_channels=num_squeezed_channels, out_channels=oup, kernel_size=1)
-            self._se_expand_padding = _make_same_padder(self._se_expand, [1, 1])
+            self._se_expand_padding = _make_same_padder(self._se_expand, [1] * spatial_dims)
 
         # Pointwise convolution phase
         final_oup = out_channels


Test patch:
diff --git a/tests/test_vitautoenc.py b/tests/test_vitautoenc.py
--- a/tests/test_vitautoenc.py
+++ b/tests/test_vitautoenc.py
@@ -65,6 +65,13 @@
 
 
 class TestPatchEmbeddingBlock(unittest.TestCase):
+    def setUp(self):
+        self.threads = torch.get_num_threads()
+        torch.set_num_threads(4)
+
+    def tearDown(self):
+        torch.set_num_threads(self.threads)
+
     @parameterized.expand(TEST_CASE_Vitautoenc)
     @skip_if_windows
     def test_shape(self, input_param, input_shape, expected_shape):
diff --git a/tests/utils.py b/tests/utils.py
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -153,6 +153,7 @@ def skip_if_downloading_fails():
                 "md5 check",
                 "limit",  # HTTP Error 503: Egress is over the account limit
                 "authenticate",
+                "timed out",  # urlopen error [Errno 110] Connection timed out
             )
         ):
             raise unittest.SkipTest(f"error while downloading: {rt_e}") from rt_e  # incomplete download