code: def test_method_task_error_messaging(linear_cls_model):
      """
      `task` must be one of ``'classification'`` or ``'regression'``.
      """
      backend, model, loss_fn, target_fn = linear_cls_model
  
      # sim_fn is one of ['grad_dot', 'grad_cos']
      with pytest.raises(ValueError) as err:
          GradientSimilarity(
              predictor=model,
              loss_fn=loss_fn,
              precompute_grads=False,
              backend=backend,
              task="not_classification",
          )
  
      assert (
          f"Unknown task not_classification. Consider using: {_get_options_string(Task)}."
          in str(err.value)
      )
  
      for task in ["classification", "regression"]:
          GradientSimilarity(
              predictor=model,
              loss_fn=loss_fn,
              precompute_grads=False,
              backend=backend,
              task=task,
          )
  
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 4 for calling a global function with example usage: test_method_task_error_messaging(linear_cls_model) without return types