anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: trusted-ai/adversarial-robustness-toolbox
Issue: Adversarial Patch Error in `PyTorchObjectDetector`

**Describe the bug**
When running the adversarial patch attack for the `PyTorchObjectDetector` and `PyTorchFasterRCNN`, an error can occur when using any PyTorch-specific preprocessors.

**To Reproduce**
Steps to reproduce the behavior:
Run the adversarial patch attack on the `PyTorchObjectDetector` while using a Faster R-CNN model. When using additional PyTorch-specific preprocessors, the error above will occur.

**Expected behavior**
The attacks should run without error. It can be easily fixed by adding the following if-condition 

```python
if x_tensor.is_leaf:
    x_tensor.requires_grad = True
else:
    x_tensor.retain_grad()
```

when setting the gradients to true. This if-condition is already applied for the `PyTorchYolo` detector, it just needs to be copied to the `PyTorchObjectDetector`.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**System information (please complete the following information):**
 - OS
 - Python version
 - ART version or commit number
 - TensorFlow / Keras / PyTorch / MXNet version


Changed files:
art/estimators/object_detection/pytorch_object_detector.py

diff --git a/art/estimators/object_detection/pytorch_object_detector.py b/art/estimators/object_detection/pytorch_object_detector.py
index fecb0fafc..06025be8d 100644
--- a/art/estimators/object_detection/pytorch_object_detector.py
+++ b/art/estimators/object_detection/pytorch_object_detector.py
@@ -219,7 +219,10 @@ class PyTorchObjectDetector(ObjectDetectorMixin, PyTorchEstimator):
 
             # Set gradients
             if not no_grad:
-                x_tensor.requires_grad = True
+                if x_tensor.is_leaf:
+                    x_tensor.requires_grad = True
+                else:
+                    x_tensor.retain_grad()
 
             # Apply framework-specific preprocessing
             x_preprocessed, y_preprocessed = self._apply_preprocessing(x=x_tensor, y=y_tensor, fit=fit, no_grad=no_grad)
Repository: trusted-ai/adversarial-robustness-toolbox
Issue: Remove unintended required dependency on PIL

**Describe the bug**
Recent version of ART became dependent on an installation of `PIL`. We would like to change it back to an optional dependency.


Changed files:
art/attacks/poisoning/perturbations/image_perturbations.py, art/visualization.py

diff --git a/art/attacks/poisoning/perturbations/image_perturbations.py b/art/attacks/poisoning/perturbations/image_perturbations.py
index 9355f054a..d04cbe9d0 100644
--- a/art/attacks/poisoning/perturbations/image_perturbations.py
+++ b/art/attacks/poisoning/perturbations/image_perturbations.py
@@ -21,7 +21,6 @@ Adversarial perturbations designed to work for images.
 from typing import Optional, Tuple
 
 import numpy as np
-from PIL import Image
 
 
 def add_single_bd(x: np.ndarray, distance: int = 2, pixel_value: int = 1) -> np.ndarray:
@@ -112,6 +111,8 @@ def insert_image(
     :param blend: The blending factor
     :return: Backdoored image.
     """
+    from PIL import Image
+
     n_dim = len(x.shape)
     if n_dim == 4:
         return np.array(
diff --git a/art/visualization.py b/art/visualization.py
index b828741fd..f33fa2bfd 100644
--- a/art/visualization.py
+++ b/art/visualization.py
@@ -25,7 +25,6 @@ import os.path
 from typing import List, Optional, TYPE_CHECKING
 
 import numpy as np
-from PIL import Image
 
 from art import config
 
@@ -97,6 +96,8 @@ def save_image(image_array: np.ndarray, f_name: str) -> None:
     :param image_array: Image to be saved.
     :param f_name: File name containing extension e.g., my_img.jpg, my_img.png, my_images/my_img.png.
     """
+    from PIL import Image
+
     file_name = os.path.join(config.ART_DATA_PATH, f_name)
     folder = os.path.split(file_name)[0]
     if not os.path.exists(folder):
Repository: trusted-ai/adversarial-robustness-toolbox
Issue: cannot import name 'TensorFlowV2RandomizedSmoothing' from partially initialized module

**Describe the bug**
In several poisoning attack or defense notebooks I will receive a partial import error. for Randomized Smoothing. Is there a quick way to fix?

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'most poisoning_attack or poisoning_defence notebooks.'
2. Click on 'run'

**Screenshots**
![image](https://github.com/Trusted-AI/adversarial-robustness-toolbox/assets/77859420/cc6d8938-ad0f-45d3-9938-38f965cda69a)


Changed files:
art/estimators/certification/__init__.py

diff --git a/art/estimators/certification/__init__.py b/art/estimators/certification/__init__.py
index 8a0a07f4e..33a97ad7a 100644
--- a/art/estimators/certification/__init__.py
+++ b/art/estimators/certification/__init__.py
@@ -2,12 +2,26 @@
 This module contains certified classifiers.
 """
 import importlib
-from art.estimators.certification import randomized_smoothing
-from art.estimators.certification import derandomized_smoothing
+from art.estimators.certification.randomized_smoothing.randomized_smoothing import RandomizedSmoothingMixin
+from art.estimators.certification.randomized_smoothing.numpy import NumpyRandomizedSmoothing
+from art.estimators.certification.randomized_smoothing.tensorflow import TensorFlowV2RandomizedSmoothing
+from art.estimators.certification.randomized_smoothing.pytorch import PyTorchRandomizedSmoothing
+from art.estimators.certification.derandomized_smoothing.derandomized_smoothing import DeRandomizedSmoothingMixin
+from art.estimators.certification.derandomized_smoothing.pytorch import PyTorchDeRandomizedSmoothing
+from art.estimators.certification.derandomized_smoothing.tensorflow import TensorFlowV2DeRandomizedSmoothing
 
 if importlib.util.find_spec("torch") is not None:
-    from art.estimators.certification import deep_z
-    from art.estimators.certification import interval
+    from art.estimators.certification.deep_z.deep_z import ZonoDenseLayer
+    from art.estimators.certification.deep_z.deep_z import ZonoBounds
+    from art.estimators.certification.deep_z.deep_z import ZonoConv
+    from art.estimators.certification.deep_z.deep_z import ZonoReLU
+    from art.estimators.certification.deep_z.pytorch import PytorchDeepZ
+    from art.estimators.certification.interval.interval import PyTorchIntervalDense
+    from art.estimators.certification.interval.interval import PyTorchIntervalConv2D
+    from art.estimators.certification.interval.interval import PyTorchIntervalReLU
+    from art.estimators.certification.interval.interval import PyTorchIntervalFlatten
+    from art.estimators.certification.interval.interval import PyTorchIntervalBounds
+    from art.estimators.certification.interval.pytorch import PyTorchIBPClassifier
 else:
     import warnings