code: def test_device_error_msgs(linear_reg_model):
      """
      Test that incorrect device type raises an error for each backend.
      """
  
      backend, model, loss_fn, target_fn = linear_reg_model
      with pytest.raises(TypeError) as err:
          GradientSimilarity(
              predictor=model,
              loss_fn=loss_fn,
              sim_fn="grad_dot",
              precompute_grads=False,
              backend=backend,
              device=[0],
          )
      if backend == "pytorch":
          assert (
              "`device` must be a ``None``, `string`, `integer` or `torch.device` object."
              " Got <class 'list'> instead."
          ) in str(err.value)
      elif backend == "tensorflow":
          assert (
              "`device` must be a `string` or ``None``. Got <class 'list'> instead."
              in str(err.value)
          )
  
file_path: alibi/alibi/explainers/tests/test_simiarlity/test_grad_methods_unit.py
imports: import pytest
  from alibi.explainers.tests.test_simiarlity.conftest import get_flattened_model_parameters
  from alibi.explainers.similarity.grad import GradientSimilarity, Task
  from alibi.utils import _get_options_string
label_desc: Use image node_id 7 for calling a global function with example usage: test_device_error_msgs(linear_reg_model) without return types