class_docstr: Class for extracting activations and
  registering gradients from targeted intermediate layers 
code: def __init__(self, model, target_layers, reshape_transform):
      self.model = model
      self.gradients = []
      self.activations = []
      self.reshape_transform = reshape_transform
      self.handles = []
      for target_layer in target_layers:
          self.handles.append(
              target_layer.register_forward_hook(self.save_activation)
          )
          # Backward compatibility with older pytorch versions:
          if hasattr(target_layer, "register_full_backward_hook"):
              self.handles.append(
                  target_layer.register_full_backward_hook(
                      self.save_gradient
                  )
              )
          else:
              self.handles.append(
                  target_layer.register_backward_hook(
                      self.save_gradient
                  )
              )
  
imports: import cv2
  import numpy
label_desc: Use image node_id 1 to create a new ActivationsAndGradients object  with example: obj = ActivationsAndGradients(model, target_layers, reshape_transform)