code: def set_hook(self, cfg):
      # set hook for extraction of featuremaps and grads
      self.target_feats = {}
      self.target_layer_name = cfg.target_feature_layer_name
      # such as trainer.model.backbone, trainer.model.bbox_head.roi_extractor
  
      def hook(layer, input, output):
          self.target_feats[layer._layer_name_for_hook] = output
  
      try:
          exec(
              "self.trainer."
              + self.target_layer_name
              + "._layer_name_for_hook = self.target_layer_name"
          )
          # self.trainer.target_layer_name._layer_name_for_hook = self.target_layer_name
          exec(
              "self.trainer."
              + self.target_layer_name
              + ".register_forward_post_hook(hook)"
          )
          # self.trainer.target_layer_name.register_forward_post_hook(hook)
      except:
          print(
              "Error! "
              "The target_layer_name--"
              + self.target_layer_name
              + " is not in model! "
              "Please check the spelling and "
              "the network's architecture!"
          )
          sys.exit()
  
file_path: PaddleDetection/ppdet/utils/cam_utils.py
imports: import numpy
  import cv2
  import os
  import sys
  import glob
  from ppdet.utils.logger import setup_logger
  import copy
  import paddle
  from ppdet.engine import Trainer
label_desc: Use image node_id 3 for calling the BBoxCAM obj's underlying member method code with example usage: obj.set_hook(cfg) without return types