code: def test_guided_grad_modifier():
      # Create a simple 2 dense layer model.
      simple_model = Sequential(
          [
              Dense(
                  2,
                  activation="relu",
                  use_bias=False,
                  kernel_initializer=Constant(
                      [[-1.0, 1.0], [-1.0, 1.0]]
                  ),
                  input_shape=(2,),
              ),
              Dense(
                  1,
                  activation="linear",
                  use_bias=False,
                  kernel_initializer=Constant([-1.0, 1.0]),
              ),
          ]
      )
      simple_model.compile(
          loss=keras.losses.categorical_crossentropy,
          optimizer=keras.optimizers.Adam(),
      )
  
      # Create a simple 2 dense layer model using Activation.
      simple_model_with_activation = Sequential(
          [
              Dense(
                  2,
                  activation="linear",
                  use_bias=False,
                  kernel_initializer=Constant(
                      [[-1.0, 1.0], [-1.0, 1.0]]
                  ),
                  input_shape=(2,),
              ),
              Activation("relu"),
              Dense(
                  1,
                  activation="linear",
                  use_bias=False,
                  kernel_initializer=Constant([-1.0, 1.0]),
              ),
          ]
      )
      simple_model_with_activation.compile(
          loss=keras.losses.categorical_crossentropy,
          optimizer=keras.optimizers.Adam(),
      )
  
      for i, model in enumerate(
          [simple_model, simple_model_with_activation]
      ):
          # Create guided backprop model
          modified_model = modify_model_backprop(model, "guided")
  
          # Gradients are zeros.
          input_array = [0.0, 0.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [0.0, 0.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [0.0, 0.0]
          )
  
          # Below 3 cases, GuidedBackprop gradients is the same as Original gradients.
          input_array = [1.0, 0.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [1.0, 1.0]
          )
  
          input_array = [0.0, 1.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [1.0, 1.0]
          )
  
          input_array = [1.0, 1.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [1.0, 1.0]
          )
  
          # If inputs contains negative values,
          # GuidedBackprop gradients is not the same as Original gradients.
          input_array = [-1.0, 0.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [0.0, 0.0]
          )
  
          input_array = [0.0, -1.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [0.0, 0.0]
          )
  
          input_array = [-1.0, -1.0]
          assert np.array_equal(
              _compute_grads(model, input_array), [1.0, 1.0]
          )
          assert np.array_equal(
              _compute_grads(modified_model, input_array), [0.0, 0.0]
          )
  
          # Activation is not changed.
          if i == 0:  # modified first model
              modified_model.layers[
                  0
              ].activation == keras.activations.relu
              modified_model.layers[
                  1
              ].activation == keras.activations.linear
          if i == 1:  # modified second model
              modified_model.layers[
                  0
              ].activation == keras.activations.linear
              modified_model.layers[
                  1
              ].activation == keras.activations.relu
              modified_model.layers[
                  2
              ].activation == keras.activations.linear
  
file_path: keras-vis/tests/vis/backend/test_backend.py
imports: import pytest
  import numpy
  from vis.backend import modify_model_backprop
  from vis.utils.test_utils import skip_backends
  import keras
  from keras.models import Model, Input, Sequential
  from keras.layers import Dense
  from keras.initializers import Constant
  from keras import backend
  from keras.activations import get
  from keras.layers import advanced_activations, Activation
label_desc: Use image node_id 2 for calling a global function with example usage: test_guided_grad_modifier() without return types