code: def test_non_numpy_grads_tensorflow():
      """Test that the `tensorflow` backend handles gradients without `numpy` methods correctly.
  
      `_TensorFlowBackend` should throw an error if the gradients cannot be converted to `numpy` arrays.
      """
  
      class MockTensor:
          is_sparse = False
  
      with pytest.raises(TypeError) as err:
          _TensorFlowBackend._grad_to_numpy(MockTensor())
  
      assert (
          "Could not convert gradient to `numpy` array. To ignore these gradients "
          "in the similarity computation set ``trainable=False`` on the corresponding parameter."
      ) in str(err.value)
  
      with pytest.raises(TypeError) as err:
          _TensorFlowBackend._grad_to_numpy(MockTensor(), "test")
  
      assert (
          "Could not convert gradient to `numpy` array for the named tensor: test."
          " To ignore these gradients in the similarity computation set "
          "``trainable=False`` on the corresponding parameter."
      ) in str(err.value)
  
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 5 for calling a global function with example usage: test_non_numpy_grads_tensorflow() without return types