code: def test_tf_embedding_similarity(trainable_emd, grads_shape):
      """Test `GradientSimilarity` explainer correctly handles sparsity and non-trainable layers for `tensorflow`.
  
      Test that `tensorflow` embedding layers work as expected and also that layers
      marked as non-trainable are not included in the gradients.
      See https://github.com/SeldonIO/alibi/issues/828.
      """
      model = tf.keras.models.Sequential(
          [
              tf.keras.layers.Embedding(
                  10, 4, input_shape=(5,), trainable=trainable_emd
              ),
              tf.keras.layers.Flatten(),
              tf.keras.layers.Dense(1),
          ]
      )
  
      X = tf.random.uniform(
          shape=(1, 5), minval=0, maxval=10, dtype=tf.float32
      )
      Y = tf.random.uniform(
          shape=(1, 1), minval=0, maxval=10, dtype=tf.float32
      )
      loss_fn = tf.keras.losses.MeanSquaredError()
      tf_grads = _TensorFlowBackend.get_grads(model, X, Y, loss_fn)
      assert tf_grads.shape == grads_shape
  
file_path: alibi/alibi/explainers/tests/test_simiarlity/test_backends.py
imports: import pytest
  import torch
  import numpy
  import tensorflow
  from alibi.explainers.similarity.backends.tensorflow.base import _TensorFlowBackend
  from alibi.explainers.similarity.backends.pytorch.base import _PytorchBackend
label_desc: Use image node_id 2 for calling a global function with example usage: test_tf_embedding_similarity(trainable_emd, grads_shape) without return types