code: def test_run_forward_from_layer(layer_nb, run_from_layer_inputs):
      # One layer ffn with all weights = 1.
      inputs = tf.keras.Input(shape=(16,))
      out = tf.keras.layers.Dense(
          8,
          kernel_initializer=tf.keras.initializers.Ones(),
          name="linear1",
      )(inputs)
      out = tf.keras.layers.Dense(
          1,
          kernel_initializer=tf.keras.initializers.Ones(),
          name="linear3",
      )(out)
      model = tf.keras.Model(inputs=inputs, outputs=out)
  
      # Select layer
      layer = model.layers[layer_nb]
      orig_call = layer.call
  
      dummy_input = np.zeros((1, 16))
  
      if run_from_layer_inputs:
          x_layer = [
              tf.convert_to_tensor(
                  np.ones((2,) + (layer.input_shape[1:]))
              )
          ]
          expected_shape = (2, 1)
          expected_values = 128
      else:
          x_layer = tf.convert_to_tensor(
              np.ones((3,) + (layer.output_shape[1:]))
          )
          expected_shape = (3, 1)
          expected_values = 8
  
      preds_from_layer = _run_forward_from_layer(
          model,
          layer,
          orig_call,
          dummy_input,
          x_layer,
          None,
          run_from_layer_inputs=run_from_layer_inputs,
          select_target=False,
      )
      preds_from_layer = preds_from_layer.numpy()
  
      assert preds_from_layer.shape == expected_shape
      assert np.allclose(preds_from_layer, expected_values)
  
imports: from functools import partial
  import numpy
  import pytest
  import tensorflow
  from numpy.testing import assert_allclose
  from tensorflow.keras import Model
  from alibi.api.interfaces import Explanation
  from alibi.explainers import IntegratedGradients
  from alibi.explainers.integrated_gradients import _get_target_from_target_fn, _run_forward_from_layer, _run_forward_to_layer, _check_target, _select_target
label_desc: Use image node_id 18 for calling a global function with example usage: test_run_forward_from_layer(layer_nb, run_from_layer_inputs) without return types