code: def test_reference_layer(val, analyzer_name):
      method, kwargs = val
      data_path = os.path.join(
          os.path.abspath(os.curdir),
          "tests",
          "references",
          "vgg16",
          analyzer_name + ".hdf5",
      )
  
      tf.keras.backend.clear_session()
  
      # Load model from keras.applications
      model = VGG16(classifier_activation=None)
  
      with h5py.File(data_path, "r") as f:
          assert (
              f.attrs["analyzer_name"] == analyzer_name
          )  # sanity check: correct file
          # Model outputs should match
          x = f["input"][:]
          y = model.predict(x)
  
          y_ref = f["output"][:]
          assert np.allclose(y, y_ref, rtol=rtol, atol=atol)
  
          # Analyze model
          analyzer = method(model, **kwargs)
          if isinstance(analyzer, LRP):
              analyzer._reverse_keep_tensors = True
  
          a = analyzer.analyze(x)
          assert np.shape(a) == np.shape(x)
  
          # Set tolerances for reference tests
          if analyzer_name == "SmoothGrad":
              _atol = atol_smoothgrad
              _rtol = rtol_smoothgrad
          else:
              _atol = atol
              _rtol = rtol
  
          # Test reverse tensors
          if isinstance(analyzer, LRP):
              relevances = analyzer._reversed_tensors
              # unzip reverse tensors to strip indices
              indices, relevances = zip(*relevances)
  
              for i, r in zip(reversed(indices), reversed(relevances)):
                  idx = str(i[0])
                  r_ref = f["layerwise_relevances"][idx][:]
                  rels_match = np.allclose(
                      r, r_ref, rtol=_rtol, atol=_atol
                  )
                  if not rels_match:
                      debug_failed_all_close(
                          r,
                          r_ref,
                          f"r_{idx}",
                          analyzer_name,
                          rtol=_rtol,
                          atol=_atol,
                      )
                  else:
                      print(f"r_{idx} passed")
                  assert rels_match
  
          # Test attribution
          a_ref = f["attribution"][:]
          attributions_match = np.allclose(
              a, a_ref, rtol=_rtol, atol=_atol
          )
          if not attributions_match:
              debug_failed_all_close(
                  a, a_ref, "a", analyzer_name, rtol=_rtol, atol=_atol
              )
          assert attributions_match
  
file_path: innvestigate/tests/analyzer/test_reference_vgg16.py
imports: import os
  import h5py
  import numpy
  import pytest
  import tensorflow
  from tensorflow.keras.applications import VGG16
  from innvestigate.analyzer.deeptaylor import BoundedDeepTaylor, DeepTaylor
  from innvestigate.analyzer.gradient_based import Deconvnet, Gradient, GuidedBackprop, InputTimesGradient, IntegratedGradients, SmoothGrad
  from innvestigate.analyzer.relevance_based.relevance_analyzer import LRP, LRPZ, LRPAlpha1Beta0, LRPAlpha1Beta0IgnoreBias, LRPAlpha2Beta1, LRPAlpha2Beta1IgnoreBias, LRPEpsilon, LRPFlat, LRPSequentialPresetA, LRPSequentialPresetAFlat, LRPSequentialPresetB, LRPSequentialPresetBFlat, LRPWSquare, LRPZPlus, LRPZPlusFast
label_desc: Use image node_id 2 for calling a global function with example usage: test_reference_layer(val, analyzer_name) without return types